src/battery: add
This commit is contained in:
parent
479ed6be92
commit
b5796746f2
1 changed files with 52 additions and 0 deletions
52
src/battery
Executable file
52
src/battery
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Define icon theme and path
|
||||
icon_theme="Tela-circle-black-dark"
|
||||
icon_path="/usr/share/icons/${icon_theme}/24/panel"
|
||||
|
||||
# Define icon files for different discharging battery states
|
||||
discharging_empty="${icon_path}/battery-000.svg"
|
||||
discharging_low="${icon_path}/battery-020.svg"
|
||||
discharging_medium="${icon_path}/battery-050.svg"
|
||||
discharging_good="${icon_path}/battery-080.svg"
|
||||
discharging_full="${icon_path}/battery-100.svg"
|
||||
|
||||
# Define icon files for different charging battery states
|
||||
charging_empty="${icon_path}/battery-020"
|
||||
charging_low="${icon_path}/battery-020-charging.svg"
|
||||
charging_medium="${icon_path}/battery-050-charging.svg"
|
||||
charging_good="${icon_path}/battery-080-charging.svg"
|
||||
charging_full="${icon_path}/battery-100-charged.svg"
|
||||
|
||||
# Get the capacity and charging state of the battery
|
||||
capacity="$(cat "/sys/class/power_supply/BAT0/capacity")"
|
||||
charging="$(cat "/sys/class/power_supply/AC/online")"
|
||||
|
||||
# Send a different notification based on the charging state
|
||||
if [ $charging -eq 0 ]; then
|
||||
# send a different notification based on the capacity
|
||||
if [ $capacity -gt 90 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_full -t 4000
|
||||
elif [ $capacity -gt 70 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_good -t 4000
|
||||
elif [ $capacity -gt 40 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_medium -t 4000
|
||||
elif [ $capacity -gt 10 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_low -t 4000
|
||||
else
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_empty -t 4000
|
||||
fi
|
||||
else
|
||||
# Send a different notification based on the capacity
|
||||
if [ $capacity -gt 90 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_full -t 4000
|
||||
elif [ $capacity -gt 70 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_good -t 4000
|
||||
elif [ $capacity -gt 40 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_medium -t 4000
|
||||
elif [ $capacity -gt 10 ]; then
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_low -t 4000
|
||||
else
|
||||
notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_empty -t 4000
|
||||
fi
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue