Skip to content

Instantly share code, notes, and snippets.

@luluco250
Last active February 2, 2023 21:52
Show Gist options
  • Save luluco250/5b8f06c2191f6de0ac3738e1b0311611 to your computer and use it in GitHub Desktop.
Save luluco250/5b8f06c2191f6de0ac3738e1b0311611 to your computer and use it in GitHub Desktop.
Bash script that forcibly shows or hides the virtual keyboard in KDE/KWin, useful for mobile devices. Works with Maliit.
#!/bin/bash
call_dbus() {
dbus-send \
--print-reply=literal \
--session \
--dest=org.kde.KWin \
/VirtualKeyboard \
"$@"
}
active=$(call_dbus \
org.freedesktop.DBus.Properties.Get \
string:org.kde.kwin.VirtualKeyboard \
string:active | awk '{ print $3 }' \
)
case "$active" in
true)
call_dbus \
org.freedesktop.DBus.Properties.Set \
string:org.kde.kwin.VirtualKeyboard \
string:active \
variant:boolean:false
;;
false)
call_dbus \
org.kde.kwin.VirtualDesktop.willShowOnActive
boolean:true
call_dbus \
org.kde.kwin.VirtualKeyboard.forceActivate
;;
*) exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment