From 79d55b304c7e44e0de5adfe8989edcd9a0b4f126 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Mon, 1 Sep 2025 01:20:43 +0200 Subject: [PATCH] feat(waybar): add a record module to track screen recording --- .../sway/includes/files/waybar-style.css | 14 +++++++ .../desktop/sway/includes/waybar.nix | 38 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/modules/home-manager/desktop/sway/includes/files/waybar-style.css b/modules/home-manager/desktop/sway/includes/files/waybar-style.css index ffc4be3..f7cc59f 100644 --- a/modules/home-manager/desktop/sway/includes/files/waybar-style.css +++ b/modules/home-manager/desktop/sway/includes/files/waybar-style.css @@ -117,3 +117,17 @@ button:hover{ font-family: "DejaVu sans"; font-size: 12px; } +#custom-screenrecord { + color: @color-critical; + border-bottom: 1px solid @color-critical; + animation-name: critical-animation; + animation-duration: 2s; + animation-timing-function: ease-in-out; + animation-direction: alternate; + animation-iteration-count: infinite; +} + +@keyframes critical-animation { + from {color: @color-critical;} + to {color: white;} +} diff --git a/modules/home-manager/desktop/sway/includes/waybar.nix b/modules/home-manager/desktop/sway/includes/waybar.nix index f9c2e6a..85641fa 100644 --- a/modules/home-manager/desktop/sway/includes/waybar.nix +++ b/modules/home-manager/desktop/sway/includes/waybar.nix @@ -1,4 +1,4 @@ -{lib, config, ...}: +{lib, config, pkgs, ...}: with lib; let cfg = config.modules.desktop.sway; @@ -16,7 +16,9 @@ in layer = "top"; spacing = 6; disable-toolptips = true; - modules-center = []; + modules-center = [ + "custom/screenrecord" + ]; modules-left = [ "sway/workspaces" "sway/mode" @@ -53,6 +55,7 @@ in "custom/sep" "clock" "custom/sep" + "privacy" "tray" ]; "clock" = { @@ -73,6 +76,14 @@ in "format" = "|"; "tooltip" = false; }; + "custom/screenrecord" = { + "format" = "  [rec.] "; + "interval" = 1; + "exec" = "echo '{\"class\": \"recording\"}'"; + "exec-if" = "${pkgs.procps}/bin/pgrep wl-screenrec"; + "on-click" = "exec ${pkgs.coreutils}/bin/kill -s SIGINT $(${pkgs.procps}/bin/pgrep wl-screenrec)"; + "tooltype" = false; + }; "idle_inhibitor" = { "format" = "{icon}"; "format-icons" = { @@ -96,6 +107,29 @@ in "format-wifi" = "{essid} ({signalStrength}%) "; "tooltip" = false; }; + "privacy"= { + "icon-spacing" = 4; + "icon-size" = 10; + "transition-duration" = 250; + "modules"= [ + { + "type" = "screenshare"; + "tooltip" = true; + "tooltip-icon-size" = 16; + } + { + "type" = "audio-out"; + "tooltip" = true; + "tooltip-icon-size" = 24; + } + { + "type" = "audio-in"; + "tooltip" = true; + "tooltip-icon-size" = 24; + } + ]; + "ignore-monitor" = true; + }; "pulseaudio#output" = { "format" = "{volume}% {icon} "; "format-bluetooth" = "{volume}% {icon}";