unmaintained project intending to allow you to use wvkbd on phosh
dbus_request_name: Request the dbus name so the keyboard button will be active in phosh
Zach DeCook 2023-05-24
parent af9302c · commit c5983b0
-rw-r--r--Makefile6
-rw-r--r--README.md10
-rw-r--r--dbus_request_name.c12
-rwxr-xr-xosk0-wvkbd-wrapper.sh4
4 files changed, 31 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 8945ff3..85aa6c1 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..11728d4
--- /dev/null
+++ b/README.md
@@ -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
+```
diff --git a/dbus_request_name.c b/dbus_request_name.c
new file mode 100644
index 0000000..f517093
--- /dev/null
+++ b/dbus_request_name.c
@@ -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;
+}
diff --git a/osk0-wvkbd-wrapper.sh b/osk0-wvkbd-wrapper.sh
index d66094b..ccca980 100755
--- a/osk0-wvkbd-wrapper.sh
+++ b/osk0-wvkbd-wrapper.sh
@@ -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