aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-tasks
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-11-14 23:43:38 +0300
committerawy <awy@awy.one>2025-11-14 23:43:38 +0300
commitc7a88a07b9287db9c129914483f6b3ae1ab5404c (patch)
tree73c227c5e8519eb9135f46984e4fc067b316ed1b /.local/bin/statusbar/sb-tasks
downloadmangoslice-c7a88a07b9287db9c129914483f6b3ae1ab5404c.tar.gz
init
Diffstat (limited to '.local/bin/statusbar/sb-tasks')
-rwxr-xr-x.local/bin/statusbar/sb-tasks20
1 files changed, 20 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-tasks b/.local/bin/statusbar/sb-tasks
new file mode 100755
index 0000000..14778a2
--- /dev/null
+++ b/.local/bin/statusbar/sb-tasks
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Originally by Andr3as07 <https://github.com/Andr3as07>
+# Some changes by Luke
+# Rebuild by Tenyun
+
+# This block displays the number running background tasks. Requires tsp.
+
+num=$(tsp -l | awk -v numr=0 -v numq=0 '{if (/running/)numr++; if (/queued/)numq++} END{print numr+numq"("numq")"}')
+
+# Handle mouse clicks
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -e tsp -l >/dev/null 2>&1 ;;
+ 3) notify-send "Tasks module" "🤖: number of running/queued background tasks
+- Left click opens tsp" ;; # Right click
+ 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;;
+esac
+
+[ "$num" != "0(0)" ] &&
+ echo "🤖$num"