1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-01 16:59:43 +01:00
home-manager/modules/services/trayer.nix

157 lines
3.3 KiB
Nix
Raw Normal View History

2021-07-21 22:43:18 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
boolTrue = {
type = types.bool;
default = true;
2021-07-21 22:43:18 +02:00
};
number0 = {
type = types.int;
default = 0;
2021-07-21 22:43:18 +02:00
};
knownSettings = {
edge = {
type = types.enum [ "left" "right" "top" "bottom" "none" ];
2021-07-21 22:43:18 +02:00
default = "bottom";
};
align = {
type = types.enum [ "left" "right" "center" ];
2021-07-21 22:43:18 +02:00
default = "center";
};
margin = number0;
widthtype = {
type = types.enum [ "request" "pixel" "percent" ];
2021-07-21 22:43:18 +02:00
default = "percent";
};
width = {
type = types.int;
default = 100;
2021-07-21 22:43:18 +02:00
};
heighttype = {
type = types.enum [ "request" "pixel" ];
2021-07-21 22:43:18 +02:00
default = "pixel";
};
height = {
type = types.int;
default = 26;
2021-07-21 22:43:18 +02:00
};
SetDockType = boolTrue;
SetPartialStrut = boolTrue;
transparent = {
type = types.bool;
default = false;
2021-07-21 22:43:18 +02:00
};
alpha = {
type = types.int;
default = 127;
2021-07-21 22:43:18 +02:00
};
tint = {
type = types.str;
default = "0xFFFFFFFF";
};
distance = number0;
distancefrom = {
type = types.enum [ "left" "right" "top" "bottom" ];
2021-07-21 22:43:18 +02:00
default = "top";
};
expand = boolTrue;
padding = number0;
monitor = {
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 {
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";
2021-07-21 22:43:18 +02:00
package = mkOption {
default = pkgs.trayer;
defaultText = literalExpression "pkgs.trayer";
2021-07-21 22:43:18 +02:00
type = types.package;
example = literalExpression "pkgs.trayer";
description = "The package to use for the trayer binary.";
2021-07-21 22:43:18 +02:00
};
settings = mkOption {
type = with types; attrsOf (nullOr (either str (either bool int)));
description = ''
2021-07-21 22:43:18 +02:00
Trayer configuration as a set of attributes. Further details can be
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: ''
{var}`${n}`
: ${v.type.description} (default: `${builtins.toJSON v.default}`)
2021-07-21 22:43:18 +02:00
'') knownSettings)}
'';
default = { };
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";
};
};
});
}