Skip to content

Commit

Permalink
dock: allow setting tile-types
Browse files Browse the repository at this point in the history
You can create spacer tiles in the dock by passing empty tile-data with
specific tile-types
  • Loading branch information
khaneliman committed Dec 5, 2024
1 parent 55d0781 commit 158701e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
12 changes: 8 additions & 4 deletions modules/system/defaults/dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ in {
description = ''
Persistent applications in the dock.
'';
apply = value:
if !(isList value)
then value
else map (app: { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }) value;
apply =
let
tileTypes = ["spacer-tile" "small-spacer-tile"];
toSpecialTile = type: { tile-data = {}; tile-type = type; };
toAppTile = cfurl: { tile-data = { file-data = { _CFURLString = cfurl; _CFURLStringType = 0; }; }; };
toTile = s: if elem s tileTypes then toSpecialTile s else toAppTile s;
in
value: if isList value then map toTile value else value;
};

system.defaults.dock.persistent-others = mkOption {
Expand Down
16 changes: 16 additions & 0 deletions tests/fixtures/system-defaults-write/activate-user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ defaults write com.apple.dock 'persistent-apps' $'<?xml version="1.0" encoding="
</dict>
</dict>
</dict>
<dict>
<key>tile-data</key>
<dict>

</dict>
<key>tile-type</key>
<string>small-spacer-tile</string>
</dict>
<dict>
<key>tile-data</key>
<dict>

</dict>
<key>tile-type</key>
<string>spacer-tile</string>
</dict>
</array>
</plist>'
defaults write com.apple.dock 'persistent-others' $'<?xml version="1.0" encoding="UTF-8"?>
Expand Down
2 changes: 1 addition & 1 deletion tests/system-defaults-write.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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.dock.persistent-apps = ["MyApp.app" "Cool.app" "small-spacer-tile" "spacer-tile"];
system.defaults.dock.persistent-others = ["~/Documents" "~/Downloads/file.txt"];
system.defaults.dock.scroll-to-open = false;
system.defaults.finder.AppleShowAllFiles = true;
Expand Down

0 comments on commit 158701e

Please sign in to comment.