aboutsummaryrefslogtreecommitdiff
path: root/.config/eww/scripts/scratchpad-indicator.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-02-06 20:44:09 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-02-06 20:44:09 +0000
commite2add462c0d66120867cdb7181a0d9c413f3e4c1 (patch)
tree4b313161d3300eeb5196d0b49d716cbec2bdc57f /.config/eww/scripts/scratchpad-indicator.sh
parent7620f87b79f7e8a4cfb6f672094a138518420d7a (diff)
Initial commit of Eww config
Diffstat (limited to '.config/eww/scripts/scratchpad-indicator.sh')
-rwxr-xr-x.config/eww/scripts/scratchpad-indicator.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/.config/eww/scripts/scratchpad-indicator.sh b/.config/eww/scripts/scratchpad-indicator.sh
new file mode 100755
index 0000000..b0911d9
--- /dev/null
+++ b/.config/eww/scripts/scratchpad-indicator.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Scratchpad indicator for Hyprland
+
+output="$(hyprctl clients -j | jq -r '.[] | select(.workspace.id==-99) |"<b>"+.class+"</b> : <i>"+.title+"</i>"')"
+number="$(hyprctl clients -j | jq -r '.[] | select(.workspace.id==-99) | (tostring)' | wc -l)"
+file=~/.config/eww/eww.scss
+
+if [ "$number" -gt 0 ]; then
+ text=" $number"
+else
+ text=""
+fi
+
+output="$(echo "$output" | sed -r 's/[&]+/and/g')" # Replace unprintable & character with the word 'and'
+tooltip="\n"
+tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')"
+tooltip=${tooltip::-2}
+
+function ShowInfo() {
+ if [ "$number" -eq 0 ]; then
+ exit
+ else
+ tooltip="$(echo -e $tooltip)"
+ notify-send " Scratchpad" "$tooltip" -r 123
+ fi
+}
+
+function Update() {
+ printf "%s" "$text"
+}
+
+if [ "$1" = "ShowInfo" ]; then
+ ShowInfo
+else
+ Update
+fi