【问题标题】:How to show and hide the on-screen keyboard "onboard" in mate-screensaver?如何在 mate-screensaver 中显示和隐藏“板载”屏幕键盘?
【发布时间】:2021-11-22 08:22:36
【问题描述】:
我正在尝试添加一个配对屏幕保护程序,以便在窗口上打开和关闭屏幕键盘(板载)。所有功能都准备好了,我使用了 org.mate.screensaver 模式的 2 个设置:
-
支持嵌入式键盘
-
嵌入式键盘命令“onboard --xid”
切换开关时,我将embedded-keyboard-enabled 的值分别更改为true 或false,但键盘只有在重新启动mate-sreensaver 窗口后才会出现或消失。据我了解,键盘是由异步进程创建的,但是我需要时如何隐藏或显示呢?
在这些函数中,我使用 g_settings_set_boolean() 来设置关键参数,并使用 g_settings_apply() 来应用更改。
【问题讨论】:
标签:
c
linux
gtk
screensaver
mate
【解决方案1】:
我编写了一个在登录时加载的小脚本,它使用鼠标中键切换隐藏和显示。当我想快速隐藏/显示它时,这非常有效。
您可以复制并粘贴以下脚本,授予它执行权限,然后在启动时运行它。 (您可能需要安装 xprintidle。)
在您喜欢的文本编辑器中复制并粘贴以下文本。
#!/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