Skip to content

Commit

Permalink
Add file or directory tile to Dock persistent others
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgpinto committed May 14, 2024
1 parent de8b0d6 commit 0a1571a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/system/defaults/dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ in {
system.defaults.dock.persistent-others = mkOption {
type = types.nullOr (types.listOf (types.either types.path types.str));
default = null;
example = [ "~/Documents" "~/Downloads" ];
example = [ "~/Downloads" "~/Downloads/file.txt" ];
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;
else map (folder: { tile-data = { file-data = { _CFURLString = "file://" + folder; _CFURLStringType = 15; }; }; tile-type = if lib.strings.hasInfix folder "." then "file-tile" else "directory-tile"; }) value;
};

system.defaults.dock.show-process-indicators = mkOption {
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/system-defaults-write/activate-user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,21 @@ defaults write com.apple.dock 'persistent-others' $'<?xml version="1.0" encoding
<integer>15</integer>
</dict>
</dict>
<key>title-type</key>
<string>directory-tile</string>
</dict>
<dict>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key>
<string>~/Downloads</string>
<string>~/Downloads/file.txt</string>
<key>_CFURLStringType</key>
<integer>15</integer>
</dict>
<key>title-type</key>
<string>file-tile</string>
</dict>
</dict>
</array>
Expand Down

0 comments on commit 0a1571a

Please sign in to comment.