summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/services/aerospace/default.nix105
1 files changed, 102 insertions, 3 deletions
diff --git a/modules/services/aerospace/default.nix b/modules/services/aerospace/default.nix
index 531e7b2..3080579 100644
--- a/modules/services/aerospace/default.nix
+++ b/modules/services/aerospace/default.nix
@@ -9,7 +9,31 @@ let
cfg = config.services.aerospace;
format = pkgs.formats.toml { };
- configFile = format.generate "aerospace.toml" cfg.settings;
+ filterAttrsRecursive = pred: set:
+ lib.listToAttrs (
+ lib.concatMap (
+ name: let
+ v = set.${name};
+ in
+ if pred v
+ then [
+ (lib.nameValuePair name (
+ if lib.isAttrs v
+ then filterAttrsRecursive pred v
+ else if lib.isList v
+ then
+ (map (i:
+ if lib.isAttrs i
+ then filterAttrsRecursive pred i
+ else i) (lib.filter pred v))
+ else v
+ ))
+ ]
+ else []
+ ) (lib.attrNames set)
+ );
+ filterNulls = filterAttrsRecursive (v: v != null);
+ configFile = format.generate "aerospace.toml" (filterNulls cfg.settings);
in
{
@@ -72,9 +96,84 @@ in
description = "Default orientation for the root container.";
};
on-window-detected = lib.mkOption {
- type = listOf str;
+ type = listOf (submodule {
+ options = {
+ "if" = lib.mkOption {
+ type = submodule {
+ options = {
+ app-id = lib.mkOption {
+ type = nullOr str;
+ default = null;
+ description = "The application ID to match (optional).";
+ };
+ workspace = lib.mkOption {
+ type = nullOr str;
+ default = null;
+ description = "The workspace name to match (optional).";
+ };
+ window-title-regex-substring = lib.mkOption {
+ type = nullOr str;
+ default = null;
+ description = "Substring to match in the window title (optional).";
+ };
+ app-name-regex-substring = lib.mkOption {
+ type = nullOr str;
+ default = null;
+ description = "Regex substring to match the app name (optional).";
+ };
+ during-aerospace-startup = lib.mkOption {
+ type = nullOr bool;
+ default = null;
+ description = "Whether to match during aerospace startup (optional).";
+ };
+ };
+ };
+ default = { };
+ description = "Conditions for detecting a window.";
+ };
+ check-further-callbacks = lib.mkOption {
+ type = nullOr bool;
+ default = null;
+ description = "Whether to check further callbacks after this rule (optional).";
+ };
+ run = lib.mkOption {
+ type = oneOf [str (listOf str)];
+ example = ["move-node-to-workspace m" "resize-node"];
+ description = "Commands to execute when the conditions match (required).";
+ };
+ };
+ });
default = [ ];
- description = "Commands to run every time a new window is detected.";
+ example = [
+ {
+ "if" = {
+ app-id = "Another.Cool.App";
+ workspace = "cool-workspace";
+ window-title-regex-substring = "Title";
+ app-name-regex-substring = "CoolApp";
+ during-aerospace-startup = false;
+ };
+ check-further-callbacks = false;
+ run = ["move-node-to-workspace m" "resize-node"];
+ }
+ ];
+ description = "Commands to run every time a new window is detected with optional conditions.";
+ };
+ workspace-to-monitor-force-assignment = lib.mkOption {
+ type = attrsOf (oneOf [int str (listOf str)]);
+ default = { };
+ description = ''
+ Map workspaces to specific monitors.
+ Left-hand side is the workspace name, and right-hand side is the monitor pattern.
+ '';
+ example = {
+ "1" = 1; # First monitor from left to right.
+ "2" = "main"; # Main monitor.
+ "3" = "secondary"; # Secondary monitor (non-main).
+ "4" = "built-in"; # Built-in display.
+ "5" = "^built-in retina display$"; # Regex for the built-in retina display.
+ "6" = ["secondary" "dell"]; # Match first pattern in the list.
+ };
};
on-focus-changed = lib.mkOption {
type = listOf str;