Skip to content

Commit

Permalink
Reduce journal log flood in headless mode
Browse files Browse the repository at this point in the history
Signed-off-by: Kajus Naujokaitis <[email protected]>
  • Loading branch information
kajusnau committed Feb 17, 2025
1 parent 8084a07 commit aeca49e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
20 changes: 6 additions & 14 deletions modules/desktop/graphics/ewwbar.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Restart = "always";
Expand All @@ -140,16 +141,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 = {
Expand All @@ -161,7 +153,7 @@ in
};
after = [ "ewwbar.service" ];
wantedBy = [ "ewwbar.service" ];
partOf = [ "ghaf-session.target" ];
partOf = [ "ewwbar.service" ];
};

eww-volume-popup = {
Expand All @@ -179,7 +171,7 @@ in
};
after = [ "ewwbar.service" ];
wantedBy = [ "ewwbar.service" ];
partOf = [ "ghaf-session.target" ];
partOf = [ "ewwbar.service" ];
};

eww-workspace-popup = {
Expand All @@ -197,7 +189,7 @@ in
};
after = [ "ewwbar.service" ];
wantedBy = [ "ewwbar.service" ];
partOf = [ "ghaf-session.target" ];
partOf = [ "ewwbar.service" ];
};

eww-fullscreen-update = {
Expand All @@ -209,7 +201,7 @@ in
};
after = [ "ewwbar.service" ];
wantedBy = [ "ewwbar.service" ];
partOf = [ "ghaf-session.target" ];
partOf = [ "ewwbar.service" ];
};

};
Expand Down
13 changes: 11 additions & 2 deletions modules/desktop/graphics/ewwbar/config/scripts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
21 changes: 18 additions & 3 deletions modules/desktop/graphics/labwc.config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,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
Expand Down Expand Up @@ -457,6 +471,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";
Expand Down

0 comments on commit aeca49e

Please sign in to comment.