swayosd: add module

This commit is contained in:
Anton Plotnikov 2023-07-07 10:15:43 +02:00 committed by Robert Helgesson
parent 069d450b6d
commit 98282a481d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
6 changed files with 104 additions and 0 deletions

View file

@ -1157,6 +1157,14 @@ in
A new module is available: 'programs.pyenv'.
'';
}
{
time = "2023-07-08T09:44:56+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.swayosd'
'';
}
];
};
}

View file

@ -312,6 +312,7 @@ let
./services/stalonetray.nix
./services/status-notifier-watcher.nix
./services/swayidle.nix
./services/swayosd.nix
./services/sxhkd.nix
./services/syncthing.nix
./services/systembus-notify.nix

View file

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.swayosd;
in {
meta.maintainers = [ hm.maintainers.pltanton ];
options.services.swayosd = {
enable = mkEnableOption ''
swayosd, a GTK based on screen display for keyboard shortcuts like
caps-lock and volume'';
package = mkPackageOption pkgs "swayosd" { };
maxVolume = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 120;
description = ''
Sets the maximum volume.
'';
};
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "services.swayosd" pkgs platforms.linux)
];
home.packages = [ cfg.package ];
systemd.user = {
services.swayosd = {
Unit = {
Description = "Volume/backlight OSD indicator";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
ConditionEnvironment = "WAYLAND_DISPLAY";
Documentation = "man:swayosd(1)";
};
Service = {
Type = "simple";
ExecStart = "${cfg.package}/bin/swayosd"
+ (optionalString (cfg.maxVolume != null)
" --max-volume ${toString cfg.maxVolume}");
Restart = "always";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
};
}

View file

@ -222,6 +222,7 @@ import nmt {
./modules/services/redshift-gammastep
./modules/services/screen-locker
./modules/services/swayidle
./modules/services/swayosd
./modules/services/sxhkd
./modules/services/syncthing/linux
./modules/services/trayer

View file

@ -0,0 +1 @@
{ swayosd = ./swayosd.nix; }

View file

@ -0,0 +1,35 @@
{ config, ... }:
{
services.swayosd = {
enable = true;
package = config.lib.test.mkStubPackage {
name = "swayosd";
outPath = "@swayosd@";
};
maxVolume = 10;
};
nmt.script = ''
assertFileContent \
home-files/.config/systemd/user/swayosd.service \
${
builtins.toFile "swayosd.service" ''
[Install]
WantedBy=graphical-session.target
[Service]
ExecStart=@swayosd@/bin/swayosd --max-volume 10
Restart=always
Type=simple
[Unit]
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=Volume/backlight OSD indicator
Documentation=man:swayosd(1)
PartOf=graphical-session.target
''
}
'';
}