at master 2.1 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 cfg = config.services.dwm-status; 9 10 format = pkgs.formats.toml { }; 11 12 configFile = format.generate "dwm-status.toml" cfg.settings; 13in 14 15{ 16 imports = [ 17 (lib.mkRenamedOptionModule 18 [ "services" "dwm-status" "order" ] 19 [ "services" "dwm-status" "settings" "order" ] 20 ) 21 (lib.mkRemovedOptionModule [ 22 "services" 23 "dwm-status" 24 "extraConfig" 25 ] "Use services.dwm-status.settings instead.") 26 ]; 27 28 options = { 29 services.dwm-status = { 30 enable = lib.mkEnableOption "dwm-status user service"; 31 32 package = lib.mkPackageOption pkgs "dwm-status" { 33 example = "dwm-status.override { enableAlsaUtils = false; }"; 34 }; 35 36 settings = lib.mkOption { 37 type = lib.types.submodule { 38 freeformType = format.type; 39 options.order = lib.mkOption { 40 type = lib.types.listOf ( 41 lib.types.enum [ 42 "audio" 43 "backlight" 44 "battery" 45 "cpu_load" 46 "network" 47 "time" 48 ] 49 ); 50 default = [ ]; 51 description = '' 52 List of enabled features in order. 53 ''; 54 }; 55 }; 56 default = { }; 57 example = { 58 order = [ 59 "battery" 60 "cpu_load" 61 "time" 62 ]; 63 time = { 64 format = "%F %a %r"; 65 update_seconds = true; 66 }; 67 }; 68 description = '' 69 Config options for dwm-status, see <https://github.com/Gerschtli/dwm-status#configuration> 70 for available options. 71 ''; 72 }; 73 }; 74 }; 75 76 config = lib.mkIf cfg.enable { 77 services.upower.enable = lib.mkIf (lib.elem "battery" cfg.settings.order) true; 78 79 systemd.user.services.dwm-status = { 80 description = "Highly performant and configurable DWM status service"; 81 wantedBy = [ "graphical-session.target" ]; 82 partOf = [ "graphical-session.target" ]; 83 serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile} --quiet"; 84 }; 85 }; 86}