diff options
author | Tobias Happ <tobias.happ@gmx.de> | 2019-08-10 16:57:19 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-08-18 16:23:31 +0200 |
commit | db0dfb4b089d0f5ba86ab39b40a228ae47c5d440 (patch) | |
tree | 6e3dcf72d677936683ee7842fc8c04d0aab74f82 /modules/services/dwm-status.nix | |
parent | 5eed33ef087f9267c956e902861168616a47ca74 (diff) |
dwm-status: add module
Diffstat (limited to 'modules/services/dwm-status.nix')
-rw-r--r-- | modules/services/dwm-status.nix | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/modules/services/dwm-status.nix b/modules/services/dwm-status.nix new file mode 100644 index 00000000000..6b6a8cbdaa6 --- /dev/null +++ b/modules/services/dwm-status.nix @@ -0,0 +1,70 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.dwm-status; + + features = [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]; + + configText = builtins.toJSON ({ inherit (cfg) order; } // cfg.extraConfig); + + configFile = pkgs.writeText "dwm-status.json" configText; +in + +{ + options = { + services.dwm-status = { + enable = mkEnableOption "dwm-status user service"; + + package = mkOption { + type = types.package; + default = pkgs.dwm-status; + defaultText = "pkgs.dwm-status"; + example = "pkgs.dwm-status.override { enableAlsaUtils = false; }"; + description = "Which dwm-status package to use."; + }; + + order = mkOption { + type = types.listOf (types.enum features); + description = "List of enabled features in order."; + }; + + extraConfig = mkOption { + type = types.attrs; + default = {}; + example = literalExample '' + { + separator = "#"; + + battery = { + notifier_levels = [ 2 5 10 15 20 ]; + }; + + time = { + format = "%H:%M"; + }; + } + ''; + description = "Extra config of dwm-status."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.dwm-status = { + Unit = { + Description = "DWM status service"; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/dwm-status ${configFile}"; + }; + }; + }; +} |