~earboxer/osk0-wvkbd-wrapper

c5983b06a787f7c0c42c718336574dca030bc312 — Zach DeCook 6 months ago af9302c
dbus_request_name: Request the dbus name so the keyboard button will be active in phosh
4 files changed, 31 insertions(+), 1 deletions(-)

M Makefile
A README.md
A dbus_request_name.c
M osk0-wvkbd-wrapper.sh
M Makefile => Makefile +5 -1
@@ 1,7 1,11 @@
install:
install: dbus_request_name
	cp dbus_request_name /usr/bin/
	cp osk0-wvkbd-wrapper.sh /usr/bin/
	cp osk0-wvkbd-wrapper.desktop /usr/share/applications/

link:
	test -L /etc/alternatives/Phosh-OSK && ln -fs /usr/share/applications/osk0-wvkbd-wrapper.desktop /etc/alternatives/Phosh-OSK
	test /etc/alternatives/Phosh-OSK -ef /usr/share/applications/sm.puri.OSK0.desktop || ln -fs /usr/share/applications/osk0-wvkbd-wrapper.desktop /usr/share/applications/sm.puri.OSK0.desktop

dbus_request_name: dbus_request_name.c
	gcc dbus_request_name.c `pkg-config --cflags --libs dbus-1` -o dbus_request_name

A README.md => README.md +10 -0
@@ 0,0 1,10 @@
# osk0-wvkbd-wrapper

Helper so you can use wvkbd on phosh.

## Debugging

```sh
# Find out if the bus has been claimed
dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:sm.puri.OSK0
```

A dbus_request_name.c => dbus_request_name.c +12 -0
@@ 0,0 1,12 @@
#include <dbus/dbus.h>

int main(int argc, char ** argv) {

	if (argc != 2) return 1;

	DBusError error = DBUS_ERROR_INIT;
	DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
	int number = dbus_bus_request_name(conn, argv[1], 0, &error);
	for(;;){}
	return 0;
}

M osk0-wvkbd-wrapper.sh => osk0-wvkbd-wrapper.sh +4 -0
@@ 27,10 27,14 @@ close() {
}


dbus_request_name 'sm.puri.OSK0' &
pid="$(echo $!)"
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