proof of concept for stevia (phosh-osk-stub) auto-changing shortcuts application-specifically
improvements to --watch
| -rwxr-xr-x | pos-dyntercomms.sh | 126 |
1 files changed, 49 insertions, 77 deletions
diff --git a/pos-dyntercomms.sh b/pos-dyntercomms.sh index 187912f..22e4a43 100755 --- a/pos-dyntercomms.sh +++ b/pos-dyntercomms.sh @@ -13,7 +13,7 @@ if ! test "$activewmclass"; then activetitle="$(printf "%s" "$json" | jq -r .title)" fi WMNAME="$activewmclass $activetitle" -echo $WMNAME +echo "$WMNAME" case "$activewmclass" in *mpv*) @@ -137,9 +137,8 @@ case "$activewmclass" in ;; *micro*) #Micro - c="'Prior','Next','<alt>Comma','<alt>Period','<ctrl>s','<ctrl>q','<ctrl>f','<ctrl>p','<ctrl>n','<ctrl>e','<ctrl>c','<ctrl>v'" + c="'Prior','Next','<alt>Comma','<alt>Period','<ctrl>s','<ctrl>q','<ctrl>f','<ctrl>p','<ctrl>n','<ctrl>e','<ctrl>c','<ctrl>v','<ctrl>z','<ctrl>y'" CHOICES=" - $icon_prv Previous Tab ^ 1 ^ sxmo_type -M Alt , -m Alt $icon_nxt Next Tab ^ 1 ^ sxmo_type -M Alt . -m Alt $icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS @@ -201,28 +200,15 @@ case "$activewmclass" in ;; *aerc*) #aerc - c="'<shift>a','<ctrl>n'" - CHOICES=" - $icon_pau Archive ^ 1 ^ sxmo_type ':archive flat' -k Return - $icon_nxt Next Tab ^ 0 ^ sxmo_type ':next-tab' -k Return - $icon_prv Previous Tab ^ 0 ^ sxmo_type ':prev-tab' -k Return - $icon_cls Close Tab ^ 0 ^ sxmo_type ':close' -k Return - $icon_itm Next Part ^ 1 ^ sxmo_type ':next-part' -k Return - $icon_trm xdg-open Part ^ 0 ^ sxmo_type ':open' -k Return - " + c="'Up','Down','<shift>a','<ctrl>p','<ctrl>n','<ctrl>j','<ctrl>k','<shift>o'" WINNAME=aerc ;; *less*|*"git blame"*|*"git diff"*|*"git grep"*|*"git help"*|*"git log"*|*"git stash"*|*"git tag"*|*"git var"*) #less + c="'q','Prior','Next'" CHOICES=" - $icon_arr Page next ^ 1 ^ sxmo_type ':n' -k Return - $icon_arl Page previous ^ 1 ^ sxmo_type ':p' -k Return - $icon_cls Quit ^ 0 ^ sxmo_type q $icon_zmi Zoom in ^ 1 ^ sxmo_type -M Ctrl + $icon_zmo Zoom out ^ 1 ^ sxmo_type -M Ctrl -k Minus - $icon_aru Scroll up ^ 1 ^ sxmo_type -k Prior - $icon_ard Scroll down ^ 1 ^ sxmo_type -k Next - $icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS " WINNAME=less ;; @@ -236,14 +222,7 @@ case "$activewmclass" in WINNAME=git ;; *senpai*) - CHOICES=" - $icon_aru Scroll up ^ 1 ^ sxmo_type -k Prior - $icon_ard Scroll down ^ 1 ^ sxmo_type -k Next - $icon_ac1 Previous Buffer ^ 1 ^ sxmo_type -M Alt -k Left - $icon_ac4 Next Buffer ^ 1 ^ sxmo_type -M Alt -k Right - $icon_lst Toggle Channels ^ 0 ^ sxmo_type -k F7 - $icon_usr Toggle Members ^ 0 ^ sxmo_type -k F8 - " + c="'Prior','Next','<alt>Left','<alt>Right','F7','F8','<ctrl>c'" WINNAME=senpai ;; *weechat*) @@ -296,7 +275,7 @@ case "$activewmclass" in ;; *) # Now we fallback to the default terminal menu - case "$WMCLASS" in + case "$activewmclass" in *st*) STSELMODEON="$( printf %s "$XPROPOUT" | grep -E '^_ST_SELMODE.+=' | cut -d= -f2 | tr -d ' ' @@ -313,11 +292,11 @@ case "$activewmclass" in $([ "$STSELMODEON" = 1 ] && echo 'Copy selection ^ 0 ^ sxmo_type -M Ctrl -M Shift -k c') $icon_pst Paste ^ 0 ^ sxmo_type -M Ctrl -M Shift -k v $icon_zmi Zoom in ^ 1 ^ sxmo_type -M Ctrl -M Shift -k Prior - $icon_zmo Zoom out ^ 1 ^ sxmo_type -M Ctrl -M Shift -k Next - $icon_aru Scroll up ^ 1 ^ sxmo_type -M Ctrl -M Shift -k b - $icon_ard Scroll down ^ 1 ^ sxmo_type -M Ctrl -M Shift -k f - $icon_a2x Invert ^ 1 ^ sxmo_type -M Ctrl -M Shift -k x - $icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys + icon_zmo Zoom out ^ 1 ^ sxmo_type -M Ctrl -M Shift -k Next + icon_aru Scroll up ^ 1 ^ sxmo_type -M Ctrl -M Shift -k b + icon_ard Scroll down ^ 1 ^ sxmo_type -M Ctrl -M Shift -k f + icon_a2x Invert ^ 1 ^ sxmo_type -M Ctrl -M Shift -k x + icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys " WINNAME=St ;; @@ -339,19 +318,19 @@ case "$activewmclass" in WINNAME=Foot ;; *terminal*|org.gnome.vte.application|Terminal) - CHOICES="$icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys" + c="'Left','Down','Up','Right','<ctrl>c','<ctrl>z','<ctrl>l','<ctrl>d','<ctrl>a','<ctrl>b'" WINNAME=Terminal ;; *alacritty*) CHOICES=" $icon_cpy Copy ^ 0 ^ sxmo_type -M Shift -M Ctrl c $icon_pst Paste ^ 0 ^ sxmo_type -M Shift -M Ctrl v - $icon_vim VI Mode ^ 0 ^ sxmo_type -M Ctrl -M Shift -k Space - $icon_fnd Search Forward ^ 0 ^ sxmo_type -M Ctrl -M Shift -k f - $icon_fnd Search Backward ^ 0 ^ sxmo_type -M Ctrl -M Shift -k b - $icon_aru Search Previous ^ 0 ^ sxmo_type -k Enter - $icon_ard Search Next ^ 0 ^ sxmo_type -M Shift -k Enter - $icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys + icon_vim VI Mode ^ 0 ^ sxmo_type -M Ctrl -M Shift -k Space + icon_fnd Search Forward ^ 0 ^ sxmo_type -M Ctrl -M Shift -k f + icon_fnd Search Backward ^ 0 ^ sxmo_type -M Ctrl -M Shift -k b + icon_aru Search Previous ^ 0 ^ sxmo_type -k Enter + icon_ard Search Next ^ 0 ^ sxmo_type -M Shift -k Enter + icon_kbd Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys " WINNAME=Alacritty ;; @@ -361,15 +340,14 @@ case "$activewmclass" in *okular*) # Okular CHOICES=" - $icon_cfg Touch $( + icon_cfg Touch $( sxmo_wm.sh inputevent touchscreen | grep -q on && \ printf %b "$icon_ton ^ 0 ^ sxmo_wm.sh inputevent touchscreen off" || \ printf %b "$icon_tof ^ 0 ^ sxmo_wm.sh inputevent touchscreen on" ) - $icon_cfg Fullscreen ^ 0 ^ sxmo_type -k Ctrl -k Shift -k F - $icon_cfg Menubar ^ 0 ^ sxmo_type -k Ctrl -k M - $icon_cfg Toolbars ^ 0 ^ sxmo_type -k F7 - $icon_cfg SXMO Bar ^ 0 ^ sxmo_wm.sh togglebar + icon_cfg Fullscreen ^ 0 ^ sxmo_type -k Ctrl -k Shift -k F + icon_cfg Menubar ^ 0 ^ sxmo_type -k Ctrl -k M + icon_cfg Toolbars ^ 0 ^ sxmo_type -k F7 " WINNAME=Xournal ;; @@ -381,7 +359,7 @@ case "$activewmclass" in printf %b "$icon_ton ^ 0 ^ sxmo_wm.sh inputevent touchscreen off" || \ printf %b "$icon_tof ^ 0 ^ sxmo_wm.sh inputevent touchscreen on" ) - $icon_flt Open ^ 0 ^ sxmo_type -k Ctrl -k o + icon_flt Open ^ 0 ^ sxmo_type -k Ctrl -k o $icon_zmi Zoom ^ 1 ^ sxmo_type -k Ctrl -k plus $icon_zmo Zoom ^ 1 ^ sxmo_type -k Ctrl -k minus $icon_zmi Next Page ^ 1 ^ sxmo_type -k Next @@ -474,17 +452,17 @@ case "$activewmclass" in *krita*) # Krita CHOICES=" - $icon_fnd Open ^ 0 ^ sxmo_type -M Ctrl o - $icon_sav Save ^ 0 ^ sxmo_type -M Ctrl s - $icon_pst Paste ^ 0 ^ sxmo_type -M Ctrl v - $icon_del Delete ^ 0 ^ sxmo_type -k Delete - $icon_win Select ^ 0 ^ sxmo_type -M Ctrl r - $icon_modem_disabled Deselect ^ 0 ^ sxmo_type -M Ctrl -M Shift a - $icon_wn2 Crop ^ 0 ^ sxmo_type c - $icon_flt Fill ^ 0 ^ sxmo_type f - $icon_modem_connected Gradient ^ 0 ^ sxmo_type g - $icon_dof HSV Adjust ^ 0 ^ sxmo_type -M Ctrl u - $icon_cls Close Image ^ 0 ^ sxmo_type -M Ctrl w + icon_fnd Open ^ 0 ^ sxmo_type -M Ctrl o + icon_sav Save ^ 0 ^ sxmo_type -M Ctrl s + icon_pst Paste ^ 0 ^ sxmo_type -M Ctrl v + icon_del Delete ^ 0 ^ sxmo_type -k Delete + icon_win Select ^ 0 ^ sxmo_type -M Ctrl r + icon_modem_disabled Deselect ^ 0 ^ sxmo_type -M Ctrl -M Shift a + icon_wn2 Crop ^ 0 ^ sxmo_type c + icon_flt Fill ^ 0 ^ sxmo_type f + icon_modem_connected Gradient ^ 0 ^ sxmo_type g + icon_dof HSV Adjust ^ 0 ^ sxmo_type -M Ctrl u + icon_cls Close Image ^ 0 ^ sxmo_type -M Ctrl w " WINNAME=Krita ;; @@ -503,10 +481,10 @@ case "$activewmclass" in # Geopard CHOICES=" $icon_flt Pipe URL ^ 0 ^ sxmo_urlhandler.sh - $icon_pls New Tab ^ 0 ^ sxmo_type -M Ctrl t - $icon_cls Close Tab ^ 0 ^ sxmo_type -M Ctrl w - $icon_bok Open Bookmarks ^ 0 ^ sxmo_type -M Ctrl b - $icon_pls Add Bookmark ^ 0 ^ sxmo_type -M Ctrl d + icon_pls New Tab ^ 0 ^ sxmo_type -M Ctrl t + icon_cls Close Tab ^ 0 ^ sxmo_type -M Ctrl w + icon_bok Open Bookmarks ^ 0 ^ sxmo_type -M Ctrl b + icon_pls Add Bookmark ^ 0 ^ sxmo_type -M Ctrl d $icon_edt Edit Bookmarks ^ 0 ^ sxmo_terminal.sh $EDITOR ~/.local/share/geopard/bookmarks.gemini $icon_zmi Increase Font Size ^ 1 ^ sxmo_type -M Ctrl -k plus $icon_zmo Decrease Font Size ^ 1 ^ sxmo_type -M Ctrl -k minus @@ -532,17 +510,8 @@ case "$activewmclass" in " WINNAME=Lagrange ;; - org.gnome.maps) - CHOICES=" - $icon_gps Toggle Geoclue ^ 0 ^ superctl status geoclue-agent |grep started >/dev/null && superctl stop geoclue-agent || superctl start geoclue-agent - $icon_zmi Zoom in ^ 1 ^ sxmo_type -M ctrl = - $icon_zmo Zoom out ^ 1 ^ sxmo_type -M ctrl -k minus - $icon_fnd Explore POI ^ 0 ^ sxmo_type -M ctrl -M Shift F - $icon_fnd Search ^ 0 ^ sxmo_type -M ctrl f - $icon_lst Show last results ^ 0 ^ sxmo_type -M ctrl r - $icon_map Toggle route planner ^ 0 ^ sxmo_type -M ctrl d - $icon_gps Show current location ^ 0 ^ sxmo_type -M ctrl l - " + org.gnome.Maps) + c="'<ctrl>equal','<ctrl>minus','<ctrl><shift>F','<ctrl>f','<ctrl>r','<ctrl>d','<ctrl>l'" WINNAME=Maps ;; *mepo*) @@ -585,11 +554,11 @@ case "$activewmclass" in *acme*) # Acme CHOICES=" - $icon_mse 2 (Right) [2s delay] ^ 0 ^ sleep 2 && xdotool click 3 - $icon_mse 3 (Middle) [2s delay] ^ 0 ^ sleep 2 && xdotool click 2 + icon_mse 2 (Right) [2s delay] ^ 0 ^ sleep 2 && xdotool click 3 + icon_mse 3 (Middle) [2s delay] ^ 0 ^ sleep 2 && xdotool click 2 $icon_itm Autocomplete ^ 0 ^ sxmo_type.sh -M Ctrl -k f $icon_exp Select Last Typed Text ^ 0 ^ sxmo_type.sh -M Escape - $icon_del Delete To Start Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k U + icon_del Delete To Start Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k U $icon_arl Move To Start Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k A $icon_arr Move To End Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k E " @@ -600,7 +569,7 @@ case "$activewmclass" in CHOICES=" $icon_nxt Next Page ^ 0 ^ sxmo_type -k Space $icon_prv Previous Page ^ 0 ^ sxmo_type -k b - $icon_chk Mark Page ^ 0 ^ sxmo_type -k m + icon_chk Mark Page ^ 0 ^ sxmo_type -k m $icon_ret Pop To Last Mark ^ 0 ^ sxmo_type -k t $icon_zmi Zoom In ^ 1 ^ sxmo_type -k + $icon_zmo Zoom Out ^ 1 ^ sxmo_type -k - @@ -630,7 +599,7 @@ case "$activewmclass" in esac if ! test "$c"; then -printf "%b\n" "$WINNAME" +test "$WINNAME" && printf "%b\n" "$WINNAME" c="$(printf "%b\n" "$CHOICES" |grep sxmo_type|sed "s/sxmo_type[^ ]* \(\S\)$/'\1'/g"| sed "s/sxmo_type[^ ]* -k \(\S\+\)$/'\1'/g"| sed "s/sxmo_type[^ ]* -M Ctrl \(\S\)$/'<ctrl>\1'/ig"| @@ -652,7 +621,7 @@ sed "s/sxmo_type[^ ]* -M Alt -k \(\S\+\)$/'<alt>\1'/g"| sed "s/sxmo_type[^ ]* -M Alt \(\S\) -m Alt$/'<alt>\1'/g"| sed "s/sxmo_type[^ ]* -M Alt -k \(\S\+\) -m Alt$/'<alt>\1'/g" |grep -v sxmo_type | grep -o "'[^']\+'$"|tr "\n" ,|sed 's/,$//g')" fi -echo "$c" +test "$c" && printf %s"\n" "$c" test "$c" && gsettings set sm.puri.phosh.osk.Terminal shortcuts "[$c]" @@ -661,6 +630,9 @@ gsettings set sm.puri.phosh.osk.Terminal shortcuts "[$c]" if test "$1" = "--watch"; then socat -U - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" |stdbuf -o0 grep 'activewindow>>' | while read -r line; do + c="" + CHOICES="" + WINNAME="" win="$(printf %s "$line" |cut -d '>' -f3 |cut -d , -f1)" tit=$(printf %s "$line" |cut -d , -f2) setComms "$win" "$tit" |