summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/statusbar')
-rwxr-xr-x.local/bin/statusbar/battery10
-rwxr-xr-x.local/bin/statusbar/pacpackages16
-rwxr-xr-x.local/bin/statusbar/weather6
3 files changed, 22 insertions, 10 deletions
diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery
index d9506f0..e8b0554 100755
--- a/.local/bin/statusbar/battery
+++ b/.local/bin/statusbar/battery
@@ -11,8 +11,10 @@ case $BLOCK_BUTTON in
- Text color reflects charge left" ;;
esac
-capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
-status=$(cat /sys/class/power_supply/"$1"/status)
+for battery in /sys/class/power_supply/BAT?
+do
+capacity=$(cat "$battery"/capacity) || exit
+status=$(cat "$battery"/status)
if [ "$capacity" -ge 75 ]; then
color="#00ff00"
@@ -29,4 +31,6 @@ fi
[ "$status" = "Charging" ] && color="#ffffff"
-printf "<span color='%s'>%s%s%s</span>\n" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
+printf "%s%s%s\n" "$(echo "$status" | sed "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
+done
+
diff --git a/.local/bin/statusbar/pacpackages b/.local/bin/statusbar/pacpackages
index 418bc2d..4273c86 100755
--- a/.local/bin/statusbar/pacpackages
+++ b/.local/bin/statusbar/pacpackages
@@ -1,10 +1,21 @@
#!/bin/sh
-# i3blocks module for pacman upgrades.
# Displays number of upgradeable packages.
# For this to work, have a `pacman -Sy` command run in the background as a
# cronjob every so often as root. This script will then read those packages.
# When clicked, it will run an upgrade via pacman.
+#
+# Add the following text as a file in /usr/share/libalpm/hooks/statusbar.hook:
+#
+# [Trigger]
+# Operation = Upgrade
+# Type = Package
+# Target = *
+#
+# [Action]
+# Description = Updating statusbar...
+# When = PostTransaction
+# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks
case $BLOCK_BUTTON in
1) $TERMINAL -e popupgrade ;;
@@ -14,5 +25,4 @@ case $BLOCK_BUTTON in
- Middle click to show upgradable packages" ;;
esac
-
-pacman -Qu | grep -v "\[ignored\]" | wc -l | sed -e "s/^0$//g"
+pacman -Qu | grep -v "\[ignored\]" | wc -l | sed "s/^/📦/;s/^📦0$//g"
diff --git a/.local/bin/statusbar/weather b/.local/bin/statusbar/weather
index 4a11673..dc33cb9 100755
--- a/.local/bin/statusbar/weather
+++ b/.local/bin/statusbar/weather
@@ -1,12 +1,10 @@
#!/bin/sh
-location="$1"; [ -z "$location" ] || { location="$location+" && rm -f "$HOME/.local/share/weatherreport" ;}
-
getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
-curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" || exit 1 ;}
+curl -sf "wttr.in/$LOCATION" > "$HOME/.local/share/weatherreport" || exit 1 ;}
showweather() { printf "%s" "$(sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
-sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
+sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-+\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
case $BLOCK_BUTTON in
1) $TERMINAL -e less -S "$HOME/.local/share/weatherreport" ;;