battery-notifier etc.
This commit is contained in:
parent
4f39b09ee6
commit
601277609f
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# low and critical battery level.
|
||||||
|
# at low battery level, notification will be sent to inform the user.
|
||||||
|
# at critcal battery level, urgent notification will be sent and if user does not plugin within the given Backup time (mentioned below), system will perform critical level action
|
||||||
|
# range = 0 - 100
|
||||||
|
# default: low=10, critcal=5
|
||||||
|
low=20
|
||||||
|
critical=15
|
||||||
|
|
||||||
|
# the time (in seconds) given to user to backup or plugin power, after critical level is reached
|
||||||
|
# default: backup=20
|
||||||
|
backupTime=25
|
||||||
|
|
||||||
|
# time (in seconds) after which the script is called again to check battery level
|
||||||
|
# default: sleepTime=30
|
||||||
|
sleepTime=60
|
||||||
|
|
||||||
|
# Select the critical Action which will be performed when battery is critical
|
||||||
|
# Values: suspend, poweroff, hibernate, hybrid-sleep
|
||||||
|
# default: criticalAction="suspend"
|
||||||
|
criticalAction="suspend"
|
||||||
|
|
||||||
|
# variable (boolean) to check if user is notified or not. Used within the script. DO NOT CHANGE or script might malfunction
|
||||||
|
# default: notified=0
|
||||||
|
notified=0
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
# get battery-level(0-100%) and state(discharging/charging)
|
||||||
|
battery=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
|
state=$(cat /sys/class/power_supply/BAT0/status)
|
||||||
|
echo $battery
|
||||||
|
echo $state
|
||||||
|
echo $notified
|
||||||
|
if [ "$state" = "Discharging" ] ; then
|
||||||
|
# if battery discharging and below low level then send notification
|
||||||
|
if [ $battery -gt $critical ] && [ $battery -le $low ] && [ $notified -eq 0 ] ; then
|
||||||
|
notify-send 'Battery Low' 'Plugin to Recharge' --icon=/home/hate/.icons/battery-low.png
|
||||||
|
let notified=1
|
||||||
|
# if battery discharging and below critical level then send notification and wait for user action
|
||||||
|
elif [ $battery -le $critical ] ; then
|
||||||
|
tempTime=$(( $backupTime*1000 ))
|
||||||
|
notify-send "Turning off system in $backupTime sec(s)" 'Backup Data or Plugin to Recharge' --icon=battery-low --urgency=critical --expire-time=$tempTime
|
||||||
|
sleep $backupTime
|
||||||
|
tempState=$(cat /sys/class/power_supply/BAT0/status)
|
||||||
|
# if battery still discharging, then perform critical action
|
||||||
|
if [ "$tempState" = "Discharging" ] ; then
|
||||||
|
executionCommand="systemctl $criticalAction"
|
||||||
|
eval $executionCommand
|
||||||
|
# if battery is now pluged in, then do not perform critical action
|
||||||
|
else
|
||||||
|
let notified=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
let notified=0
|
||||||
|
fi
|
||||||
|
sleep $sleepTime
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -74,6 +74,8 @@ exec --no-startup-id twmnd &
|
||||||
#exec --no-startup-id mpdscribble --no-daemon &
|
#exec --no-startup-id mpdscribble --no-daemon &
|
||||||
#Wpgtk
|
#Wpgtk
|
||||||
exec --no-startup-id ~/.config/wpg/wp_init.sh
|
exec --no-startup-id ~/.config/wpg/wp_init.sh
|
||||||
|
#Battery notify
|
||||||
|
exec --no-startup-id ~/.config/Scripts/i3-battery-monitor
|
||||||
#Conky
|
#Conky
|
||||||
#exec --no-startup-id conky -d -c ~/.config/conky/conkybg &
|
#exec --no-startup-id conky -d -c ~/.config/conky/conkybg &
|
||||||
#Picom
|
#Picom
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ label-background = ${colors.color9}
|
||||||
[module/temperature]
|
[module/temperature]
|
||||||
type = internal/temperature
|
type = internal/temperature
|
||||||
thermal-zone = 6
|
thermal-zone = 6
|
||||||
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp1_input
|
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input
|
||||||
warn-temperature = 65
|
warn-temperature = 65
|
||||||
format = <ramp> <label>
|
format = <ramp> <label>
|
||||||
format-underline = ${colors.foreground}
|
format-underline = ${colors.foreground}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
export REDSHIFT=on
|
export REDSHIFT=off
|
||||||
export REDSHIFT_TEMP=3500
|
export REDSHIFT_TEMP=3500
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ dell-bios-fan-control-git
|
||||||
device-mapper
|
device-mapper
|
||||||
dialog
|
dialog
|
||||||
diffutils
|
diffutils
|
||||||
|
downgrade
|
||||||
e2fsprogs
|
e2fsprogs
|
||||||
exfat-utils
|
exfat-utils
|
||||||
fakeroot
|
fakeroot
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue