diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/chkb | 8 | ||||
-rwxr-xr-x | .local/bin/mc-pass | 8 | ||||
-rwxr-xr-x | .local/bin/notify | 14 | ||||
-rwxr-xr-x | .local/bin/scst | 16 | ||||
-rwxr-xr-x | .local/bin/send-package | 11 | ||||
-rwxr-xr-x | .local/bin/uni | 7 | ||||
-rwxr-xr-x | .local/bin/vlt | 36 | ||||
-rwxr-xr-x | .local/sbin/chtz | 10 |
8 files changed, 64 insertions, 46 deletions
diff --git a/.local/bin/chkb b/.local/bin/chkb index b2f0d64..ac27e98 100755 --- a/.local/bin/chkb +++ b/.local/bin/chkb @@ -2,6 +2,9 @@ set -e +export NOTIFY_LONG=keyboard +export NOTIFY_SHORT=${0##*/} + readonly KEYBOARD=at-translated-set-2-keyboard s="$( @@ -19,8 +22,9 @@ s="$( if choice="$(echo "$s" | osel)" then - n="$(echo "$s" | sed -n "/$choice/=" | xargs expr -1 +)" + echo "$s" + n="$(echo "$s" | sed -n "/$choice/=" | { xargs expr -1 + || true; })" hyprctl switchxkblayout $KEYBOARD $n >/dev/null - notify "${0##*/}" keyboard 'Keyboard Layout Changed' \ + notify 'Keyboard Layout Changed' \ "The keyboard layout was changed to ‘$choice’" fi diff --git a/.local/bin/mc-pass b/.local/bin/mc-pass index 7dc868d..168e62e 100755 --- a/.local/bin/mc-pass +++ b/.local/bin/mc-pass @@ -1,12 +1,14 @@ #!/bin/sh +export NOTIFY_LONG='mc pass' +export NOTIFY_SHORT="${0##*/}" + trap ' wl-copy </dev/null - notify "${0##*/}" "mc pass" "Password Cleared" \ - "The password was cleared from the clipboard." + notify "Password Cleared" "The password was cleared from the clipboard." ' INT EXIT TERM vlt raw Email thomasvoss@live.com | wl-copy -notify "${0##*/}" 'mc pass' 'Password Copied' \ +notify 'Password Copied' \ 'The password will be cleared from the clipboard in 10 seconds.' sleep 10 diff --git a/.local/bin/notify b/.local/bin/notify index 39669fe..a87d3ab 100755 --- a/.local/bin/notify +++ b/.local/bin/notify @@ -1,18 +1,18 @@ #!/bin/sh -if [ $# -lt 4 ] +if [ $# -lt 2 ] then - echo "Usage: ${0##*/} short long summary body [args ...]" >&2 + echo "Usage: ${0##*/} summary body [args ...]" >&2 exit 1 fi if [ -t 2 ] then - printf "%s: %s\n" "$1" "$4" >&2 + printf "%s: %s\n" "$NOTIFY_SHORT" "$2" >&2 else - t="$(echo "$2" | tr a-z A-Z)" - s="$3" - b="$4." - shift 4 + t="$(echo "$NOTIFY_LONG" | tr a-z A-Z)" + s="$1" + b="$2." + shift 2 notify-send "$@" -a "$t" "$s" "$b" fi diff --git a/.local/bin/scst b/.local/bin/scst index d1ad54a..51b00c1 100755 --- a/.local/bin/scst +++ b/.local/bin/scst @@ -2,9 +2,12 @@ set -e +export NOTIFY_LONG=screenshot +export NOTIFY_SHORT="${0##*/}" + xnotify() { - notify ${0##*/} screenshot 'Screenshot Copied' \ + notify 'Screenshot Copied' \ 'Screenshot successfully copied to the clipboard' \ -i "$filename" } @@ -35,10 +38,7 @@ fi [ -f "$filename" ] || exit 1 -opt="$( - printf 'Copy screenshot\nEdit- and copy screenshot\n' \ - | { osel || true; } -)" +opt="$(printf 'Copy screenshot\nEdit- and copy screenshot\n' | { osel || true; })" case "$opt" in 'Copy screenshot') @@ -46,13 +46,11 @@ case "$opt" in xnotify ;; 'Edit- and copy screenshot') - swappy -f "$filename" -o - \ - | pee wl-copy cat \ - | sponge "$filename" + swappy -f "$filename" -o - | pee wl-copy cat | sponge "$filename" xnotify ;; *) - notify ${0##*/} screenshot 'Screenshot Saved' \ + notify 'Screenshot Saved' \ "The screenshot ‘$filebase’ was successfully saved" \ -i "$filename" esac diff --git a/.local/bin/send-package b/.local/bin/send-package new file mode 100755 index 0000000..bcd7eb0 --- /dev/null +++ b/.local/bin/send-package @@ -0,0 +1,11 @@ +#!/bin/sh + +# Why not? + +readonly tmpl="${XDG_DATA_HOME:-$HOME/.local/share}/send-package/template" + +sed -En '/^Angel Cakes/,/^Doozies/s/(\t|\s{2,})/\n/gp' ~/doc/tit-names \ +| shuf -n1 \ +| tr A-Z a-z \ +| xargs -I{} -- sed 's/$REPLACEME/{}/' "$tmpl" \ +| smail diff --git a/.local/bin/uni b/.local/bin/uni index 4be2d86..3ed7ec4 100755 --- a/.local/bin/uni +++ b/.local/bin/uni @@ -2,6 +2,9 @@ set -e +export NOTIFY_LONG=unicode +export NOTIFY_SHORT="${0##*/}" + setup() { curl 'https://www.unicode.org/Public/UNIDATA/UnicodeData.txt' \ @@ -23,5 +26,5 @@ rune="$( | xargs printf )" -wl-copy -n "$rune" && notify uni unicode 'Rune Copied' \ - "The rune ‘$rune’ was copied to the clipboard" +wl-copy -n "$rune" \ +&& notify 'Rune Copied' "The rune ‘$rune’ was copied to the clipboard" diff --git a/.local/bin/vlt b/.local/bin/vlt index 72ec397..14c3c1f 100755 --- a/.local/bin/vlt +++ b/.local/bin/vlt @@ -2,13 +2,16 @@ set -e +export NOTIFY_LONG=vault +export NOTIFY_SHORT="${0##*/}" + sanitize() { s="${1#"${1%%[![:space:]]*}"}" s="${s%"${s##*[![:space:]]}"}" if [ "${#s}" -eq 0 ] then - xnotify 'Invalid Input' 'Empty strings do not constitute valid input' + notify 'Invalid Input' 'Empty strings do not constitute valid input' exit 1 fi } @@ -29,11 +32,6 @@ xecho() printf '%s' "$@" } -xnotify() -{ - notify "${0##*/}" vault "$1" "$2" -} - prompt() { if [ -t 2 ] @@ -89,7 +87,7 @@ add() xecho "$data" \ | jq -e --arg c "$c" --arg n "$n" '.[$c] | has($n) | not' >/dev/null || { - xnotify 'Failed To Add Password' "The password ‘$n’ already exists" + notify 'Failed To Add Password' "The password ‘$n’ already exists" exit 1 } @@ -111,7 +109,7 @@ add() "period": ($p | tonumber) }}' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify '2FA Key Added' \ + [ ! -t 2 ] && notify '2FA Key Added' \ "The 2FA key ‘$n’ was added with the digit length ‘$d’ and period ‘$p’" else xprompt 'Password:' @@ -119,7 +117,7 @@ add() xecho "$data" \ | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify 'Password Added' \ + [ ! -t 2 ] && notify 'Password Added' \ "The password ‘$n’ was added to the category ‘$c’" fi } @@ -131,7 +129,7 @@ add_c() prompt 'Category to create:' xecho "$data" | jq -e --arg s "$s" 'has($s) | not' >/dev/null || { - xnotify 'Failed To Create Category' "The category ‘$s’ already exists" + notify 'Failed To Create Category' "The category ‘$s’ already exists" exit 1 } @@ -139,7 +137,7 @@ add_c() | jq --arg s "$s" '. + {($s): {}}' \ | enchive archive >"$VAULT" [ ! -t 2 ] && \ - xnotify 'Category Created' "The password category ‘$s’ was created" + notify 'Category Created' "The password category ‘$s’ was created" } get() @@ -163,13 +161,13 @@ get() ')" \ | wl-copy -no \ && [ ! -t 2 ] \ - && xnotify '2FA Code Copied To The Clipboard' \ + && notify '2FA Code Copied To The Clipboard' \ "The 2FA code for ‘$o’ was copied to the clipboard" else jq -r --arg c "$c" --arg o "$o" '.[$c] | .[$o]' \ | wl-copy -no \ && [ ! -t 2 ] \ - && xnotify 'Password Copied To The Clipboard' \ + && notify 'Password Copied To The Clipboard' \ "The password for ‘$o’ was copied to the clipboard" fi } @@ -199,7 +197,7 @@ rm_() xecho "$data" \ | jq --arg c "$c" --arg n "$n" 'del(.[$c] | .[$n])' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify 'Removed Password' \ + [ ! -t 2 ] && notify 'Removed Password' \ "The password ‘$n’ was removed from the category ‘$c’" } @@ -211,14 +209,14 @@ rm_c() xecho "$data" \ | jq -e --arg c "$c" '.[$c] | length == 0' >/dev/null || { - xnotify 'Failed To Remove Category' "The category ‘$c’ is not empty" + notify 'Failed To Remove Category' "The category ‘$c’ is not empty" exit 1 } xecho "$data" \ | jq --arg c "$c" 'del(.[$c])' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify 'Removed Category' "The category ‘$c’ was removed" + [ ! -t 2 ] && notify 'Removed Category' "The category ‘$c’ was removed" } edit() @@ -261,14 +259,14 @@ edit() "period": ($p | tonumber) }}' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify '2FA Key Added' \ + [ ! -t 2 ] && notify '2FA Key Added' \ "The 2FA key ‘$n’ was added with the digit length ‘$d’ and period ‘$p’" else xprompt 'Password:' xecho "$data" \ | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify 'Password Edit' \ + [ ! -t 2 ] && notify 'Password Edit' \ "The password ‘$n’ in the category ‘$c’ was changed" fi } @@ -283,7 +281,7 @@ edit_c() | jq --arg o "$c" --arg n "$s" \ 'with_entries(if .key == $o then .key = $n else . end)' \ | enchive archive >"$VAULT" - [ ! -t 2 ] && xnotify 'Category Edit' "The category ‘$c’ was renamed" + [ ! -t 2 ] && notify 'Category Edit' "The category ‘$c’ was renamed" } raw() diff --git a/.local/sbin/chtz b/.local/sbin/chtz index f6a6444..2a02e79 100755 --- a/.local/sbin/chtz +++ b/.local/sbin/chtz @@ -2,7 +2,9 @@ set -e -choice="`timedatectl list-timezones | grep './.' | osel`" \ - && sudo timedatectl set-timezone "$choice" \ - && notify "${0##*/}" timezone 'Timezone Changed' \ - "The system timezone was changed to ‘$choice’" +export NOTIFY_LONG=timezone +export NOTIFY_SHORT="${0##*/}" + +choice="$(timedatectl list-timezones | grep './.' | osel)" \ +&& sudo timedatectl set-timezone "$choice" \ +&& notify 'Timezone Changed' "The system timezone was changed to ‘$choice’" |