unmaintained project intending to allow you to use wvkbd on phosh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Copyright 2023 Zach DeCook

KEYBOARD=wvkbd-mobintl

isopen() {
	if [ -z "$KEYBOARD" ]; then
		exit 0 # ssh/tty usage by example
	fi
	pidof "$KEYBOARD" > /dev/null
}

open() {
	if [ -n "$KEYBOARD" ]; then
		#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 &
	fi
}

close() {
	if [ -n "$KEYBOARD" ]; then # avoid killing everything !
		pkill "$KEYBOARD"
	fi
}


dbus_request_name 'sm.puri.OSK0' &
pid="$(echo $!)"
stdbuf -oL dbus-monitor "interface='sm.puri.OSK0',member='SetVisible'" |
	while read -r line; do
		echo "$line" | grep -i "boolean.*true" && open
		echo "$line" | grep -i "boolean.*false" && close
	done

kill "$pid"

exit 0