Skip to content

Commit

Permalink
Add persistent others to dock
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgpinto committed Apr 8, 2024
1 parent 36524ad commit 84ad88e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
20 changes: 17 additions & 3 deletions modules/system/defaults/dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ with lib;
let
# Should only be used with options that previously used floats defined as strings.
inherit (config.lib.defaults.types) floatWithDeprecationError;
in {
in
{
options = {

system.defaults.dock.appswitcher-all-displays = mkOption {
Expand Down Expand Up @@ -136,6 +137,19 @@ in {
else map (app: { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }) value;
};

system.defaults.dock.persistent-others = mkOption {
type = types.nullOr (types.listOf (types.either types.path types.str));
default = null;
example = [ "~/Documents" "~/Downloads" ];
description = lib.mdDoc ''
Persistent folders in the dock.
'';
apply = value:
if !(isList value)
then value
else map (folder: { tile-data = { file-data = { _CFURLString = folder; _CFURLStringType = 15; }; }; }) value;
};

system.defaults.dock.show-process-indicators = mkOption {
type = types.nullOr types.bool;
default = null;
Expand Down Expand Up @@ -191,7 +205,7 @@ in {
Magnified icon size on hover. The default is 16.
'';
};


system.defaults.dock.wvous-tl-corner = mkOption {
type = types.nullOr types.ints.positive;
Expand Down Expand Up @@ -277,5 +291,5 @@ in {
'';
};

};
};
}
31 changes: 30 additions & 1 deletion tests/fixtures/system-defaults-write/activate-user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,36 @@ defaults write com.apple.dock 'persistent-apps' $'<?xml version="1.0" encoding="
</dict>
</array>
</plist>'

defaults write com.apple.dock 'persistent-others' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key>
<string>~/Documents</string>
<key>_CFURLStringType</key>
<integer>15</integer>
</dict>
</dict>
</dict>
<dict>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key>
<string>~/Downloads</string>
<key>_CFURLStringType</key>
<integer>15</integer>
</dict>
</dict>
</dict>
</array>
</plist>'


defaults write com.apple.screencapture 'location' $'<?xml version="1.0" encoding="UTF-8"?>
Expand Down
1 change: 1 addition & 0 deletions tests/system-defaults-write.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
system.defaults.dock.autohide-delay = 0.24;
system.defaults.dock.orientation = "left";
system.defaults.dock.persistent-apps = ["MyApp.app" "Cool.app"];
system.defaults.dock.persistent-apps = ["~/Documents" "~/Downloads"];
system.defaults.screencapture.location = "/tmp";
system.defaults.screensaver.askForPassword = true;
system.defaults.screensaver.askForPasswordDelay = 5;
Expand Down

0 comments on commit 84ad88e

Please sign in to comment.