2022-11-21 23:42:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-03-08 19:11:04 +00:00
|
|
|
FILE="$HOME/.local/state/hibernate_inhibitor"
|
2022-11-21 23:42:30 +00:00
|
|
|
if [ -e $FILE ]; then
|
2023-01-06 19:41:31 +00:00
|
|
|
INHIBITED=1
|
2022-11-21 23:42:30 +00:00
|
|
|
else
|
2023-01-06 19:41:31 +00:00
|
|
|
INHIBITED=0
|
2022-11-21 23:42:30 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $1 ] || [[ "$1" == "bar" ]]; then
|
2023-01-06 19:41:31 +00:00
|
|
|
if [[ $INHIBITED == 1 ]]; then
|
|
|
|
echo '{"text":"☕","icon":"☕","tooltip":"Allow hibernation","class":"enabled"}'
|
|
|
|
else
|
|
|
|
echo '{"text":"💤","icon":"💤","tooltip":"Prevent hibernation","class":"disabled"}'
|
|
|
|
fi
|
2022-11-21 23:42:30 +00:00
|
|
|
elif [[ "$1" == "toggle" ]]; then
|
2023-01-06 19:41:31 +00:00
|
|
|
if [[ $INHIBITED == "1" ]]; then
|
|
|
|
rm $FILE
|
|
|
|
else
|
|
|
|
touch $FILE
|
|
|
|
fi
|
2022-11-21 23:42:30 +00:00
|
|
|
else
|
2023-01-06 19:41:31 +00:00
|
|
|
echo "Invalid argumuent $1"
|
2022-11-21 23:42:30 +00:00
|
|
|
fi
|