Last active
July 24, 2020 06:44
-
-
Save scturtle/44ba4f8d9f94afea2c277e816dfd1415 to your computer and use it in GitHub Desktop.
手机插电脑解锁拔下来锁屏
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
VENDOR="05ac:12a8" | |
SERIAL="XXXXXXXXXXXXXXXXX" | |
#LOCK="gnome-screensaver-command -l" | |
#UNLOCK="gnome-screensaver-command -d" | |
LOCK="slock" | |
UNLOCK="killall slock" | |
while true; do | |
# wait new device status | |
stdbuf -o0 udevadm monitor --udev | stdbuf -o0 grep usb | head -n1 > /dev/null | |
sleep 0.1 | |
# check the vendor info | |
found=$(lsusb -v -d "$VENDOR" | grep iSerial | awk '{print $3}') | |
# action | |
if [ "$found" != "$SERIAL" ]; then | |
echo "plug out" | |
$LOCK & | |
else | |
echo "plug in" | |
$UNLOCK | |
fi | |
sleep 0.1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment