aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/google-oauth220
-rwxr-xr-xbin/menu-contacts9
-rwxr-xr-xbin/menu-lesspass22
-rwxr-xr-xbin/menu-pass24
4 files changed, 75 insertions, 0 deletions
diff --git a/bin/google-oauth2 b/bin/google-oauth2
new file mode 100755
index 0000000..3ef43b9
--- /dev/null
+++ b/bin/google-oauth2
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Reads client secret and client token from STDIN (slightly better than as
+# args, which are public), one in each line respectively.
+#
+# Calls into Google's OAuth2 API with that info to retrieve an access token,
+# which is output to STDOUT.
+#
+# CLIENT_ID is the only argument taken by this script.
+
+CLIENT_ID=$1
+read -r CLIENT_SECRET
+read -r REFRESH_TOKEN
+
+curl --silent \
+ --data client_id=$CLIENT_ID \
+ --data client_secret=$CLIENT_SECRET \
+ --data grant_type=refresh_token \
+ --data refresh_token=$REFRESH_TOKEN \
+ 'https://www.googleapis.com/oauth2/v4/token' | jq -r .access_token \ No newline at end of file
diff --git a/bin/menu-contacts b/bin/menu-contacts
new file mode 100755
index 0000000..f2f3454
--- /dev/null
+++ b/bin/menu-contacts
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Search in contact list built by khard using bemenu, outputs the selected
+# option as FirstName LastName <address>
+
+khard email --remove-first-line --parsable \
+ | cut -f 1,2 \
+ | bemenu -i -s -c -l 20 -W 0.5 -p '@' \
+ | awk -F "\t" '{printf "%s <%s>\n", $2, $1}'
diff --git a/bin/menu-lesspass b/bin/menu-lesspass
new file mode 100755
index 0000000..3abdfd0
--- /dev/null
+++ b/bin/menu-lesspass
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Search in logins list using bemenu. Assumes a .config/logins.db.asc file exists
+# with:
+# DOMAIN_1 USERNAME_1
+# DOMAIN_2 USERNAME_2
+# ...
+# DOMAIN_N USERNAME_N
+# pairs, one per line.
+
+SELECTION=`gpg --decrypt $HOME/.config/logins.db.asc 2>/dev/null | bemenu -i -s -c -l 20 -W 0.2 -p '*'`
+DOMAIN=`echo $SELECTION | cut -f 1 -d ' '`
+USERNAME=`echo $SELECTION | cut -f 2 -d ' '`
+OPTIONS=`echo $SELECTION | cut -f 1,2 -d ' ' --complement`
+
+if [ -z $USERNAME ] || [ -z $DOMAIN ]; then
+ exit 1
+fi
+
+# -c copies to clipboard
+export LESSPASS_MASTER_PASSWORD=`pass lesspass`
+lesspass $DOMAIN $USERNAME $OPTIONS -c 2>&1 >/dev/null
diff --git a/bin/menu-pass b/bin/menu-pass
new file mode 100755
index 0000000..74468d6
--- /dev/null
+++ b/bin/menu-pass
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Select which password from pass(1) to copy into the clipboard using an interactive menu
+#
+# Inspired by
+# https://github.com/ibizaman/pass-clip/blob/9ef6e932e1149c07e991c82f916d018f3fbf0694/clip.bash
+
+PASSWORD_STORE_DIR="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+
+passfile=$(find -L "${PASSWORD_STORE_DIR}" \
+ -path '*/.git' \
+ -prune \
+ -o \
+ -iname '*.gpg' \
+ -printf '%P\n' \
+ | sed -e 's/.gpg$//' \
+ | bemenu -i -s -c -l 20 -W 0.2 -p '*')
+
+if [ -z $passfile ]
+then
+ exit 1
+else
+ pass show -c $passfile
+fi