summaryrefslogtreecommitdiffstats
path: root/.scripts/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/statusbar')
-rwxr-xr-x.scripts/statusbar/i3battery22
-rwxr-xr-x.scripts/statusbar/i3mail11
-rwxr-xr-x.scripts/statusbar/i3mpd13
-rwxr-xr-x.scripts/statusbar/i3mpdupdate9
-rwxr-xr-x.scripts/statusbar/i3pacman13
-rwxr-xr-x.scripts/statusbar/i3torrent6
-rwxr-xr-x.scripts/statusbar/i3volume22
-rwxr-xr-x.scripts/statusbar/i3weather15
-rwxr-xr-x.scripts/statusbar/i3wifi9
-rwxr-xr-x.scripts/statusbar/popupgrade10
-rwxr-xr-x.scripts/statusbar/popweather2
11 files changed, 132 insertions, 0 deletions
diff --git a/.scripts/statusbar/i3battery b/.scripts/statusbar/i3battery
new file mode 100755
index 0000000..6f045fc
--- /dev/null
+++ b/.scripts/statusbar/i3battery
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Give a battery name (e.g. BAT0) as an argument.
+
+capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
+status=$(cat /sys/class/power_supply/"$1"/status)
+
+if [ "$capacity" -ge 80 ]; then
+ color="#00FF00"
+elif [ "$capacity" -ge 60 ]; then
+ color="#FFFFFF"
+elif [ "$capacity" -ge 40 ]; then
+ color="#FFF600"
+elif [ "$capacity" -ge 20 ]; then
+ color="#FFAE00"
+else
+ color="#FF0000"
+fi
+
+[ "$status" = "Charging" ] && color="#FFF"
+
+printf "<span color='%s'>%s %s</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$(echo "$capacity" | sed -e 's/$/%/')"
diff --git a/.scripts/statusbar/i3mail b/.scripts/statusbar/i3mail
new file mode 100755
index 0000000..e80df86
--- /dev/null
+++ b/.scripts/statusbar/i3mail
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# i3blocks mail module.
+# Displays number of unread mail and an loading icon if updating.
+# When clicked, brings up `neomutt`.
+
+case $BLOCK_BUTTON in
+ 1) $TERMINAL -e neomutt ;;
+esac
+
+echo "$(du -a ~/.mail/*/INBOX/new/* | sed -n '$=')" $(cat ~/.config/mutt/.dl)
diff --git a/.scripts/statusbar/i3mpd b/.scripts/statusbar/i3mpd
new file mode 100755
index 0000000..9dc97a0
--- /dev/null
+++ b/.scripts/statusbar/i3mpd
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+filter() {
+ sed "/^volume:/d" | tac | sed -e "s/\\&/&amp;/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' | sed -e "s/$/<\\/span>/g"
+ }
+
+case $BLOCK_BUTTON in
+ 1) mpc status | filter && $TERMINAL -e ncmpcpp & disown ;; # right click, pause/unpause
+ 3) mpc toggle | filter ;; # right click, pause/unpause
+ 4) mpc prev | filter ;; # scroll up, previous
+ 5) mpc next | filter ;; # scroll down, next
+ *) mpc status | filter ;;
+esac
diff --git a/.scripts/statusbar/i3mpdupdate b/.scripts/statusbar/i3mpdupdate
new file mode 100755
index 0000000..646b49e
--- /dev/null
+++ b/.scripts/statusbar/i3mpdupdate
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+[ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit
+
+while : ; do
+ pgrep -x mpd || exit
+ mpc idle > /dev/null
+ pkill -RTMIN+11 i3blocks ;
+done
diff --git a/.scripts/statusbar/i3pacman b/.scripts/statusbar/i3pacman
new file mode 100755
index 0000000..6825b92
--- /dev/null
+++ b/.scripts/statusbar/i3pacman
@@ -0,0 +1,13 @@
+#!/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 `yay`. (`yay` required, duh.)
+
+case $BLOCK_BUTTON in
+ 1) $TERMINAL -e "popupgrade" ;;
+esac
+
+yay -Qu | sed -e '/^Get/d' | wc -l | sed -e "s/^0$//g"
diff --git a/.scripts/statusbar/i3torrent b/.scripts/statusbar/i3torrent
new file mode 100755
index 0000000..603ff01
--- /dev/null
+++ b/.scripts/statusbar/i3torrent
@@ -0,0 +1,6 @@
+#!/bin/sh
+case $BLOCK_BUTTON in
+ 1) $TERMINAL -e transmission-remote-cli
+esac
+
+transmission-remote -l | grep % | sed -e "s/.*100%.*/Z/g;s/.*Idle.*/A/g;s/.*%.*/M/g" | sort -h | uniq -c | sed -e "s/Z/🌱/g;s/M/⬇️/g;s/A/⌛️/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g"
diff --git a/.scripts/statusbar/i3volume b/.scripts/statusbar/i3volume
new file mode 100755
index 0000000..9492906
--- /dev/null
+++ b/.scripts/statusbar/i3volume
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+case $BLOCK_BUTTON in
+ 1) setsid "$TERMINAL" -e pulsemixer & ;;
+ 3) pulsemixer --toggle-mute ;;
+ 4) pulsemixer --change-volume +5 ;;
+ 5) pulsemixer --change-volume -5 ;;
+esac
+
+[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit
+
+vol=$(pulsemixer --get-volume | awk '{print $1}')
+
+if [ "$vol" -gt "70" ]; then
+ icon="🔊"
+elif [ "$vol" -lt "30" ]; then
+ icon="🔈"
+else
+ icon="🔉"
+fi
+
+printf "%s %s%%\\n" "$icon" "$vol"
diff --git a/.scripts/statusbar/i3weather b/.scripts/statusbar/i3weather
new file mode 100755
index 0000000..8573a42
--- /dev/null
+++ b/.scripts/statusbar/i3weather
@@ -0,0 +1,15 @@
+#!/bin/sh
+### This is only if your location isn't automatically detected, otherwise you can leave it blank.
+location=""
+
+[ "$location" != "" ] && location="$location+"
+
+[ "$BLOCK_BUTTON" = "1" ] && $TERMINAL -e popweather
+
+ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit
+
+curl -s wttr.in/$location > ~/.weatherreport
+
+printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
+
+sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","☀️",$2 "°"}'
diff --git a/.scripts/statusbar/i3wifi b/.scripts/statusbar/i3wifi
new file mode 100755
index 0000000..178c88e
--- /dev/null
+++ b/.scripts/statusbar/i3wifi
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+case $BLOCK_BUTTON in
+ 1) $TERMINAL -e nmtui ;;
+esac
+
+[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && echo 📡 && exit
+
+grep ^w /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }'
diff --git a/.scripts/statusbar/popupgrade b/.scripts/statusbar/popupgrade
new file mode 100755
index 0000000..739fcb7
--- /dev/null
+++ b/.scripts/statusbar/popupgrade
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+printf "Beginning upgrade.\\n"
+
+yay -Syu
+pacman -Qu | wc -l > ~/.pacupgrnum
+pkill -RTMIN+8 i3blocks
+
+printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
+read -r
diff --git a/.scripts/statusbar/popweather b/.scripts/statusbar/popweather
new file mode 100755
index 0000000..d11bdf5
--- /dev/null
+++ b/.scripts/statusbar/popweather
@@ -0,0 +1,2 @@
+#!/bin/sh
+cat ~/.weatherreport && read