diff options
| author | Michael Hoang <Enzime@users.noreply.github.com> | 2024-11-03 10:19:55 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-03 10:19:55 +1100 |
| commit | 146629a54364f6b54e7f3d15c44fea69ed0bf476 (patch) | |
| tree | 76c452b5ea0e7b240d022bff1687a1b227b84175 /modules/system | |
| parent | 446e1ef8e17380b979b1337f82eae75cfa565c05 (diff) | |
| parent | 0dacfdea635b664812b8065e6b5449c43bf1a586 (diff) | |
Merge pull request #1125 from aschleck/new-window-path
Configure the folder that new Finder windows open
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/defaults/finder.nix | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/modules/system/defaults/finder.nix b/modules/system/defaults/finder.nix index 1da93c0..51fff74 100644 --- a/modules/system/defaults/finder.nix +++ b/modules/system/defaults/finder.nix @@ -1,7 +1,10 @@ { config, lib, ... }: -with lib; +let + inherit (lib) mkOption types; + cfg = config.system.defaults.finder; +in { options = { @@ -96,5 +99,54 @@ with lib; ''; }; + system.defaults.finder.NewWindowTarget = mkOption { + type = types.nullOr (types.enum [ + "Computer" + "OS volume" + "Home" + "Desktop" + "Documents" + "Recents" + "iCloud Drive" + "Other" + ]); + apply = key: if key == null then null else { + "Computer" = "PfCm"; + "OS volume" = "PfVo"; + "Home" = "PfHm"; + "Desktop" = "PfDe"; + "Documents" = "PfDo"; + "Recents" = "PfAF"; + "iCloud Drive" = "PfID"; + "Other" = "PfLo"; + }.${key}; + default = null; + description = '' + Change the default folder shown in Finder windows. "Other" corresponds to the value of + NewWindowTargetPath. The default is unset ("Recents"). + ''; + }; + + system.defaults.finder.NewWindowTargetPath = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Sets the URI to open when NewWindowTarget is "Other". Spaces and similar characters must be + escaped. If the value is invalid, Finder will open your home directory. + Example: "file:///Users/foo/long%20cat%20pics". + The default is unset. + ''; + }; + }; + + config = { + assertions = [{ + assertion = cfg.NewWindowTargetPath != null -> cfg.NewWindowTarget == "PfLo"; + message = "`system.defaults.finder.NewWindowTarget` should be set to `Other` when `NewWindowTargetPath` is non-null."; + } + { + assertion = cfg.NewWindowTarget == "PfLo" -> cfg.NewWindowTargetPath != null; + message = "`system.defaults.finder.NewWindowTargetPath` should be non-null when `NewWindowTarget` is set to `Other`."; + }]; }; } |
