mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 15:09:46 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
124 lines
3.5 KiB
Nix
124 lines
3.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.cbatticon;
|
|
|
|
package = pkgs.cbatticon;
|
|
|
|
makeCommand = commandName: commandArg:
|
|
optional (commandArg != null)
|
|
(let cmd = pkgs.writeShellScript commandName commandArg;
|
|
in "--${commandName} ${cmd}");
|
|
|
|
commandLine = concatStringsSep " " ([ "${package}/bin/cbatticon" ]
|
|
++ makeCommand "command-critical-level" cfg.commandCriticalLevel
|
|
++ makeCommand "command-left-click" cfg.commandLeftClick
|
|
++ optional (cfg.iconType != null) "--icon-type ${cfg.iconType}"
|
|
++ optional (cfg.lowLevelPercent != null)
|
|
"--low-level ${toString cfg.lowLevelPercent}"
|
|
++ optional (cfg.criticalLevelPercent != null)
|
|
"--critical-level ${toString cfg.criticalLevelPercent}"
|
|
++ optional (cfg.updateIntervalSeconds != null)
|
|
"--update-interval ${toString cfg.updateIntervalSeconds}"
|
|
++ optional (cfg.hideNotification != null && cfg.hideNotification)
|
|
"--hide-notification");
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.pmiddend ];
|
|
|
|
options = {
|
|
services.cbatticon = {
|
|
enable = mkEnableOption (lib.mdDoc "cbatticon");
|
|
|
|
commandCriticalLevel = mkOption {
|
|
type = types.nullOr types.lines;
|
|
default = null;
|
|
example = ''
|
|
notify-send "battery critical!"
|
|
'';
|
|
description = lib.mdDoc ''
|
|
Command to execute when the critical battery level is reached.
|
|
'';
|
|
};
|
|
|
|
commandLeftClick = mkOption {
|
|
type = types.nullOr types.lines;
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Command to execute when left clicking on the tray icon.
|
|
'';
|
|
};
|
|
|
|
iconType = mkOption {
|
|
type =
|
|
types.nullOr (types.enum [ "standard" "notification" "symbolic" ]);
|
|
default = null;
|
|
example = "symbolic";
|
|
description = lib.mdDoc "Icon type to display in the system tray.";
|
|
};
|
|
|
|
lowLevelPercent = mkOption {
|
|
type = types.nullOr (types.ints.between 0 100);
|
|
default = null;
|
|
example = 20;
|
|
description = lib.mdDoc ''
|
|
Low level percentage of the battery in percent (without the
|
|
percent symbol).
|
|
'';
|
|
};
|
|
|
|
criticalLevelPercent = mkOption {
|
|
type = types.nullOr (types.ints.between 0 100);
|
|
default = null;
|
|
example = 5;
|
|
description = lib.mdDoc ''
|
|
Critical level percentage of the battery in percent (without
|
|
the percent symbol).
|
|
'';
|
|
};
|
|
|
|
updateIntervalSeconds = mkOption {
|
|
type = types.nullOr types.ints.positive;
|
|
default = null;
|
|
example = 5;
|
|
description = lib.mdDoc ''
|
|
Number of seconds between updates of the battery information.
|
|
'';
|
|
};
|
|
|
|
hideNotification = mkOption {
|
|
type = types.nullOr types.bool;
|
|
default = null;
|
|
description = lib.mdDoc "Hide the notification popups.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.cbatticon" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
home.packages = [ package ];
|
|
|
|
systemd.user.services.cbatticon = {
|
|
Unit = {
|
|
Description = "cbatticon system tray battery icon";
|
|
Requires = [ "tray.target" ];
|
|
After = [ "graphical-session-pre.target" "tray.target" ];
|
|
PartOf = [ "graphical-session.target" ];
|
|
};
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
|
|
Service = {
|
|
ExecStart = commandLine;
|
|
Restart = "on-abort";
|
|
};
|
|
};
|
|
};
|
|
}
|