ich*_*len 10 mouse screen-lock xdotool
我想编写一个脚本,通过虚拟摆动鼠标来防止计算机锁定。但是,我xdotool
在使用的计算机上没有安装,因为我不是 root,所以无法安装。有没有办法在不使用的情况下移动光标xdotool
?
jim*_*mij 11
根据此答案,您可以通过以下步骤使用命令行移动鼠标指针:
首先你需要找到鼠标输入设备
grep mouse /proc/bus/input/devices | grep event
Run Code Online (Sandbox Code Playgroud)
H: Handlers=mouse0 event7
在我的情况下,您应该会看到类似的内容。如果您有不止一个鼠标(例如触摸板),它可以输出不止一行。重要的部分是event7
,这意味着你会写信给/dev/input/event7
。
然后以下将鼠标指针向右移动 100 像素:
seconds=$(date +%s)
type=2 # EV_REL
code=0 # REL_X
value=100 # 100 pixels
printf '%08X%04X%04X%08X%08X\n' $value $code $type 0 $seconds | xxd -r -p | \
perl -0777e 'print scalar reverse <>' > /dev/input/event7
type=0 # EV_SYN
code=0 # SYN_REPORT
value=0
printf '%08X%04X%04X%08X%08X\n' $value $code $type 0 $seconds | xxd -r -p | \
perl -0777e 'print scalar reverse <>' > /dev/input/event7
Run Code Online (Sandbox Code Playgroud)我没有测试这个过程是否等同于中断锁定机制意义上的真实鼠标移动。