summaryrefslogtreecommitdiff
path: root/dwm-6.3/scripts
diff options
context:
space:
mode:
authorstkhan <personal@slickd.xyz>2022-04-21 17:15:27 -0500
committerstkhan <personal@slickd.xyz>2022-04-21 17:15:27 -0500
commit6d5f8c137608df2e459c9865efa19c72856ed6e8 (patch)
treebde7ebb7e20ac737d10c25b6503228395645a8db /dwm-6.3/scripts
parentdf966cab682c913e8b62b460c9ef900e1046863f (diff)
added stuff:
Diffstat (limited to 'dwm-6.3/scripts')
-rwxr-xr-xdwm-6.3/scripts/passmenu35
-rwxr-xr-xdwm-6.3/scripts/passmenu260
-rwxr-xr-xdwm-6.3/scripts/power8
3 files changed, 43 insertions, 60 deletions
diff --git a/dwm-6.3/scripts/passmenu b/dwm-6.3/scripts/passmenu
new file mode 100755
index 0000000..76d92ab
--- /dev/null
+++ b/dwm-6.3/scripts/passmenu
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+shopt -s nullglob globstar
+
+typeit=0
+if [[ $1 == "--type" ]]; then
+ typeit=1
+ shift
+fi
+
+if [[ -n $WAYLAND_DISPLAY ]]; then
+ dmenu=dmenu-wl
+ xdotool="ydotool type --file -"
+elif [[ -n $DISPLAY ]]; then
+ dmenu=dmenu
+ xdotool="xdotool type --clearmodifiers --file -"
+else
+ echo "Error: No Wayland or X11 display detected" >&2
+ exit 1
+fi
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
+
+[[ -n $password ]] || exit
+
+if [[ $typeit -eq 0 ]]; then
+ pass show -c "$password" 2>/dev/null
+else
+ pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+fi
diff --git a/dwm-6.3/scripts/passmenu2 b/dwm-6.3/scripts/passmenu2
deleted file mode 100755
index 3847219..0000000
--- a/dwm-6.3/scripts/passmenu2
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-
-shopt -s nullglob globstar
-
-typeit=0
-if [[ $1 == "--type" ]]; then
- typeit=1
- shift
-fi
-
-
-STARTDIR=${PASSWORD_STORE_DIR-~/.password-store}
-BASEDIR=$STARTDIR
-DONE=0
-LEVEL=0
-PREVSELECTION=""
-SELECTION=""
-
-while [ "$DONE" -eq 0 ] ; do
- password_files=( "$STARTDIR"/* )
- password_files=( "${password_files[@]#"$STARTDIR"/}" )
- password_files=( "${password_files[@]%.gpg}" )
-
- if [ "$LEVEL" -ne 0 ] ; then
- password_files=(".." "${password_files[@]}")
- fi
- entry=$(printf '%s\n' "${password_files[@]}" | dmenu "$@" -l 15)
-
- echo "entry: $entry"
- if [ -z "$entry" ] ; then
- DONE=1
- exit
- fi
-
- if [ "$entry" != ".." ] ; then
- PREVSELECTION=$SELECTION
- SELECTION="$SELECTION/$entry"
-
- # check if another dir
- if [ -d "$STARTDIR/$entry" ] ; then
- STARTDIR="$STARTDIR/$entry"
- LEVEL=$((LEVEL+1))
- else
- # not a directory so it must be a real password entry
-
- if [[ $typeit -eq 0 ]]; then
- pass show -c "$SELECTION" 2>/dev/null
- else
- xdotool - <<<"type --clearmodifiers -- $(pass show "$SELECTION" | head -n 1)"
- fi
- DONE=1
- fi
-
- else
- LEVEL=$((LEVEL-1))
- SELECTION=$PREVSELECTION
- STARTDIR="$BASEDIR/$SELECTION"
- fi
-done
-
diff --git a/dwm-6.3/scripts/power b/dwm-6.3/scripts/power
new file mode 100755
index 0000000..d376fa9
--- /dev/null
+++ b/dwm-6.3/scripts/power
@@ -0,0 +1,8 @@
+#!/bin/sh
+# A dmenu wrapper script for system functions.
+
+case "$(printf "🔃 reboot\n🖥️shutdown\n" | dmenu -i -p 'Power: ')" in
+ '🔃 reboot') sudo reboot ;;
+ '🖥️shutdown') sudo poweroff ;;
+ *) exit 1 ;;
+esac