2023-07-07 08:15:43 +00:00
|
|
|
{ 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" { };
|
|
|
|
|
2024-02-05 22:31:53 +00:00
|
|
|
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)";
|
|
|
|
});
|
2023-07-07 08:15:43 +00:00
|
|
|
default = null;
|
2024-02-05 22:31:53 +00:00
|
|
|
example = 1.0;
|
|
|
|
description = "OSD margin from top edge (0.5 would be screen center).";
|
|
|
|
};
|
|
|
|
|
2024-04-21 06:55:00 +00:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-02-05 22:31:53 +00:00
|
|
|
display = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "eDP-1";
|
2023-07-07 08:15:43 +00:00
|
|
|
description = ''
|
2024-02-05 22:31:53 +00:00
|
|
|
X display to use.
|
2023-07-07 08:15:43 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
2024-02-05 22:31:53 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/swayosd-server"
|
|
|
|
+ (optionalString (cfg.display != null) " --display ${cfg.display}")
|
2024-04-21 06:55:00 +00:00
|
|
|
+ (optionalString (cfg.stylePath != null)
|
|
|
|
" --style ${escapeShellArg cfg.stylePath}")
|
2024-02-05 22:31:53 +00:00
|
|
|
+ (optionalString (cfg.topMargin != null)
|
|
|
|
" --top-margin ${toString cfg.topMargin}");
|
2023-07-07 08:15:43 +00:00
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|