summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-06-29 12:14:19 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-06-29 12:14:19 +0300
commita1ea786ce911c3a41eb4e0f56e63d548a7521b09 (patch)
treec36aa2ef65f0e759f5a7777221a029889bb78872
parent2ddecd462c293ab81787ee0ac2daf4dbe44e40cd (diff)
downloaddotfiles-a1ea786ce911c3a41eb4e0f56e63d548a7521b09.tar
dotfiles-a1ea786ce911c3a41eb4e0f56e63d548a7521b09.tar.gz
dotfiles-a1ea786ce911c3a41eb4e0f56e63d548a7521b09.zip
Added a battery status information script
-rw-r--r--.config/tint2/tint2rc39
-rw-r--r--.gitignore1
-rwxr-xr-xbattery-status.sh37
3 files changed, 70 insertions, 7 deletions
diff --git a/.config/tint2/tint2rc b/.config/tint2/tint2rc
index 0e9d66c..1869b54 100644
--- a/.config/tint2/tint2rc
+++ b/.config/tint2/tint2rc
@@ -1,4 +1,4 @@
-#---- Generated by tint2conf 98f8 ----
+#---- Generated by tint2conf 512e ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for
# full documentation of the configuration options.
#-------------------------------------
@@ -72,7 +72,7 @@ border_color_pressed = #ffffff 0
#-------------------------------------
# Panel
-panel_items = L:T:SE:C
+panel_items = L:T:SEE:C
panel_size = 100% 50
panel_margin = 0 0
panel_padding = 8 4 4
@@ -165,7 +165,7 @@ launcher_item_app = /usr/share/applications/jgmenu.desktop
# Clock
time1_format = %H:%M - %d.%m.%Y
time2_format =
-time1_font = Sans 10
+time1_font = Sans 11
time1_timezone =
time2_timezone =
clock_font_color = #eeeeee 100
@@ -183,14 +183,14 @@ clock_dwheel_command =
# Battery
battery_tooltip = 1
battery_low_status = 10
-battery_low_cmd = notify-send "battery low"
+battery_low_cmd = notify-send -u critical -i battery-low 'Battery low!'
battery_full_cmd =
-bat1_font = sans 8
+bat1_font = sans 10
bat2_font = sans 6
battery_font_color = #eeeeee 100
-bat1_format =
+bat1_format = $(/home/kamen/battery-status.sh)
bat2_format =
-battery_padding = 1 0
+battery_padding = 0 3
battery_background_id = 0
battery_hide = 101
battery_lclick_command =
@@ -237,11 +237,13 @@ execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 1
execp_markup = 0
+execp_monitor = all
execp_lclick_command =
execp_rclick_command =
execp_mclick_command =
execp_uwheel_command =
execp_dwheel_command =
+execp_font = Sans 11
execp_font_color = #ffffff 100
execp_padding = 0 3
execp_background_id = 0
@@ -250,6 +252,29 @@ execp_icon_w = 0
execp_icon_h = 0
#-------------------------------------
+# Executor 2
+execp = new
+execp_command = /home/kamen/battery-status.sh
+execp_interval = 1
+execp_has_icon = 0
+execp_cache_icon = 1
+execp_continuous = 1
+execp_markup = 0
+execp_monitor = all
+execp_lclick_command =
+execp_rclick_command =
+execp_mclick_command =
+execp_uwheel_command =
+execp_dwheel_command =
+execp_font = Sans 11
+execp_font_color = #ffbe6f 100
+execp_padding = 0 3
+execp_background_id = 0
+execp_centered = 1
+execp_icon_w = 0
+execp_icon_h = 0
+
+#-------------------------------------
# Tooltip
tooltip_show_timeout = 0.5
tooltip_hide_timeout = 0.1
diff --git a/.gitignore b/.gitignore
index 6469521..2b04282 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@
!app-mem.sh
!toggle-desktop.sh
!dunst-toggler-applet.sh
+!battery-status.sh
!.local/
.local/*
diff --git a/battery-status.sh b/battery-status.sh
new file mode 100755
index 0000000..f0a829f
--- /dev/null
+++ b/battery-status.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+battery_notify () {
+ if [ ${__bat_per} -eq $1 ] && [[ ${__bat_power} = $2 ]] && ! [[ -f "/tmp/battery.tmp" ]]; then
+ notify-send -u critical -i battery-low "$3"
+ touch /tmp/battery.tmp
+ elif ! [ ${__bat_per} -eq $1 ] && [[ -f "/tmp/battery.tmp" ]]; then
+ rm /tmp/battery.tmp
+ fi
+}
+
+if command -v upower > /dev/null 2>&1 ; then
+ __bat_power=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state | awk '{print $2}')
+ if [[ -n ${__bat_per} ]]; then
+ exit
+ fi
+ __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
+ __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]')
+
+ echo -n " ${__bat_power_ind} ${__bat_per}%"
+ if [[ ${__bat_power} = "discharging" ]]; then
+ echo " ${__time_empt}"
+ else
+ echo " ${__time_full}"
+ fi
+
+ battery_notify 100 'fully-charged' 'Battery charged!'
+ battery_notify 15 'discharging' 'Battery low!'
+ battery_notify 10 'discharging' 'Battery lower!!'
+ battery_notify 5 'discharging' 'Battery critical!!!'
+fi