From c5a4bfa5f2d95ebffb79ab17580040588a498b32 Mon Sep 17 00:00:00 2001 From: oddlama Date: Thu, 20 Jun 2024 17:46:19 +0200 Subject: [PATCH] chore: don't use systemd to start swaync and waybar to get restart support --- users/myuser/graphical/hyprland.nix | 7 +++++++ users/myuser/graphical/swaync.nix | 3 +++ users/myuser/graphical/waybar.nix | 25 +++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/users/myuser/graphical/hyprland.nix b/users/myuser/graphical/hyprland.nix index b9d4014..b3665e5 100644 --- a/users/myuser/graphical/hyprland.nix +++ b/users/myuser/graphical/hyprland.nix @@ -117,6 +117,13 @@ in { }; decoration.rounding = 4; + exec-once = [ + "${pkgs.waybar}/bin/waybar" + "${pkgs.swaynotificationcenter}/bin/swaync" + "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP" + "systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP" + "systemctl --user restart xdg-desktop-portal.service" + ]; input = { kb_layout = "de"; diff --git a/users/myuser/graphical/swaync.nix b/users/myuser/graphical/swaync.nix index 2778fe0..c95b907 100644 --- a/users/myuser/graphical/swaync.nix +++ b/users/myuser/graphical/swaync.nix @@ -86,4 +86,7 @@ ) + (builtins.readFile ./swaync-style.css); }; + + # Started via hyprland to ensure it restarts properly with hyprland + systemd.user.services.swaync.Install.WantedBy = lib.mkForce []; } diff --git a/users/myuser/graphical/waybar.nix b/users/myuser/graphical/waybar.nix index 0de4f47..6174dca 100644 --- a/users/myuser/graphical/waybar.nix +++ b/users/myuser/graphical/waybar.nix @@ -5,7 +5,8 @@ }: { programs.waybar = { enable = true; - systemd.enable = true; + # Started via hyprland to ensure it restarts properly with hyprland + systemd.enable = false; style = builtins.readFile ./waybar-style.css; settings.main = { layer = "top"; @@ -17,6 +18,7 @@ "tray" "hyprland/submap" "privacy" + "custom/whisper_overlay" ]; modules-center = [ "hyprland/window" @@ -88,6 +90,25 @@ escape = true; }; + "custom/whisper_overlay" = { + tooltip = true; + format = "{icon}"; + format-icons = { + disconnected = ""; + connected = ""; + connected-active = ""; + }; + return-type = "json"; + exec = "${lib.getExe pkgs.whisper-overlay} waybar-status --address localhost:43007"; + on-click-right = lib.getExe (pkgs.writeShellApplication { + name = "toggle-realtime-stt-server"; + runtimeInputs = []; + text = '' + ''; + }); + escape = true; + }; + privacy = { icon-spacing = 4; icon-size = 18; @@ -115,7 +136,7 @@ format = "{icon} {volume}%"; format-muted = " {volume}%"; format-icons = ["" ""]; - on-click = "hyprctl dispatch exec \"[float;pin;move 80% 50%;size 20% 50%;noborder]\" ${lib.getExe pkgs.pwvucontrol}"; + on-click = "${pkgs.hyprland}/bin/hyprctl dispatch exec \"[float;pin;move 80% 50%;size 20% 50%;noborder]\" ${lib.getExe pkgs.pwvucontrol}"; on-click-middle = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 100%"; on-click-right = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; };