简体   繁体   English

如何在 mate-screensaver 中显示和隐藏屏幕键盘“onboard”?

[英]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:所有功能都已准备就绪,我使用 org.mate.screensaver 架构的 2 个设置:

  • embedded-keyboard-enabled嵌入式键盘启用

  • embedded-keyboard-command "onboard --xid"嵌入式键盘命令“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.切换开关的时候,我把embedded-keyboard-enabled的值分别改成true或者false,但是只有重启mate-sreensaver窗口后键盘才会出现或者消失。 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.在这些函数中,我使用 g_settings_set_boolean() 来设置关键参数并使用 g_settings_apply() 来应用更改。

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.) (您可能需要安装 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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