From 0c97e9f3f656675384d39b2b9f33c027b1a6988b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 29 Apr 2024 11:51:25 +0200 Subject: [PATCH] Improve flakestat --- home/hyprland/waybar/default.nix | 12 ++++-------- home/hyprland/waybar/flakestat.sh | 13 ++++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/home/hyprland/waybar/default.nix b/home/hyprland/waybar/default.nix index e1e2bac..7ade5c7 100644 --- a/home/hyprland/waybar/default.nix +++ b/home/hyprland/waybar/default.nix @@ -172,12 +172,11 @@ in ({ "layer" = "top"; "position" = "top"; - modules-left = [ "custom/launcher" "hyprland/workspaces" ]; + modules-left = [ "custom/flakestat" "hyprland/workspaces" ]; modules-center = [ "clock" ]; modules-right = [ (lib.mkIf (withArrhist) "custom/arrhist") - "custom/flakestat" "pulseaudio" "pulseaudio#microphone" "memory" @@ -185,11 +184,6 @@ in "tray" (lib.mkIf (withBattery) "battery") ]; - "custom/launcher" = { - "format" = " "; - "on-click" = "pkill rofi || ~/.config/rofi/launcher.sh"; - "tooltip" = false; - }; "hyprland/workspaces" = { "format" = "{name}"; "on-click" = "activate"; @@ -248,13 +242,15 @@ in }; "custom/flakestat" = { "exec" = "${flakestat}/bin/flakestat"; + "format" = " {}"; + "return-type" = "json"; "interval" = 600; }; } // lib.optionalAttrs (withArrhist) { "custom/arrhist" = { "exec" = "${arrhist}/bin/arrhist"; "return-type" = "json"; - "interval" = 30; + "interval" = 600; }; }) ]; diff --git a/home/hyprland/waybar/flakestat.sh b/home/hyprland/waybar/flakestat.sh index 4538521..7e699ef 100644 --- a/home/hyprland/waybar/flakestat.sh +++ b/home/hyprland/waybar/flakestat.sh @@ -18,4 +18,15 @@ git fetch -q --all stable_commit_count=$(git rev-list --count "$stable_rev..origin/$stable_branch") unstable_commit_count=$(git rev-list --count "$unstable_rev..origin/$unstable_branch") -echo "$stable_commit_count|$unstable_commit_count" +text="$stable_commit_count|$unstable_commit_count" +tooltip="${stable_branch}: ${stable_commit_count} +${unstable_branch}: ${unstable_commit_count}" + +output=$(jq -n \ + --arg text "$text" \ + --arg tooltip "$tooltip" \ + --unbuffered \ + --compact-output \ + '{text: $text, tooltip: $tooltip}') + +echo "$output"