diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-04-27 11:38:33 +0200 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-04-27 11:38:33 +0200 |
commit | 270b45988de6d76dbe284dcaf73c908a2e37ca46 (patch) | |
tree | dc1866d7cc63d9eaf0f45c281d9781e2e7715e1d /bin | |
parent | 7caa9a0fa8557707737598e5d2de2384b3f1e289 (diff) |
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/extra/cycleKB | 2 | ||||
-rwxr-xr-x | bin/extra/saveself | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/bin/extra/cycleKB b/bin/extra/cycleKB index 8f0de60..c3cc9f6 100755 --- a/bin/extra/cycleKB +++ b/bin/extra/cycleKB @@ -35,4 +35,4 @@ notify-send "_cycleKB" "*${Layout%% -option*}" & exit # THIS LINE IS ADDED AUTOMATICALLY -us -variant colemak -option ctrl:swapcaps,altwin:menu_win +us diff --git a/bin/extra/saveself b/bin/extra/saveself new file mode 100755 index 0000000..8906a5f --- /dev/null +++ b/bin/extra/saveself @@ -0,0 +1,41 @@ +#!/bin/sh + +Threshold=5 + +GetBatteryCapacity() +{ + File="$(find /sys/class/power_supply \ + -maxdepth 1 \ + -type l \ + -name 'BAT*' | + head -n 1)" + cat "$File"/capacity +} + +PrevCapacity="$(GetBatteryCapacity)" +[ "$PrevCapacity" ] || exit 1 + +while true +do + sleep 5 + Capacity="$(GetBatteryCapacity)" + if [ "$Capacity" -lt "$PrevCapacity" ] + then + if [ "$Capacity" -le "$Threshold" ] + then + setsid slock + HostName="$(hostname)" + if [ "$HostName" = "spring" ] + then + doas /usr/sbin/zzz -Z + elif [ "$HostName" = "winter" ] + then + systemctl hibernate + fi + fi + PrevCapacity="$Capacity" + fi +done + + + |