4 ms·
[OpSec] Auto lock screen when you depart with the smartphone
- moviuro 8y agoYou could probably watch dmesg and lock instantly. Probably along those lines: while IFS= read -r line; do if printf '%s\n' "$line" | grep [something here]; then # lock screen elif printf '%s\n' "$line" | grep [something else here]; then # unlock screen fi done <<< "$(dmesg -w)"
- qertoip 8y agoThanks! I wanted to force connecting the smartphone back on the user by making the check every couple of seconds and locking. For that reason event driven approach wasn't the best fit.
- kees99 8y agoOr better yet, let udev trigger do the hard work of watching for you. Just add one line to /etc/udev/rules.d/99-my.rules file: ACTION=="remove", ENV{ID_SERIAL}=="Pixel_3_0a7...", RUN+="/usr/bin/screensaver-lock-script" To find out your phone's ID_SERIAL string, run this then plug in: udevadm monitor -up
- parliament32 8y agoCool idea, and a good use for systemd timers. A few things: 1) your home directory (/home/qertoip/) is hardcoded in the .service file, 2) this assume you're using cinnamon-screensaver, for portability you should probably have a configuration var for "lock command" or similar, and 3) you should avoid the symlink setup for /usr/lib/systemd/system/, user .service and .timer files should be put in (or symlinked into) /etc/systemd/system (see man 5 systemd.unit).