Created
May 27, 2014 09:10
-
-
Save michenriksen/91fb91c80cebd6c73d5b to your computer and use it in GitHub Desktop.
Simple anti-theft script for Debian systems. When the machine enters battery mode while in lockscreen/screensaver, kill KeePassX, Chromium, Firefox, dismount TrueCrypt volumes and shut down.
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/sh | |
# Put this file in /etc/pm/power.d/ and make it executable | |
case $1 in | |
true) | |
# Replace <username> with your actual username. | |
# You might need to use gnome-screensaver-command instead | |
if DISPLAY=:0.0 XAUTHORITY=/home/<username>/.Xauthority sudo -u <username> cinnamon-screensaver-command -q | egrep -q 'is active'; then | |
# Kill KeePassX | |
killall keepassx | |
# Dismount all TrueCrypt volumes | |
truecrypt --dismount | |
# Kill all chromium processes | |
for i in $(ps ax | grep chromium-browser | cut -d"?" -f1 | grep -v chromium-browser); do kill -9 $i ; done | |
# Kill all Firefox processes | |
for i in $(ps ax | grep firefox | cut -d"?" -f1 | grep -v firefox); do kill -9 $i ; done | |
# Shut down the machine | |
shutdown -P now | |
else | |
# Do stuff for when computer enters battery mode in non-lockscreen | |
fi | |
;; | |
false) | |
# Do stuff for when computer enters AC mode | |
;; | |
help) help;; | |
*) exit $NA ;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment