about summary refs log tree commit diff
path: root/home/profiles
diff options
context:
space:
mode:
Diffstat (limited to 'home/profiles')
-rw-r--r--home/profiles/gui/config/waybar/settings.nix14
-rw-r--r--home/profiles/gui/config/waybar/style.nix4
-rw-r--r--home/profiles/gui/default.nix2
-rw-r--r--home/profiles/gui/scripts/scratchpad-indicator.nix18
4 files changed, 35 insertions, 3 deletions
diff --git a/home/profiles/gui/config/waybar/settings.nix b/home/profiles/gui/config/waybar/settings.nix
index 9470824..341a1b3 100644
--- a/home/profiles/gui/config/waybar/settings.nix
+++ b/home/profiles/gui/config/waybar/settings.nix
@@ -1,4 +1,4 @@
-{ config, lib, neotheme }:
+{ config, lib, pkgs, neotheme }:
 
 with neotheme.colors;
 
@@ -10,7 +10,7 @@ in
   position = "top";
   height = 22;
   modules-left = [ "wireplumber" "custom/separator" "cpu" "custom/separator" "memory" "custom/separator" "idle_inhibitor" ];
-  modules-center = [ "sway/workspaces" ];
+  modules-center = [ "sway/workspaces" "custom/scratchpad-indicator" ];
   modules-right = [ "group/tray" "custom/separator" "network" "custom/separator" ]
     ++ lib.optionals (guiCfg.laptop.enable) [ "battery" "custom/separator" ]
     ++ [ "clock" ];
@@ -96,6 +96,16 @@ in
     tooltip = false;
   };
 
+  "custom/scratchpad-indicator" = {
+    format = "(+{})";
+    interval = 3;
+    return-type = "json";
+    hide-empty-text = true;
+    exec = "${pkgs.writeShellScript "scratchpad-indicator" (import ../../scripts/scratchpad-indicator.nix)}";
+    on-click = "exec swaymsg scratchpad show";
+    on-click-right = "exec swaymsg move scratchpad";
+  };
+
   "custom/separator" = {
     format = "|";
     interval = "once";
diff --git a/home/profiles/gui/config/waybar/style.nix b/home/profiles/gui/config/waybar/style.nix
index ac6aad7..1f5327e 100644
--- a/home/profiles/gui/config/waybar/style.nix
+++ b/home/profiles/gui/config/waybar/style.nix
@@ -107,6 +107,10 @@ in
     padding-right: 0.2rem;
   }
 
+  #custom-scratchpad-indicator {
+    color: #f0a0c0;
+  }
+
   #custom-separator {
     color: #${alt1};
     background-color: #${background};
diff --git a/home/profiles/gui/default.nix b/home/profiles/gui/default.nix
index d43e454..cba6747 100644
--- a/home/profiles/gui/default.nix
+++ b/home/profiles/gui/default.nix
@@ -166,7 +166,7 @@ in
       waybar = {
         enable = config.wayland.windowManager.sway.enable;
 
-        settings = [ (import ./config/waybar/settings.nix { inherit config lib neotheme; }) ];
+        settings = [ (import ./config/waybar/settings.nix { inherit config lib pkgs neotheme; }) ];
 
         style = import ./config/waybar/style.nix { inherit config neotheme; };
       };
diff --git a/home/profiles/gui/scripts/scratchpad-indicator.nix b/home/profiles/gui/scripts/scratchpad-indicator.nix
new file mode 100644
index 0000000..7ee66c3
--- /dev/null
+++ b/home/profiles/gui/scripts/scratchpad-indicator.nix
@@ -0,0 +1,18 @@
+''
+output="$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.name == "__i3_scratch").floating_nodes[]|"`<b>"+.name+"`</b> - "+.app_id+" "+(.id|tostring)')"
+number="$(swaymsg -r -t get_tree | jq -r 'recurse(.nodes[]) | first(select(.name=="__i3_scratch")) | .floating_nodes | length')"
+
+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="Scratchpad\n\n"
+tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')"
+tooltip=''${tooltip::-2}
+
+echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}"
+exit 0
+''