diff --git a/modules/desktop/graphics/ewwbar.nix b/modules/desktop/graphics/ewwbar.nix index 127ed09cf..ad87753bd 100644 --- a/modules/desktop/graphics/ewwbar.nix +++ b/modules/desktop/graphics/ewwbar.nix @@ -115,6 +115,7 @@ in description = "ewwbar"; serviceConfig = { Type = "forking"; + ExecCondition = "${pkgs.wlr-randr}/bin/wlr-randr > /dev/null 2>&1"; ExecStart = "${ewwScripts.ewwbar-ctrl}/bin/ewwbar-ctrl start"; ExecReload = "${ewwScripts.ewwbar-ctrl}/bin/ewwbar-ctrl reload"; ExecStopPost = '' @@ -143,16 +144,7 @@ in }; after = [ "ewwbar.service" ]; wantedBy = [ "ewwbar.service" ]; - partOf = [ "ghaf-session.target" ]; - }; - - eww-display-trigger = { - description = "eww-display-trigger"; - serviceConfig = { - Type = "oneshot"; - ExecStart = "${pkgs.bash}/bin/bash -c 'echo 1 > ~/.config/eww/display'"; - }; - after = [ "ewwbar.service" ]; + partOf = [ "ewwbar.service" ]; }; eww-display-handler = { @@ -164,7 +156,7 @@ in }; after = [ "ewwbar.service" ]; wantedBy = [ "ewwbar.service" ]; - partOf = [ "ghaf-session.target" ]; + partOf = [ "ewwbar.service" ]; }; eww-volume-popup = { @@ -182,7 +174,7 @@ in }; after = [ "ewwbar.service" ]; wantedBy = [ "ewwbar.service" ]; - partOf = [ "ghaf-session.target" ]; + partOf = [ "ewwbar.service" ]; }; eww-workspace-popup = { @@ -200,7 +192,7 @@ in }; after = [ "ewwbar.service" ]; wantedBy = [ "ewwbar.service" ]; - partOf = [ "ghaf-session.target" ]; + partOf = [ "ewwbar.service" ]; }; eww-fullscreen-update = { @@ -212,7 +204,7 @@ in }; after = [ "ewwbar.service" ]; wantedBy = [ "ewwbar.service" ]; - partOf = [ "ghaf-session.target" ]; + partOf = [ "ewwbar.service" ]; }; }; diff --git a/modules/desktop/graphics/ewwbar/config/scripts/default.nix b/modules/desktop/graphics/ewwbar/config/scripts/default.nix index 1be33c88f..904116173 100644 --- a/modules/desktop/graphics/ewwbar/config/scripts/default.nix +++ b/modules/desktop/graphics/ewwbar/config/scripts/default.nix @@ -84,7 +84,11 @@ let text = '' start() { # Get the number of connected displays using wlr-randr and parse the output with jq - wlr_randr_output=$(wlr-randr --json) + + if ! wlr_randr_output=$(wlr-randr --json); then + echo "Error: Failed to get display info from wlr-randr" + exit 1 + fi displays=$(echo "$wlr_randr_output" | jq 'length') # Check if there are any connected displays @@ -120,7 +124,12 @@ let reload() { #${ewwCmd} reload ${ewwCmd} close-all - open-bars "$(wlr-randr --json)" + if ! wlr_randr_output=$(wlr-randr --json); then + echo "Error: Failed to get display info from wlr-randr" + exit 1 + fi + + open-bars "$wlr_randr_output" } update-vars() { diff --git a/modules/desktop/graphics/labwc.config.nix b/modules/desktop/graphics/labwc.config.nix index 948e5b848..52ed63569 100644 --- a/modules/desktop/graphics/labwc.config.nix +++ b/modules/desktop/graphics/labwc.config.nix @@ -422,12 +422,26 @@ let display-event-trigger = pkgs.writeShellApplication { name = "display-event-trigger"; - runtimeInputs = [ ]; + runtimeInputs = [ + auto-display-scale + pkgs.mako + pkgs.wlr-randr + ]; bashOptions = [ ]; text = '' # Run the following commands in order every time a display change event is detected - ${auto-display-scale}/bin/auto-display-scale # Auto scaling - ${pkgs.mako}/bin/makoctl set-mode default # Reset mako mode so notifications don't break + auto-display-scale # Auto scaling + makoctl set-mode default # Reset mako mode so notifications don't break + + if wlr-randr > /dev/null 2>&1; then + # If displays are connected (not headless mode), ensure ewwbar and ghaf-launcher are running + systemctl --user is-active --quiet ewwbar || systemctl --user reload-or-restart ewwbar + systemctl --user is-active --quiet ghaf-launcher || systemctl --user reload-or-restart ghaf-launcher + else + # If all displays were disconnected, we can stop ghaf-launcher and ewwbar services + echo "No displays connected. Stopping ghaf-launcher and ewwbar services" + systemctl --user stop ewwbar ghaf-launcher + fi ''; }; in @@ -487,6 +501,7 @@ in serviceConfig = { Type = "simple"; EnvironmentFile = "-/etc/locale.conf"; + ExecCondition = "${pkgs.wlr-randr}/bin/wlr-randr > /dev/null 2>&1"; ExecStart = "${pkgs.nwg-drawer}/bin/nwg-drawer -r -nofs -nocats -s ${drawerStyle}"; Restart = "always"; RestartSec = "1";