From 5c65cfb656c1a7879c750d342bfdcc082831a891 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Mon, 20 Mar 2023 09:22:41 -0700 Subject: [PATCH] Add support for persistent-apps in dock --- modules/system/defaults/dock.nix | 13 ++++++++ .../system-defaults-write/activate-user.txt | 30 +++++++++++++++++++ tests/system-defaults-write.nix | 1 + 3 files changed, 44 insertions(+) diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 7fda0daf5..9d54f756a 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -123,6 +123,19 @@ in { ''; }; + system.defaults.dock.persistent-apps = mkOption { + type = types.nullOr (types.listOf (types.either types.path types.str)); + default = null; + example = [ "/Applications/Safari.app" "/System/Applications/Utilities/Terminal.app" ]; + description = lib.mdDoc '' + Persistent applications in the dock. + ''; + apply = value: + if !(isList value) + then value + else map (app: { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }) value; + }; + system.defaults.dock.show-process-indicators = mkOption { type = types.nullOr types.bool; default = null; diff --git a/tests/fixtures/system-defaults-write/activate-user.txt b/tests/fixtures/system-defaults-write/activate-user.txt index 81d9b2775..1021ab38f 100644 --- a/tests/fixtures/system-defaults-write/activate-user.txt +++ b/tests/fixtures/system-defaults-write/activate-user.txt @@ -225,6 +225,36 @@ defaults write com.apple.dock 'orientation' $' left ' +defaults write com.apple.dock 'persistent-apps' $' + + + + + tile-data + + file-data + + _CFURLString + MyApp.app + _CFURLStringType + 0 + + + + + tile-data + + file-data + + _CFURLString + Cool.app + _CFURLStringType + 0 + + + + +' diff --git a/tests/system-defaults-write.nix b/tests/system-defaults-write.nix index def169d26..9840298b3 100644 --- a/tests/system-defaults-write.nix +++ b/tests/system-defaults-write.nix @@ -46,6 +46,7 @@ system.defaults.dock.appswitcher-all-displays = false; system.defaults.dock.autohide-delay = 0.24; system.defaults.dock.orientation = "left"; + system.defaults.dock.persistent-apps = ["MyApp.app" "Cool.app"]; system.defaults.screencapture.location = "/tmp"; system.defaults.screensaver.askForPassword = true; system.defaults.screensaver.askForPasswordDelay = 5;