diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-01-10 09:53:47 +0100 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-01-10 09:53:47 +0100 |
commit | 0467fa38e57589f2bcd5cfeca5643f360800460e (patch) | |
tree | 30fe3d379312073177b9425b76b782947b11a9dc /bin | |
parent | c8283a1ef06b15ab0b5871655f4bfaefe9518673 (diff) |
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/common/gt | 18 | ||||
-rwxr-xr-x | bin/extra/cycleKB | 33 | ||||
-rwxr-xr-x | bin/extra/notify-send | 1 |
3 files changed, 41 insertions, 11 deletions
diff --git a/bin/common/gt b/bin/common/gt index 5adfe71..e048912 100755 --- a/bin/common/gt +++ b/bin/common/gt @@ -34,6 +34,13 @@ EOF } list_repos() { cut -f 1 -d ' ' "$REPOS"; } +quit_when_no_repos() { + if [ "$(wc -l <"$REPOS")" -eq 0 ]; + then + >&2 printf 'No repositories added.\n' + exit 1 + fi +} # fetch repository prettily, outputs nothing if failed fetch() { @@ -49,7 +56,6 @@ if [ -z "$1" ]; then exit 1 fi -[ "$(wc -l <"$REPOS")" -gt 0 ] || exit 0 while getopts ":a:c:f:lsheu" opt; do case "$opt" in @@ -73,6 +79,7 @@ while getopts ":a:c:f:lsheu" opt; do printf >&2 'added.\n' ;; c) + quit_when_no_repos list_repos | if [ "$parallel" ]; then parallel gt-cmd "{}" "$OPTARG" @@ -80,11 +87,16 @@ while getopts ":a:c:f:lsheu" opt; do xargs -I{} gt-cmd "{}" "$OPTARG" fi ;; - s) list_repos | xargs -I{} gt-st {} ;; - l) list_repos ;; + s) + quit_when_no_repos + list_repos | xargs -I{} gt-st {} ;; + l) + quit_when_no_repos + list_repos ;; e) $EDITOR "$REPOS" ;; f) REPOS="$OPTARG" ;; u) + quit_when_no_repos >&2 printf 'pull:\n' if [ "$parallel" ]; then list_repos | parallel gt-cmd {} pull diff --git a/bin/extra/cycleKB b/bin/extra/cycleKB index 597f26f..8f0de60 100755 --- a/bin/extra/cycleKB +++ b/bin/extra/cycleKB @@ -4,18 +4,35 @@ list_layouts() { cat <<EOF us -colemak -option ctrl:swapcaps,altwin:menu_win +us -variant colemak -option ctrl:swapcaps,altwin:menu_win EOF } -current_keymap() -{ - setxkbmap -print | awk -F '+' '/xkb_symbols/ {print $2}' -} +ProgramPath="$(readlink -f "$0")" +CurrentKeymap="$(tail -n 1 "$ProgramPath")" +>&2 printf 'Current: %s\n' "$CurrentKeymap" NumLayouts="$(list_layouts | wc -l)" -IndexLayout="$(list_layouts | awk "/^$(current_keymap)/ {print NR}")" -[ "$IndexLayout" -eq "$NumLayouts" ] && IndexLayout=1 || IndexLayout=$((IndexLayout + 1)) +[ "$NumLayouts" ] || exit 1 +IndexLayout="$(list_layouts | awk "/^${CurrentKeymap}$/ {print NR}")" +[ "$IndexLayout" ] || exit 2 + +# Cycle +if [ "$IndexLayout" -eq "$NumLayouts" ]; then + IndexLayout=1 +else + IndexLayout=$((IndexLayout + 1)) +fi + Layout="$(list_layouts | sed -n "${IndexLayout}p" )" +[ "$Layout" ] || exit 3 + +>&2 printf 'Layout: %s\n' "$Layout" setxkbmap $Layout & -herbe "_cycleKB" "*${Layout%% *}" +sed -i "\$s/.*/$Layout/" "$ProgramPath" +notify-send "_cycleKB" "*${Layout%% -option*}" & + +exit + +# THIS LINE IS ADDED AUTOMATICALLY +us -variant colemak -option ctrl:swapcaps,altwin:menu_win diff --git a/bin/extra/notify-send b/bin/extra/notify-send index b0cf04a..e058d79 100755 --- a/bin/extra/notify-send +++ b/bin/extra/notify-send @@ -83,4 +83,5 @@ parse() { parse "$@" eval set -- "$REST" +pkill herbe herbe "$@" & |