From f86cc46d037233887c325601cd2d833c8c9e3ebb Mon Sep 17 00:00:00 2001 From: Stacy Harper Date: Sun, 29 Aug 2021 20:39:46 +0200 Subject: [PATCH] Add a bemenu control mode to access bemenu control with buttons Signed-off-by: Stacy Harper Signed-off-by: Maarten van Gompel --- configs/appcfg/sway_template | 7 +++++++ configs/sway/xkb_mobile_movement_buttons | 22 ++++++++++++++++++++++ configs/sway/xkb_mobile_normal_buttons | 22 ++++++++++++++++++++++ scripts/core/sxmo_dmenu.sh | 6 +++++- scripts/core/sxmo_inputhandler.sh | 2 +- scripts/core/sxmo_menumode_toggler.sh | 20 ++++++++++++++++++++ 6 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 configs/sway/xkb_mobile_movement_buttons create mode 100644 configs/sway/xkb_mobile_normal_buttons create mode 100644 scripts/core/sxmo_menumode_toggler.sh diff --git a/configs/appcfg/sway_template b/configs/appcfg/sway_template index 87a3a65..e2e102e 100644 --- a/configs/appcfg/sway_template +++ b/configs/appcfg/sway_template @@ -61,11 +61,13 @@ exec sxmo_idle.sh start input 0:0:axp20x-pek { repeat_delay 200 repeat_rate 15 + xkb_file /usr/share/sxmo/sway/xkb_mobile_normal_buttons } # Volume buttons input 1:1:1c21800.lradc { repeat_delay 200 repeat_rate 15 + xkb_file /usr/share/sxmo/sway/xkb_mobile_normal_buttons } exec sxmo_multikey.sh clear @@ -84,6 +86,10 @@ exec sxmo_multikey.sh clear # Next workspace bindsym --input-device=1:1:1c21800.lradc XF86AudioLowerVolume exec sxmo_multikey.sh voldown "sxmo_inputhandler.sh voldown_one" "sxmo_inputhandler.sh voldown_two" "sxmo_inputhandler.sh voldown_three" + mode "menu" { + bindsym --input-device=1:1:1c21800.lradc XF86AudioMute exec nothing # placeholder for "menu" mode + } + # Kill focused window bindsym $mod+Shift+q kill @@ -252,3 +258,4 @@ exec sxmo_modemmonitortoggle.sh restart exec sxmo_notificationmonitor.sh exec mako exec sxmo_hooks.sh lisgdstart +exec sxmo_menumode_toggler.sh diff --git a/configs/sway/xkb_mobile_movement_buttons b/configs/sway/xkb_mobile_movement_buttons new file mode 100644 index 0000000..1cdc9a8 --- /dev/null +++ b/configs/sway/xkb_mobile_movement_buttons @@ -0,0 +1,22 @@ +xkb_keymap { +xkb_keycodes "(unnamed)" { + minimum = 122; + maximum = 124; + = 122; + = 123; + = 124; + alias = ; + alias = ; + alias = ; +}; +xkb_types "(unnamed)" { +}; +xkb_compatibility "(unnamed)" { +}; +xkb_symbols "(unnamed)" { + name[group1]="Mobile Convenient Buttons"; + key { [ Down ] }; + key { [ Up ] }; + key { [ Return ] }; +}; +}; diff --git a/configs/sway/xkb_mobile_normal_buttons b/configs/sway/xkb_mobile_normal_buttons new file mode 100644 index 0000000..6cf2ea9 --- /dev/null +++ b/configs/sway/xkb_mobile_normal_buttons @@ -0,0 +1,22 @@ +xkb_keymap { +xkb_keycodes "(unnamed)" { + minimum = 122; + maximum = 124; + = 122; + = 123; + = 124; + alias = ; + alias = ; + alias = ; +}; +xkb_types "(unnamed)" { +}; +xkb_compatibility "(unnamed)" { +}; +xkb_symbols "(unnamed)" { + name[group1]="Mobile Convenient Buttons"; + key { [ XF86AudioLowerVolume ] }; + key { [ XF86AudioRaiseVolume ] }; + key { [ XF86PowerOff ] }; +}; +}; diff --git a/scripts/core/sxmo_dmenu.sh b/scripts/core/sxmo_dmenu.sh index d6e23c4..60dab6d 100755 --- a/scripts/core/sxmo_dmenu.sh +++ b/scripts/core/sxmo_dmenu.sh @@ -28,7 +28,11 @@ esac > /dev/null case "$(sxmo_wm.sh)" in sway) - exec bemenu --scrollbar autohide -s -n -w -c -l "$(sxmo_rotate.sh isrotated > /dev/null && printf 8 || printf 15)" "$@" + swaymsg mode menu -q # disable default button inputs + bemenu --scrollbar autohide -s -n -w -c -l "$(sxmo_rotate.sh isrotated > /dev/null && printf 8 || printf 15)" "$@" + returned=$? + swaymsg mode default -q + exit "$returned" ;; xorg|dwm) if sxmo_keyboard.sh isopen; then diff --git a/scripts/core/sxmo_inputhandler.sh b/scripts/core/sxmo_inputhandler.sh index 78db426..16ce961 100755 --- a/scripts/core/sxmo_inputhandler.sh +++ b/scripts/core/sxmo_inputhandler.sh @@ -289,7 +289,7 @@ case "$ACTION" in exit 0 ;; "bottomleftcorner") - lock_screen + sxmo_dmenu.sh close && lock_screen exit 0 ;; "bottomrightcorner") diff --git a/scripts/core/sxmo_menumode_toggler.sh b/scripts/core/sxmo_menumode_toggler.sh new file mode 100644 index 0000000..487d664 --- /dev/null +++ b/scripts/core/sxmo_menumode_toggler.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +inputs=" + 1:1:1c21800.lradc + 0:0:axp20x-pek +" + +setup_xkb() { + for input in $inputs; do + swaymsg input "$input" xkb_file "$1" + done +} + +swaymsg -t subscribe -m "['mode']" | while read -r message; do + if printf %s "$message" | grep -q menu; then + setup_xkb /usr/share/sxmo/sway/xkb_mobile_movement_buttons + else + setup_xkb /usr/share/sxmo/sway/xkb_mobile_normal_buttons + fi +done