diff --git a/scripts/appscripts/sxmo_reddit.sh b/scripts/appscripts/sxmo_reddit.sh index bef3f6e..7d50f53 100755 --- a/scripts/appscripts/sxmo_reddit.sh +++ b/scripts/appscripts/sxmo_reddit.sh @@ -7,12 +7,12 @@ [ -z "$SXMO_SUBREDDITS" ] && SXMO_SUBREDDITS="pine64official pinephoneofficial unixporn postmarketos linux" menu() { - pidof "$KEYBOARD" || "$KEYBOARD" & + sxmo_keyboard.sh open SUBREDDIT="$( printf %b "Close Menu\n$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" | dmenu -p "Subreddit:" -c -l 10 )" - pkill "$KEYBOARD" + sxmo_keyboard.sh close [ "Close Menu" = "$SUBREDDIT" ] && exit 0 REDDITRESULTS="$( diff --git a/scripts/appscripts/sxmo_timer.sh b/scripts/appscripts/sxmo_timer.sh index 4493049..50ddf2b 100755 --- a/scripts/appscripts/sxmo_timer.sh +++ b/scripts/appscripts/sxmo_timer.sh @@ -29,7 +29,7 @@ timerrun() { } menu() { - pidof "$KEYBOARD" || "$KEYBOARD" & + sxmo_keyboard.sh open TIMEINPUT="$( echo " 1h @@ -47,7 +47,7 @@ menu() { Close Menu " | awk 'NF' | awk '{$1=$1};1' | dmenu -p Timer -c -l 20 )" - pkill "$KEYBOARD" + sxmo_keyboard.sh close [ "Close Menu" = "$TIMEINPUT" ] && exit 0 st -f Monospace-50 -e "$0" timerrun "$TIMEINPUT" } diff --git a/scripts/appscripts/sxmo_websearch.sh b/scripts/appscripts/sxmo_websearch.sh index 02609fe..fff584a 100755 --- a/scripts/appscripts/sxmo_websearch.sh +++ b/scripts/appscripts/sxmo_websearch.sh @@ -4,11 +4,11 @@ # shellcheck source=scripts/core/sxmo_common.sh . "$(dirname "$0")/sxmo_common.sh" -pidof "$KEYBOARD" || "$KEYBOARD" & +sxmo_keyboard.sh open SEARCHQUERY="$( echo "Close Menu" | dmenu -t -p "Search:" -c -l 20 )" -pkill "$KEYBOARD" +sxmo_keyboard.sh close [ "Close Menu" = "$SEARCHQUERY" ] && exit 0 echo "$SEARCHQUERY" | grep . || exit 0 diff --git a/scripts/core/sxmo_dmenu_with_kb.sh b/scripts/core/sxmo_dmenu_with_kb.sh index 0022009..f59c857 100755 --- a/scripts/core/sxmo_dmenu_with_kb.sh +++ b/scripts/core/sxmo_dmenu_with_kb.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -pidof "$KEYBOARD" >&2 || "$KEYBOARD" & +sxmo_keyboard.sh open OUTPUT="$(cat | dmenu "$@")" -pkill "$KEYBOARD" >&2 +sxmo_keyboard.sh close echo "$OUTPUT" diff --git a/scripts/core/sxmo_gesturehandler.sh b/scripts/core/sxmo_gesturehandler.sh index 36d6de8..19784ab 100755 --- a/scripts/core/sxmo_gesturehandler.sh +++ b/scripts/core/sxmo_gesturehandler.sh @@ -75,10 +75,10 @@ if [ "$HANDLE" -ne 0 ]; then sxmo_vol.sh down & ;; "showkeyboard") - pidof "$KEYBOARD" || "$KEYBOARD" & + sxmo_keyboard.sh open ;; "hidekeyboard") - pkill -9 "$KEYBOARD" + sxmo_keyboard.sh close ;; "showmenu") pidof dmenu || setsid -f sxmo_appmenu.sh & diff --git a/scripts/core/sxmo_keyboard.sh b/scripts/core/sxmo_keyboard.sh new file mode 100755 index 0000000..55637a3 --- /dev/null +++ b/scripts/core/sxmo_keyboard.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +# shellcheck disable=SC2034 +SXMO_NO_ICONS=1 #just to make it a bit faster +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. "$(dirname "$0")/sxmo_common.sh" + +open() { + #Note: KEYBOARD_ARGS is not quoted by design as it may includes a pipe and further tools + # shellcheck disable=SC2086 + pidof -q "$KEYBOARD" || "$KEYBOARD" $KEYBOARD_ARGS & +} + +close() { + pkill "$KEYBOARD" +} + +if [ "$1" = "close" ]; then + close +else + open +fi diff --git a/scripts/core/sxmo_pipecomplete.sh b/scripts/core/sxmo_pipecomplete.sh index 06562be..2791829 100755 --- a/scripts/core/sxmo_pipecomplete.sh +++ b/scripts/core/sxmo_pipecomplete.sh @@ -3,14 +3,14 @@ INPUT="$(cat)" STWIN="$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')" menu() { - pidof "$KEYBOARD" || "$KEYBOARD" & + sxmo_keyboard.sh open RESULT="$( printf %b "$( echo "Close Menu"; echo "$INPUT" | grep -Eo '\S+' | tr -d '[:blank:]' | sort | uniq )" | dmenu -p "$PROMPT" -l 10 -i -c )" - pkill "$KEYBOARD" + sxmo_keyboard.sh close } copy() { diff --git a/scripts/core/sxmo_rotate.sh b/scripts/core/sxmo_rotate.sh index 404190c..0d596fd 100755 --- a/scripts/core/sxmo_rotate.sh +++ b/scripts/core/sxmo_rotate.sh @@ -18,7 +18,7 @@ isrotated() { } rotnormal() { - pkill "$KEYBOARD" + sxmo_keyboard.sh close xrandr -o normal applyptrmatrix 0 0 0 0 0 0 0 0 0 pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 0 & @@ -26,7 +26,7 @@ rotnormal() { } rotright() { - pkill "$KEYBOARD" + sxmo_keyboard.sh close xrandr -o right applyptrmatrix 0 1 0 -1 0 1 0 0 1 pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 1 & @@ -34,7 +34,7 @@ rotright() { } rotleft() { - pkill "$KEYBOARD" + sxmo_keyboard.sh close xrandr -o left applyptrmatrix 0 -1 1 1 0 0 0 0 1 pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o -1 & diff --git a/scripts/core/sxmo_surf_linkselect.sh b/scripts/core/sxmo_surf_linkselect.sh index 32d2b94..77e5523 100755 --- a/scripts/core/sxmo_surf_linkselect.sh +++ b/scripts/core/sxmo_surf_linkselect.sh @@ -73,7 +73,7 @@ link_select() { link_normalize "$(xprop -id "$SURF_WINDOW" _SURF_URI | cut -d '"' -f 2)" } -pidof "$KEYBOARD" || "$KEYBOARD" & +sxmo_keyboard.sh open VAL="$(link_select)" -pkill "$KEYBOARD" +sxmo_keyboard.sh close echo "$VAL" diff --git a/scripts/core/sxmo_xinit.sh b/scripts/core/sxmo_xinit.sh index 4813e69..561dd3e 100755 --- a/scripts/core/sxmo_xinit.sh +++ b/scripts/core/sxmo_xinit.sh @@ -45,10 +45,14 @@ xdefaults() { defaultkeyboard() { if command -v svkbd-mobile-intl; then export KEYBOARD=svkbd-mobile-intl + export KEYBOARD_ARGS= elif command -v svkbd-mobile-plain; then export KEYBOARD=svkbd-mobile-plain + export KEYBOARD_ARGS= else + #legacy export KEYBOARD=svkbd-sxmo + export KEYBOARD_ARGS= fi }