2021-11-04 16:42:44 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
boolTrue = {
|
|
|
|
type = types.bool;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = true;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
number0 = {
|
|
|
|
type = types.int;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = 0;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
knownSettings = {
|
|
|
|
edge = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.enum [ "left" "right" "top" "bottom" "none" ];
|
2021-11-04 16:42:44 +00:00
|
|
|
default = "bottom";
|
|
|
|
};
|
|
|
|
|
|
|
|
align = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.enum [ "left" "right" "center" ];
|
2021-11-04 16:42:44 +00:00
|
|
|
default = "center";
|
|
|
|
};
|
|
|
|
|
|
|
|
margin = number0;
|
|
|
|
widthtype = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.enum [ "request" "pixel" "percent" ];
|
2021-11-04 16:42:44 +00:00
|
|
|
default = "percent";
|
|
|
|
};
|
|
|
|
|
|
|
|
width = {
|
|
|
|
type = types.int;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = 100;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
heighttype = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.enum [ "request" "pixel" ];
|
2021-11-04 16:42:44 +00:00
|
|
|
default = "pixel";
|
|
|
|
};
|
|
|
|
|
|
|
|
height = {
|
|
|
|
type = types.int;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = 26;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SetDockType = boolTrue;
|
|
|
|
|
|
|
|
SetPartialStrut = boolTrue;
|
|
|
|
|
|
|
|
transparent = {
|
|
|
|
type = types.bool;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = false;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
alpha = {
|
|
|
|
type = types.int;
|
2023-08-08 10:19:01 +00:00
|
|
|
default = 127;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
tint = {
|
|
|
|
type = types.str;
|
|
|
|
default = "0xFFFFFFFF";
|
|
|
|
};
|
|
|
|
|
|
|
|
distance = number0;
|
|
|
|
|
|
|
|
distancefrom = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.enum [ "left" "right" "top" "bottom" ];
|
2021-11-04 16:42:44 +00:00
|
|
|
default = "top";
|
|
|
|
};
|
|
|
|
|
|
|
|
expand = boolTrue;
|
|
|
|
|
|
|
|
padding = number0;
|
|
|
|
|
|
|
|
monitor = {
|
2023-08-08 10:19:01 +00:00
|
|
|
type = types.either types.ints.unsigned (types.enum [ "primary" ]);
|
|
|
|
default = 0;
|
2021-11-04 16:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
iconspacing = number0;
|
|
|
|
};
|
|
|
|
|
|
|
|
cfg = config.services.trayer;
|
|
|
|
|
|
|
|
in {
|
2023-01-10 09:35:00 +00:00
|
|
|
meta.maintainers = [ hm.maintainers.mager ];
|
2021-11-04 16:42:44 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
services.trayer = {
|
|
|
|
enable = mkEnableOption
|
|
|
|
"trayer, the lightweight GTK2+ systray for UNIX desktops";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.trayer;
|
|
|
|
defaultText = literalExpression "pkgs.trayer";
|
|
|
|
type = types.package;
|
|
|
|
example = literalExpression "pkgs.trayer";
|
|
|
|
description = "The package to use for the trayer binary.";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types; attrsOf (nullOr (either str (either bool int)));
|
|
|
|
description = ''
|
|
|
|
Trayer configuration as a set of attributes. Further details can be
|
2023-08-08 10:19:01 +00:00
|
|
|
found in [trayer's README](https://github.com/sargon/trayer-srg/blob/master/README).
|
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList (n: v: ''
|
2023-08-08 10:19:01 +00:00
|
|
|
{var}`${n}`
|
|
|
|
: ${v.type.description} (default: `${builtins.toJSON v.default}`)
|
2021-11-04 16:42:44 +00:00
|
|
|
'') knownSettings)}
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
edge = "top";
|
|
|
|
padding = 6;
|
|
|
|
SetDockType = true;
|
|
|
|
tint = "0x282c34";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable ({
|
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.trayer" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
systemd.user.services.trayer = let
|
|
|
|
valueToString = v:
|
|
|
|
if isBool v then (if v then "true" else "false") else "${toString v}";
|
|
|
|
parameter = k: v: "--${k} ${valueToString v}";
|
|
|
|
parameters = concatStringsSep " " (mapAttrsToList parameter cfg.settings);
|
|
|
|
in {
|
|
|
|
Unit = {
|
|
|
|
Description = "trayer -- lightweight GTK2+ systray for UNIX desktops";
|
|
|
|
PartOf = [ "tray.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "tray.target" ];
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${cfg.package}/bin/trayer ${parameters}";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|