2021-07-21 22:43:18 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
boolTrue = {
|
|
|
|
type = types.bool;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = true;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
number0 = {
|
|
|
|
type = types.int;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = 0;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
knownSettings = {
|
|
|
|
edge = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.enum [ "left" "right" "top" "bottom" "none" ];
|
2021-07-21 22:43:18 +02:00
|
|
|
default = "bottom";
|
|
|
|
};
|
|
|
|
|
|
|
|
align = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.enum [ "left" "right" "center" ];
|
2021-07-21 22:43:18 +02:00
|
|
|
default = "center";
|
|
|
|
};
|
|
|
|
|
|
|
|
margin = number0;
|
|
|
|
widthtype = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.enum [ "request" "pixel" "percent" ];
|
2021-07-21 22:43:18 +02:00
|
|
|
default = "percent";
|
|
|
|
};
|
|
|
|
|
|
|
|
width = {
|
|
|
|
type = types.int;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = 100;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
heighttype = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.enum [ "request" "pixel" ];
|
2021-07-21 22:43:18 +02:00
|
|
|
default = "pixel";
|
|
|
|
};
|
|
|
|
|
|
|
|
height = {
|
|
|
|
type = types.int;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = 26;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
SetDockType = boolTrue;
|
|
|
|
|
|
|
|
SetPartialStrut = boolTrue;
|
|
|
|
|
|
|
|
transparent = {
|
|
|
|
type = types.bool;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = false;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
alpha = {
|
|
|
|
type = types.int;
|
2023-07-01 08:14:03 +02:00
|
|
|
default = 127;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
tint = {
|
|
|
|
type = types.str;
|
|
|
|
default = "0xFFFFFFFF";
|
|
|
|
};
|
|
|
|
|
|
|
|
distance = number0;
|
|
|
|
|
|
|
|
distancefrom = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.enum [ "left" "right" "top" "bottom" ];
|
2021-07-21 22:43:18 +02:00
|
|
|
default = "top";
|
|
|
|
};
|
|
|
|
|
|
|
|
expand = boolTrue;
|
|
|
|
|
|
|
|
padding = number0;
|
|
|
|
|
|
|
|
monitor = {
|
2023-07-01 08:14:03 +02:00
|
|
|
type = types.either types.ints.unsigned (types.enum [ "primary" ]);
|
|
|
|
default = 0;
|
2021-07-21 22:43:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
iconspacing = number0;
|
|
|
|
};
|
|
|
|
|
|
|
|
cfg = config.services.trayer;
|
|
|
|
|
|
|
|
in {
|
2021-12-25 19:43:19 +01:00
|
|
|
meta.maintainers = [ hm.maintainers.mager ];
|
2021-07-21 22:43:18 +02:00
|
|
|
|
|
|
|
options = {
|
|
|
|
services.trayer = {
|
|
|
|
enable = mkEnableOption
|
|
|
|
"trayer, the lightweight GTK2+ systray for UNIX desktops";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.trayer;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.trayer";
|
2021-07-21 22:43:18 +02:00
|
|
|
type = types.package;
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression "pkgs.trayer";
|
2021-07-21 22:43:18 +02:00
|
|
|
description = "The package to use for the trayer binary.";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = with types; attrsOf (nullOr (either str (either bool int)));
|
2023-07-01 08:14:03 +02:00
|
|
|
description = lib.mdDoc ''
|
2021-07-21 22:43:18 +02:00
|
|
|
Trayer configuration as a set of attributes. Further details can be
|
2023-07-01 08:14:03 +02:00
|
|
|
found in [trayer's README](https://github.com/sargon/trayer-srg/blob/master/README).
|
|
|
|
|
2021-07-21 22:43:18 +02:00
|
|
|
${concatStringsSep "\n" (mapAttrsToList (n: v: ''
|
2023-07-01 08:14:03 +02:00
|
|
|
{var}`${n}`
|
|
|
|
: ${v.type.description} (default: `${builtins.toJSON v.default}`)
|
2021-07-21 22:43:18 +02:00
|
|
|
'') knownSettings)}
|
|
|
|
'';
|
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-07-21 22:43:18 +02:00
|
|
|
{
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|