]> git.armaanb.net Git - bin.git/blobdiff - status
Web-update-server: Switch to rebase pull
[bin.git] / status
diff --git a/status b/status
index 7f3843a45c47d6eb8a635cde27720124b50a0685..9154162fd7b27ef8e2a218ec4c5e60fd92715023 100755 (executable)
--- a/status
+++ b/status
@@ -1,18 +1,19 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
+# Sends a notification with battery level and time
+
 function time_set() {
-  date +%A" "%B" "%e" | "%1l:%M:%S
+  date +%A", "%b" "%e", "%r
 }
 
 function power_set() {
-  upower -d | grep percentage | tail -c 4 | head -c 3
-  echo " battery,"
-  upower --dump | grep "time to empty" | tail -c 15
+  upower -d | grep percentage | tail -c 5
+  if [[ $(upower -d | grep "discharging") ]]; then
+    echo " battery,"
+    echo "$(upower -d | grep "time to empty" | tail -c 15) remaining"
+  else
+    echo " battery,"
+    echo "$(upower -d | grep "time to full" | tail -c 15) until charged"
+  fi
 }
 
-export TIME=$(time_set)
-export POWER=$(power_set)
-
-notify-send -i "clock" "`echo $TIME`" "`echo $POWER`"
-
-
+notify-send -i "clock" "`echo $(time_set)`" "`echo $(power_set)`"