简体   繁体   中英

How to show and hide the on-screen keyboard "onboard" in mate-screensaver?

I'm trying to add a mate-screensaver, so that there would be a switch on and off the on-screen keyboard (onboard) right on the window. All the functionality is ready, I use 2 settings of the org.mate.screensaver schemas:

  • embedded-keyboard-enabled

  • embedded-keyboard-command "onboard --xid"

When switching the switch, I change the value of embedded-keyboard-enabled to true or false, respectively, but the keyboard appears or disappears only after restarting the mate-sreensaver window. As I understand it, the keyboard is created by an asynchronous process, but how do I hide or show it when I need it?

Of the functions, I use g_settings_set_boolean() to set the key parameter and g_settings_apply() to apply the changes.

I wrote a little script that I load at login which toggles hide and show using my middle mouse button. This works very when I want to hide/show it quickly.

You could copy and past the below script, give it execution permission, and run it at startup. (You may need to install xprintidle.)

Copy and paste below text in your favourite text editor.

#!/usr/bin/bash

if [[ "$(pidof -x $(basename $0))" != $$ ]] ; then exit;fi

rest=0

sleep 35;# (i need to wait 30-35 seconds at login for the physical mouse id to be assigned instead of the virtual mouse. It might go quicker for you.)

MOUSE=$(xinput --list --long | grep XIButtonClass | head -n 1 | egrep -o '[0-9]+');

toggle() { dbus-send --type=method_call --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.ToggleVisible;
}

while :;do
idle3=$(xprintidle)
STATE=$(xinput --query-state $MOUSE);
if [[ $STATE == *"button[2]=down"* ]];then toggle;sleep .5;elif [ $idle3 -gt 3000 ] && [ $rest = '.14' ];then rest=3;else rest=.14;fi;
sleep $rest;
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM