From 13dbf2623d6465d5c4db54ce8a5a630dce79c3e9 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 6 Feb 2024 00:31:53 +0200 Subject: [PATCH] swayosd: update executable --- modules/services/swayosd.nix | 25 ++++++++++++++++------ tests/modules/services/swayosd/swayosd.nix | 5 +++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/modules/services/swayosd.nix b/modules/services/swayosd.nix index 067c104c..51e7eb6d 100644 --- a/modules/services/swayosd.nix +++ b/modules/services/swayosd.nix @@ -16,12 +16,22 @@ in { package = mkPackageOption pkgs "swayosd" { }; - maxVolume = mkOption { - type = types.nullOr types.ints.unsigned; + topMargin = mkOption { + type = types.nullOr (types.addCheck types.float (f: f >= 0.0 && f <= 1.0) + // { + description = "float between 0.0 and 1.0 (inclusive)"; + }); default = null; - example = 120; + example = 1.0; + description = "OSD margin from top edge (0.5 would be screen center)."; + }; + + display = mkOption { + type = types.nullOr types.str; + default = null; + example = "eDP-1"; description = '' - Sets the maximum volume. + X display to use. ''; }; }; @@ -45,9 +55,10 @@ in { Service = { Type = "simple"; - ExecStart = "${cfg.package}/bin/swayosd" - + (optionalString (cfg.maxVolume != null) - " --max-volume ${toString cfg.maxVolume}"); + ExecStart = "${cfg.package}/bin/swayosd-server" + + (optionalString (cfg.display != null) " --display ${cfg.display}") + + (optionalString (cfg.topMargin != null) + " --top-margin ${toString cfg.topMargin}"); Restart = "always"; }; diff --git a/tests/modules/services/swayosd/swayosd.nix b/tests/modules/services/swayosd/swayosd.nix index b371d86a..ba92d81f 100644 --- a/tests/modules/services/swayosd/swayosd.nix +++ b/tests/modules/services/swayosd/swayosd.nix @@ -7,7 +7,8 @@ name = "swayosd"; outPath = "@swayosd@"; }; - maxVolume = 10; + display = "DISPLAY"; + topMargin = 0.1; }; nmt.script = '' @@ -19,7 +20,7 @@ WantedBy=graphical-session.target [Service] - ExecStart=@swayosd@/bin/swayosd --max-volume 10 + ExecStart=@swayosd@/bin/swayosd-server --display DISPLAY --top-margin 0.100000 Restart=always Type=simple