blob: 64e39154021b146be811b19027aae67e434d2311 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/bash
# use xinput to get all keyboards and pointers (mouse)
keyboards=$( xinput list | grep -E "slave.*(keyboard|pointer)" | grep -oP '(?<=id=)\d+' )
[ -z "$keyboards" ] && exit 0
# Make sure we're matching lock/unlock calls
TMP="${XDG_RUNTIME_DIR:-"/run/user/$UID"}/pvslock"
for i in 10 20 40 80 160 320 0; do
if mkdir "$TMP"; then
echo "$keyboards" > "$TMP/locked" && break
fi
usleep ${i}000
done
if [ "$i" = 0 ]; then
echo "locked, raced"
exit 0
fi
for id in $keyboards; do
echo "disabling device #$id"
xinput disable "$id" &
done
wait
touch "$TMP/done"
exit 0
|