Skip to content

Instantly share code, notes, and snippets.

@evamvid
Created June 23, 2015 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evamvid/a7231fca5e549d88871e to your computer and use it in GitHub Desktop.
Save evamvid/a7231fca5e549d88871e to your computer and use it in GitHub Desktop.
PowerBlocker
#!/bin/bash
cat /sys/class/power_supply/BAT0/status
OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
echo "${OUTPUT}"
if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
echo charging or full
elif [ "${OUTPUT}" = "Discharging" ]; then
notify-send -i /home/evamvid/Documents/Programming/OokiNoUse/power25.png "Hey there brother" "plug it in"
COUNTER=0
while [ "$COUNTER" -le 12 ]
do
cat /sys/class/power_supply/BAT0/status
OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
echo "${OUTPUT}"
if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
exit
elif [ "${OUTPUT}" = "Discharging" ]; then
COUNTER=$(($COUNTER+1))
echo $COUNTER
sleep 1
fi
done
fi
@evamvid
Copy link
Author

evamvid commented Nov 2, 2016

preliminary bash script to stop computer from being used when the power is on. I don't even know if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment