From hekuran, 3 Months ago, written in Bash.
Embed
  1. #!/bin/sh
  2.  
  3. # Notify me with notify-send if my battery is below 25%.
  4. # You can set this to run via cron.
  5. status="$(cat /sys/class/power_supply/BAT0/status)"
  6. test "$status" = 'Charging' && exit 0
  7.  
  8. # DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u "$USER")/bus; export DISPLAY=:0;
  9. # export DBUS_SESSION_BUS_ADDRESS
  10. prct=36
  11. capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
  12.  
  13. test "$capacity" -le "$prct" && \
  14.         notify-send -u critical "     ❗❗LOW Battery❗❗" " ❗HIBERNATING In One Minute❗" && \
  15.                 sleep 57 && \
  16.                         test "$capacity" -le "$prct" && \
  17.                                 ! test status = 'Charging' && \
  18.                                         systemctl hibernate

Replies to cronbat rss

Title Name Language When
cronbat hekuran bash 3 Months ago.