summaryrefslogtreecommitdiff
path: root/scripts/battery-status.sh
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-08-04 17:41:27 +0300
committerSyndamia <kamen@syndamia.com>2022-08-04 17:41:27 +0300
commit80b4c81b618d4e75b301ac1dd5adfb47f91deca7 (patch)
treebc7d94935b273a1aa9b1a1b69c2bbc853c8a32e7 /scripts/battery-status.sh
parenta47706a5bd5ee5be16e3fe443b6008cac9ee741d (diff)
downloaddotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.tar
dotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.tar.gz
dotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.zip
Moved a lot of stuff to a new folder called .a
Diffstat (limited to 'scripts/battery-status.sh')
-rwxr-xr-xscripts/battery-status.sh57
1 files changed, 0 insertions, 57 deletions
diff --git a/scripts/battery-status.sh b/scripts/battery-status.sh
deleted file mode 100755
index efbc2a2..0000000
--- a/scripts/battery-status.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-if [[ "$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep native-path | awk '{print $2}')" == '(null)' ]]; then
- exit
-fi
-
-battery_notify () {
- # if battery percentage is equal to given one, if battery percentage inside /tmp/battery.tmp is not equal to given one and if power indicator is the given on
- if [ ${__bat_per} -eq $1 ] && ! grep -q $1 "/tmp/battery.tmp" && [[ ${__bat_power} = $2 ]]; then
- # Send notification and rewrite battery.tmp file with current percentage
- notify-send -u critical -i battery-low -t 99999999 "$3"
- echo $1 > /tmp/battery.tmp
- fi
-}
-
-# If upower command is available
-if command -v upower > /dev/null 2>&1 ; then
-
- # Get battery power indicator (charging/discharging/fully charged) and stop script if there is no value for it (if there is no battery in device)
- __bat_power=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state | awk '{print $2}')
- if [[ -n ${__bat_per} ]]; then
- exit
- fi
-
- # Set the battery power indicator icon
- __bat_power_ind=""
- if [[ ${__bat_power} = "charging" ]]; then __bat_power_ind=""
- elif [[ ${__bat_power} = "discharging" ]]; then __bat_power_ind=""
- elif [[ ${__bat_power} = "fully-charged" ]]; then __bat_power_ind=""
- fi
-
- # Get the battery percentage, time until the battery is empty and time until the battery is full
- __bat_per=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk '{print $2}' | sed "s|%||g")
- __time_empt=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time to empty" | awk '{print $4 $5}' | grep -o '^[0-9.]*[a-z]')
- __time_full=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time to full" | awk '{print $4 $5}' | grep -o '^[0-9.]*[a-z]')
-
- # Print the battery power indicator icon, percentage and time until empty or time until full
- echo -n " ${__bat_power_ind} ${__bat_per}%"
- if [[ ${__bat_power} = "discharging" ]]; then
- echo " ${__time_empt}"
- else
- echo " ${__time_full}"
- fi
-
- # Create the temporary battery file, if it doesn't exist
- if [ ! -f "/tmp/battery.tmp" ]; then
- touch /tmp/battery.tmp
- fi
-
- # Setup for battery notifications
- battery_notify 100 'fully-charged' 'Battery 100%'
- battery_notify 80 'charging' 'Battery 80%'
- battery_notify 20 'discharging' 'Battery 20%'
- battery_notify 15 'discharging' 'Battery 15%'
- battery_notify 10 'discharging' 'Battery 10%'
- battery_notify 5 'discharging' 'Battery 5%'
-fi