mirror of
https://github.com/sahinakkaya/dotfiles.git
synced 2024-11-22 00:29:37 +01:00
Add battery script
This commit is contained in:
parent
328b1eb452
commit
e030b16b8f
20
scripts/check-battery.sh
Executable file
20
scripts/check-battery.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set limit to shell argument
|
||||
batteryLimit=$1
|
||||
fullAt=92
|
||||
|
||||
# Get the current battery level with acpi
|
||||
batteryLevel=$(acpi | cut -d ' ' -f 4 | tr -d '%|,| ')
|
||||
charging=$(acpi | cut -d ' ' -f 3 | tr -d ',| ')
|
||||
|
||||
echo $batteryLevel
|
||||
|
||||
if [[ "$batteryLevel" -le "$batteryLimit" ]] && [[ "$charging" == "Discharging" ]]; then
|
||||
/usr/bin/notify-send -a "Battery Warning" --urgency critical "Battery level at ${batteryLevel}%" -i abrt -t 10000
|
||||
/usr/bin/mpv /usr/share/sounds/Oxygen-Sys-Warning.ogg
|
||||
# /usr/bin/aplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
|
||||
#elif [[ "$batteryLevel" -gt "$fullAt" ]] && [[ ! "$charging" == "Discharging" ]]; then
|
||||
# /usr/bin/notify-send -a "Battery Warning" "Battery is full: ${batteryLevel}" -i abrt -t 10000
|
||||
# /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
|
||||
fi
|
Loading…
Reference in New Issue
Block a user