From 2138b4624eae088a81852f50b3a8f50fc0431a10 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 29 Nov 2024 18:51:52 +0100 Subject: refactor(modules/legacy/conf/yambar): Move to `by-name` and modernize --- modules/by-name/ya/yambar/module.nix | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 modules/by-name/ya/yambar/module.nix (limited to 'modules/by-name/ya/yambar/module.nix') diff --git a/modules/by-name/ya/yambar/module.nix b/modules/by-name/ya/yambar/module.nix new file mode 100644 index 00000000..2f6ea22f --- /dev/null +++ b/modules/by-name/ya/yambar/module.nix @@ -0,0 +1,65 @@ +{ + config, + sysLib, + pkgs, + lib, + ... +}: let + cfg = config.soispha.programs.yambar; + + makeScript = { + name, + dependencies, + ... + }: + sysLib.writeShellScript { + inherit name; + src = ./scripts/${name}.sh; + dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash;}); + } + + "/bin/${name}"; +in { + options.soispha.programs.yambar = { + enable = lib.mkEnableOption "yambar"; + + laptop = lib.mkEnableOption "laptop specific settings"; + backlight = lib.mkOption { + type = lib.types.str; + example = "intel_backlight"; + description = "Which backlight to query for the screen brightness"; + }; + }; + + config = lib.mkIf cfg.enable { + home-manager.users.soispha = { + programs.yambar = { + enable = true; + settings = import ./settings { + inherit lib; + inherit (cfg) laptop; + laptopBacklightName = cfg.backlight; + scripts = { + mpd_song_name_script = makeScript { + dependencies = [pkgs.mpc]; + name = "mpd_song_name"; + }; + + volume_script = makeScript { + dependencies = with pkgs; [pulseaudio gawk coreutils]; + name = "sound-volume"; + }; + + cpu_script = "${lib.getExe pkgs.yambar-modules} cpu"; + + memory_script = "${lib.getExe pkgs.yambar-modules} memory"; + + disk_script = makeScript { + dependencies = with pkgs; [gawk btrfs-progs coreutils]; + name = "disk"; + }; + }; + }; + }; + }; + }; +} -- cgit 1.4.1