diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 6d3e174ac..6c0f88cbd 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1168,6 +1168,14 @@ in A new module is available: 'services.muchsync'. ''; } + + { + time = "2019-08-18T14:22:41+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.dwm-status'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 05f3bb50b..cc38e9e71 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -98,6 +98,7 @@ let (loadModule ./services/blueman-applet.nix { }) (loadModule ./services/compton.nix { }) (loadModule ./services/dunst.nix { }) + (loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/flameshot.nix { }) (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) diff --git a/modules/services/dwm-status.nix b/modules/services/dwm-status.nix new file mode 100644 index 000000000..6b6a8cbda --- /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}"; + }; + }; + }; +}