Some pkill implementations match on /proc/pid/stat which is limited to 15 characters [1]. $KEYBOARD defaults to svkbd-mobile-intl which is more then 15 characters, so use -f to match the full string. Note that sxmo uses busybox pkill by default which does not have this limit. [1] https://manpages.debian.org/buster/procps/pgrep.1.en.html (Notes) Signed-off-by: Anjandev Momi <anjan@momi.ca>
31 lines
606 B
Bash
Executable file
31 lines
606 B
Bash
Executable file
#!/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"
|
|
|
|
isopen() {
|
|
pidof "$KEYBOARD" > /dev/null
|
|
}
|
|
|
|
open() {
|
|
#Note: KEYBOARD_ARGS is not quoted by design as it may includes a pipe and further tools
|
|
# shellcheck disable=SC2086
|
|
isopen || eval "$KEYBOARD" $KEYBOARD_ARGS &
|
|
}
|
|
|
|
close() {
|
|
pkill -f "$KEYBOARD"
|
|
}
|
|
|
|
if [ "$1" = "toggle" ]; then
|
|
close || open
|
|
elif [ "$1" = "close" ]; then
|
|
close
|
|
elif [ "$1" = "isopen" ]; then
|
|
isopen || exit 1
|
|
else
|
|
open
|
|
fi
|