From c90ac8fe4a98a998336ae01752d08f4399eb8251 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@clevo" Date: Mon, 14 Feb 2022 09:34:06 +0100 Subject: [PATCH] Notify when battery is low --- dotfiles/i3/scripts/battery | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dotfiles/i3/scripts/battery b/dotfiles/i3/scripts/battery index d3db8b3..c69526d 100755 --- a/dotfiles/i3/scripts/battery +++ b/dotfiles/i3/scripts/battery @@ -1,4 +1,11 @@ #!/bin/bash icon="" -echo "${icon} $(upower -d | grep 'percentage' | awk '{print $2}' | head -n 1) ($(upower -d | grep 'time to empty' | awk -F: '{print $2}' | awk '{print $1,$2}' | head -n 1))" +percent="$(upower -d | grep 'percentage' | awk '{print $2}' | head -n 1)" +remaining="$(upower -d | grep 'time to empty' | awk -F: '{print $2}' | awk '{print $1,$2}' | head -n 1)" + +if [ "$(echo "$percent" | awk -F% '{print $1}')" -lt 5 ]; then + notify-send "CHARGE YOUR BATTERY" +fi + +echo "${icon} ${percent} (${remaining})"