Skip to content

Commit

Permalink
fix(cronbat): skip "complete-charge" if discharging more than 95%
Browse files Browse the repository at this point in the history
  • Loading branch information
YeferYV committed Oct 27, 2022
1 parent eac1dee commit 11b8050
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
6 changes: 5 additions & 1 deletion wslfiles/.config/sxhkd/sxhkdrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 18,12 @@ mod1 {_,shift ,ctrl }Return
ctrl {_,shift }Return
dunstctl {close, history-pop}

# make sxhkd reload its configuration files:
# stop cronbat
super Escape
ps aux | grep cronbat | awk '\{print $2\}' | xargs kill -9 & dunstctl close

# make sxhkd reload its configuration files:
super shift Escape
pkill -USR1 -x sxhkd

#
Expand Down
36 changes: 20 additions & 16 deletions wslfiles/.local/bin/cron/cronbat
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 21,27 @@ countdown() {
# Path for mimic nix package
export PATH="/home/drksl/.nix-profile/bin:/home/drksl/.local/bin:/usr/local/bin:/usr/bin"

# TO STOP SHUTDOWN:
# ps aux | grep cronbat | awk '{print $2}' | xargs kill -9 && killall notify-send

# DON'T EVEN DARE TO COMMENT THIS CODE OUT
# date %T | awk -F ':' '($1 >= 23 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "23:50 hours 🛌 lights out" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 23 && $2 == 40)' | xargs -I_ [ -z _ ] || (echo "23:40 hours 🛌 still redeyes? " | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 30)' | xargs -I_ [ -z _ ] || (echo "23:30 hours 🛌 follow your own rules " | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 23 && $2 == 20)' | xargs -I_ [ -z _ ] || (echo "23:20 hours 🛌 less energy more migraine" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 23 && $2 == 10)' | xargs -I_ [ -z _ ] || (echo "23:10 hours 🛌 waking late " | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 00)' | xargs -I_ [ -z _ ] || (echo "23:00 hours 🛌 go bed, listen podcats" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "22:50 hours 🛌 sleep boy health is first, glasses?" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 40)' | xargs -I_ [ -z _ ] || (echo "22:40 hours 🛌 work smart than harder" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 22 && $2 == 30)' | xargs -I_ [ -z _ ] || (echo "22:30 hours 🛌 slow time, follow the rules" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 30)' | xargs -I_ [ -z _ ] || (echo "22:20 hours 🛌 use your time wisely" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 10)' | xargs -I_ [ -z _ ] || (echo "22:10 hours 🛌 4AM rule, feeling untired, study math, bysnappy" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 00)' | xargs -I_ [ -z _ ] || (echo "22:00 hours 🛌 wake up before the enemy, challenge yourself" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 21 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "21:50 hours 🛌 feeling slow, low cognition" | tee >(mimic -voice slt_hts) && countdown 1800 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 21 && $2 == 40) {exit 1}' || (mimic -voice slt_hts -t "21:40 hours 💤 sleeping late equals sleepy next day" && notify-send -u low "21:40 hours 💤")
date %T | awk -F ':' '($1 >= 23 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "23:50 hours 🛌 lights out" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 40)' | xargs -I_ [ -z _ ] || (echo "23:40 hours 🛌 still redeyes? " | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 30)' | xargs -I_ [ -z _ ] || (echo "23:30 hours 🛌 follow your own rules " | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 20)' | xargs -I_ [ -z _ ] || (echo "23:20 hours 🛌 less energy more migraine" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 10)' | xargs -I_ [ -z _ ] || (echo "23:10 hours 🛌 waking late " | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 23 && $2 == 00)' | xargs -I_ [ -z _ ] || (echo "23:00 hours 🛌 go bed, listen podcats" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 22 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "22:50 hours 🛌 sleep boy health is first, glasses?" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 22 && $2 == 40)' | xargs -I_ [ -z _ ] || (echo "22:40 hours 🛌 work smart than harder" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 22 && $2 == 30)' | xargs -I_ [ -z _ ] || (echo "22:30 hours 🛌 slow time, follow the rules" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 22 && $2 == 20)' | xargs -I_ [ -z _ ] || (echo "22:20 hours 🛌 use your time wisely" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 10)' | xargs -I_ [ -z _ ] || (echo "22:10 hours 🛌 4AM rule, feeling untired, study math, bysnappy" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 22 && $2 == 00)' | xargs -I_ [ -z _ ] || (echo "22:00 hours 🛌 wake up before the enemy, challenge yourself" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
# date %T | awk -F ':' '($1 >= 21 && $2 == 50)' | xargs -I_ [ -z _ ] || (echo "21:50 hours 🛌 feeling slow, low cognition" | tee >(mimic -voice slt_hts) && countdown 600 && sudo -i poweroff)
date %T | awk -F ':' '($1 >= 21 && $2 == 50) {exit 1}' || (mimic -voice slt_hts -t "21:50 hours 💤 sleeping late equals sleepy next day" && notify-send -u low "21:50 hours 💤")
date %T | awk -F ':' '($1 >= 21 && $2 ~".0") {print $1":"$2}' | mimic -voice slt_hts
date %T | awk -F ':' '($1 ~ "." && $2 == 00) {print $1":"$2}' | mimic -voice slt_hts
cat /sys/class/power_supply/BAT0/capacity | awk ' $1 >= 98 {system("mimic -voice slt_hts -t complete-charge") }'
cat /sys/class/power_supply/BAT0/status | awk '$1 == "Discharging" {exit 1}' &&
cat /sys/class/power_supply/BAT0/capacity | awk ' $1 >= 95 {system("mimic -voice slt_hts -t complete-charge") }'
cat /sys/class/power_supply/BAT0/status | awk '$1 == "Charging" {exit 1}' &&
cat /sys/class/power_supply/BAT0/capacity | awk '$1 <= 15 {system("mimic -voice slt_hts -t "$1"-percent") } ; $1 == 5 {system("notify-send -u critical " $1 "% discharging\n") }'
cat /sys/class/power_supply/BAT0/capacity | awk '$1 <= 15 {system("mimic -voice slt_hts -t "$1"-percent") } ; $1 <= 5 {system("notify-send -u critical " $1 "% discharging\n") }'

0 comments on commit 11b8050

Please sign in to comment.