swayosd: add custom style option

This commit is contained in:
Sergio Ribera 2024-04-21 02:55:00 -04:00 committed by Robert Helgesson
parent 33a20182e3
commit bfa7c06436
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
2 changed files with 13 additions and 1 deletions

View file

@ -26,6 +26,15 @@ in {
description = "OSD margin from top edge (0.5 would be screen center)."; description = "OSD margin from top edge (0.5 would be screen center).";
}; };
stylePath = mkOption {
type = types.nullOr types.path;
default = null;
example = "/etc/xdg/swayosd/style.css";
description = ''
Use a custom Stylesheet file instead of looking for one.
'';
};
display = mkOption { display = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
@ -57,6 +66,8 @@ in {
Type = "simple"; Type = "simple";
ExecStart = "${cfg.package}/bin/swayosd-server" ExecStart = "${cfg.package}/bin/swayosd-server"
+ (optionalString (cfg.display != null) " --display ${cfg.display}") + (optionalString (cfg.display != null) " --display ${cfg.display}")
+ (optionalString (cfg.stylePath != null)
" --style ${escapeShellArg cfg.stylePath}")
+ (optionalString (cfg.topMargin != null) + (optionalString (cfg.topMargin != null)
" --top-margin ${toString cfg.topMargin}"); " --top-margin ${toString cfg.topMargin}");
Restart = "always"; Restart = "always";

View file

@ -8,6 +8,7 @@
outPath = "@swayosd@"; outPath = "@swayosd@";
}; };
display = "DISPLAY"; display = "DISPLAY";
stylePath = "/etc/xdg/swayosd/style.css";
topMargin = 0.1; topMargin = 0.1;
}; };
@ -20,7 +21,7 @@
WantedBy=graphical-session.target WantedBy=graphical-session.target
[Service] [Service]
ExecStart=@swayosd@/bin/swayosd-server --display DISPLAY --top-margin 0.100000 ExecStart=@swayosd@/bin/swayosd-server --display DISPLAY --style '/etc/xdg/swayosd/style.css' --top-margin 0.100000
Restart=always Restart=always
Type=simple Type=simple