From 4429e050649adc6733552021cbcd1f88f591d97d Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Tue, 23 Jul 2024 20:42:51 +0200 Subject: [PATCH] feat: add mako program --- home/modules/profiles/desktop/dwl/default.nix | 43 ++++++++++ .../profiles/desktop/dwl/mako-hm-impl.nix | 15 ++++ home/modules/profiles/desktop/dwl/mako.nix | 84 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 home/modules/profiles/desktop/dwl/mako-hm-impl.nix create mode 100644 home/modules/profiles/desktop/dwl/mako.nix diff --git a/home/modules/profiles/desktop/dwl/default.nix b/home/modules/profiles/desktop/dwl/default.nix index e67cb30..e812a3a 100644 --- a/home/modules/profiles/desktop/dwl/default.nix +++ b/home/modules/profiles/desktop/dwl/default.nix @@ -20,6 +20,8 @@ let wlopmEnableScreens = wlopmScreens "on"; in { imports = [ + ./mako.nix + ./mako-hm-impl.nix ]; options = { @@ -112,6 +114,46 @@ in { }; }; + rutherther.programs.mako = { + enable = true; + + config = with config.themes.default; { + default = { + font = "Ubuntu Mono 10"; + text-color = "#${foreground.text}FF"; + background-color = "#${background.primary}CC"; + + border-size = 2; + border-color = "#${foreground.active}FF"; + + height = 250; + margin = 5; + padding = 16; + max-icon-size = 16; + layer = "overlay"; + + default-timeout = 5000; + }; + + sections = [ + { + conditions = { urgency = "critical"; }; + config = { + border-color = "#${urgent}FF"; + }; + } + + { + conditions = { mode = "idle"; }; + config = { + ignore-timeout = 1; + default-timeout = 0; + }; + } + ]; + }; + }; + services.cliphist = { enable = true; systemdTarget = "wlr-session.target"; @@ -126,6 +168,7 @@ in { timeouts = [ { timeout = 300; command = lib.getExe wlopmDisableScreens; resumeCommand = lib.getExe wlopmEnableScreens; } { timeout = 1800; command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; } + { timeout = 5; command = "${lib.getExe' pkgs.mako "makoctl"} -a idle"; resumeCommand = "${lib.getExe' pkgs.mako "makoctl"} -r idle"; } ]; }; diff --git a/home/modules/profiles/desktop/dwl/mako-hm-impl.nix b/home/modules/profiles/desktop/dwl/mako-hm-impl.nix new file mode 100644 index 0000000..a0579a3 --- /dev/null +++ b/home/modules/profiles/desktop/dwl/mako-hm-impl.nix @@ -0,0 +1,15 @@ +{ config, lib, ... }: + +let + cfg = config.rutherther.programs.mako; +in { + config = lib.mkIf cfg.enable { + home.packages = [ + cfg.package + ]; + + xdg.dataFile."dbus-1/services/${builtins.baseNameOf (builtins.unsafeDiscardStringContext + cfg.dbusFile)}".source = cfg.dbusFile; + xdg.configFile."mako/config".source = cfg.configFile; + }; +} diff --git a/home/modules/profiles/desktop/dwl/mako.nix b/home/modules/profiles/desktop/dwl/mako.nix new file mode 100644 index 0000000..a060ae9 --- /dev/null +++ b/home/modules/profiles/desktop/dwl/mako.nix @@ -0,0 +1,84 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.rutherther.programs.mako; + + inherit (lib) mkOption mkEnableOption mkPackageOption; + inherit (lib.types) str package number path attrsOf listOf oneOf submodule; + + configOptionType = oneOf [ str number ]; + configOptionsType = attrsOf configOptionType; + mapConfigOptions = options: lib.mapAttrsToList (name: value: "${name}=${builtins.toString value}") options; + sectionsType = submodule ({ config, ... }: { + options = { + conditions = mkOption { + type = configOptionsType; + description = "The conditions for current section."; + example = { + urgency = "critical"; + }; + }; + config = mkOption { + type = configOptionsType; + description = "Options to configure for the specified condition."; + example = { + border-color = "#FFFFFFFF"; + }; + }; + configText = mkOption { + type = str; + readOnly = true; + }; + }; + + config = { + configText = ''[${lib.concatStringsSep " " (mapConfigOptions config.conditions)}] +${lib.concatStringsSep "\n" (mapConfigOptions config.config)}''; + }; + }); + + sectionsConfigs = lib.lists.map (section: section.configText) cfg.config.sections; +in { + options.rutherther.programs.mako = { + enable = mkEnableOption "Program - simple wayland notification daemon"; + + package = mkPackageOption pkgs "mako" {}; + + config.default = mkOption { + type = configOptionsType; + description = '' + Text for the configuration file. + ''; + }; + + config.sections = mkOption { + type = listOf sectionsType; + description = "Sections to append to the config file. These apply only if conditions for those are satisfied."; + }; + + configFile = mkOption { + type = package; + readOnly = true; + description = "Resulting file with the configuration text."; + }; + + configText = mkOption { + type = str; + readOnly = true; + description = '' + Resulting text of the configuration file. + ''; + }; + + dbusFile = mkOption { + type = path; + description = "D-Bus service file"; + }; + }; + + config.rutherther.programs.mako = { + configText = lib.concatStringsSep "\n" ((mapConfigOptions cfg.config.default) ++ sectionsConfigs) + "\n"; + configFile = pkgs.writeText "mako-config" cfg.configText; + dbusFile = "${cfg.package}/share/dbus/fr.emersion.mako.service"; + }; +} -- 2.48.1