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 Nov 22, 2024
1 parent edabc79 commit 9a98401
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
9 changes: 8 additions & 1 deletion modules/system/defaults/dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,16 @@ in {
Persistent applications in the dock.
'';
apply = value:
let
tileTypes = ["spacer-tile" "small-spacer-tile"];
in
if !(isList value)
then value
else map (app: { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }) value;
else map (app:
if elem app tileTypes
then { tile-data = {}; tile-type = app; }
else { tile-data = { file-data = { _CFURLString = app; _CFURLStringType = 0; }; }; }
) value;
};

system.defaults.dock.persistent-others = mkOption {
Expand Down
18 changes: 17 additions & 1 deletion tests/fixtures/system-defaults-write/activate-user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,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 Expand Up @@ -568,4 +584,4 @@ defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Sound' $'<?
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>24</integer>
</plist>'
</plist>'
2 changes: 1 addition & 1 deletion tests/system-defaults-write.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 9a98401

Please sign in to comment.