我编写了一个在登录时加载的小脚本,它使用鼠标中键切换隐藏和显示。当我想快速隐藏/显示它时,这非常有效。
您可以复制并粘贴以下脚本,授予它执行权限,然后在启动时运行它。(您可能需要安装 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