I'm running Ubuntu 22.04.2 LTS and want to display the lock screen when I unplug my charger. Is there a script, plugin or program that will let me do this?
Asked
Active
Viewed 69 times
0
1 Answers
0
tl;dr:
sudo bash -c 'cat << EOF > /etc/udev/rules.d/80.lock_when_unpluged.rules
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/bin/loginctl lock-sessions"
EOF'
# ... and reboot
Tested on ubuntu 20.04 and 22.04
I have a file at /etc/udev/rules.d/80.lock_when_unpluged.rules, and it works like a charm :
# /etc/udev/rules.d/80.lock_when_unpluged.rules
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/bin/loginctl lock-sessions"
I needed a reboot
Bryan Brancotte
- 101