summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbertalanp99 <bertalanp99+git@bertalanp99.eu>2019-05-21 19:58:45 +0200
committerbertalanp99 <bertalanp99+git@bertalanp99.eu>2019-05-21 19:58:45 +0200
commit016794a45bd128dd8b1a433343a4deb5233ae5e9 (patch)
treee1d46b2d263b47f7ff8382b0c80c00be5e8fe338
downloadscripts-016794a45bd128dd8b1a433343a4deb5233ae5e9.tar.gz
scripts-016794a45bd128dd8b1a433343a4deb5233ae5e9.zip
initial commit
-rwxr-xr-xpassmenu/passmenu112
-rw-r--r--passmenu/passmenu.189
-rwxr-xr-xrundwm/rundwm20
-rwxr-xr-xsyncimap/syncimap31
4 files changed, 252 insertions, 0 deletions
diff --git a/passmenu/passmenu b/passmenu/passmenu
new file mode 100755
index 0000000..987fbb9
--- /dev/null
+++ b/passmenu/passmenu
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+###
+# passmenu - dmenu interface for password-store
+#
+# The popular, commonly used script for this purpose is available at
+# <https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu>
+# (as of 2019-05-20).
+# However, that script has been written in bash. This is my own, pure sh
+# implementation. I believe it is slower and a lot less efficient. Nevertheless,
+# it just works(TM). It is also tailored to my own liking.
+#
+# The script requires the following binaries in PATH to work:
+# - pass (password-store, obviously)
+# - dmenu (also rather obvious)
+# - xsel (for the ability to copy the username only)
+#
+# The script has a manual included, but for the sake of redundancy, the options
+# are also listed below. It accepts all options dmenu accepts and uses them as
+# expected.
+#
+# SYNOPSIS: passmenu [-hu] [dmenu options]
+# -h, --help print usage
+# -u, --username copy the username, not the password
+#
+# bertalanp99@ 2019-05-20
+###
+
+#################
+### FUNCTIONS ###
+#################
+
+usage()
+{
+ printf 'usage: passmenu [-hu]'
+}
+
+
+#################
+### VARIABLES ###
+#################
+
+prefix=${PASSWORD_STORE_DIR-$HOME/.password-store/}
+
+
+##############
+### SCRIPT ###
+##############
+
+### CHECK FOR BINARIES IN PATH ###
+
+for binary in pass dmenu xsel
+do
+ if ! command -v $binary >/dev/null 2>&1
+ then
+ echo "this script needs '$binary' in PATH to work"
+ exit 1
+ fi
+done
+
+### PARSE OPTIONS ###
+
+needuser=0
+dmenuoptions=
+while [ -n "$1" ]
+do
+ case $1 in
+ -b|-f|-i|-v)
+ dmenuoptions="$dmenuoptions $1"
+ ;;
+
+ -l|-m|-p|-fn|-nb|-nf|-sb|-sf|-w)
+ dmenuoptions="$dmenuoptions $1 $2"
+ shift
+ ;;
+
+ -h|--help)
+ usage
+ exit 0
+ ;;
+
+ -u|--username)
+ needuser=1
+ ;;
+
+ *)
+ echo unknown option \'"$1"\'
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+### MAIN ###
+
+password="$(\
+ find "$prefix" -name '*.gpg' |\
+ sed "s|${prefix}\(.*\).gpg|\1|" |\
+ dmenu $dmenuoptions)"
+
+if [ $needuser -eq 0 ]
+then
+ pass show --clip "$password" >/dev/null 2>&1
+else
+ pass show "$password" 2>/dev/null |\
+ head -2 |\
+ tail -1 |\
+ sed 's/login: //' |\
+ tr -d '\n' |\
+ xsel --input --clipboard
+fi
diff --git a/passmenu/passmenu.1 b/passmenu/passmenu.1
new file mode 100644
index 0000000..399ae3a
--- /dev/null
+++ b/passmenu/passmenu.1
@@ -0,0 +1,89 @@
+.\"""
+.\" passmenu.1 - passmenu man page
+.\"
+.\" bertalanp99@ 2019-05-20
+.\"""
+.Dd 2019-05-20
+.Dt PASSMENU 1
+.Os
+.Sh NAME
+.Nm passmenu
+.Nd dmenu interface for password-store (pass)
+.Sh SYNOPSIS
+.Nm passmenu
+.Op Fl hu
+.Op dmenu options
+.Sh DESCRIPTION
+The
+.Nm
+utility provides a quick and easy interface for
+.Xr pass 1
+using
+.Xr dmenu 1
+.Ns . It reads all passwords from
+.Ev PASSWORD_STORE DIR
+(
+.Ns Pa ~/.password-store
+if unset) and displays them in dmenu. The selected password is
+copied to the clipboard.
+
+The following options are available:
+.Bl -tag -width Ds -compact
+.It Fl h
+Print usage
+.It Fl u
+Copy the username, not the password
+.It dmenu options
+.Nm
+accepts all options
+.Xr dmenu 1
+accepts and passes them to it.
+.El
+.Sh ENVIRONMENT
+.Pp
+The following environment variables affect
+.Nm
+:
+.Bl -tag -width Ds -compact
+.It Ev PASSWORD_STORE_DIR
+The location of the password-store
+.El
+.Sh EXIT STATUS
+.Nm
+returns 0 on success
+and
+1 on any error
+.Sh EXAMPLES
+Run
+.Nm
+with various options passed to dmenu:
+.Bd -literal -offset indent -compact
+passmenu -nb '#000' -nf '#FFF' -sb '#AAA' -sf '#000'
+.Be
+.Sh SEE ALSO
+.Xr pass 1
+.Xr dmenu 1
+.Sh HISTORY
+There is a popular script with the same name, however, that is a different
+implementation. As of 2019-05-20, said script is available at
+.Lk https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu
+.Sh AUTHORS
+The
+.Nm
+script was written by
+.An Bertalan Z. P├ęter Aq Mt bertalanp99@bertalanp99.eu
+.Sh CAVEATS
+.Pp
+Beware that when copying passwords using the
+.Fl u
+option,
+.Nm
+actually just takes the second line of the password file and trims the string
+.Ql login:\
+out. Therefore passwords are expected to be stored in the form
+.Bd -literal -offset indent -compact
+my-highly-secure-password999
+login: my-username
+url: https://some-site.domain
+\&...
+.Ed
diff --git a/rundwm/rundwm b/rundwm/rundwm
new file mode 100755
index 0000000..ce14fe7
--- /dev/null
+++ b/rundwm/rundwm
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+###
+# rundmw - run dwm and restart when killed
+#
+# box: watermelon
+# os: openbsd
+#
+# This script allows running dwm in a loop, so when it exits, the X session is
+# preserved and dwm is started again.
+#
+# In order to properly terminate the X session, this script must be killed.
+#
+# bertalanp99@ 2019-05-18
+###
+
+while true
+do
+ dwm 2>$HOME/.log/dwm-errors.log
+done
diff --git a/syncimap/syncimap b/syncimap/syncimap
new file mode 100755
index 0000000..9e02cb8
--- /dev/null
+++ b/syncimap/syncimap
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+###
+# syncimap - Synchronize IMAP email using isync/mbsync
+#
+# This script is just a simple wrapper around `mbsync`. It is intended to call
+# this script from a cron job like this:
+#
+# * * * * * -n /path/to/syncimap
+#
+# (see crontab(5))
+#
+# If logging is desired, I recommend using `logger` like this:
+#
+# * * * * * -n /path/to/syncimap 2>&1 | logger -t syncimap
+#
+# (this will pipe error output to a log entry using syslog)
+#
+# The script is quiet; you should only receive output in case an error occurs.
+#
+# Required binaries in PATH:
+# - mbsync (obviously)
+#
+# bertalanp99@ 2019-05-21
+###
+
+# kill instances that might have got stuck
+pkill -f mbsync
+
+# sync everything
+mbsync --all --quiet