Skip to content

Commit

Permalink
feat: add dock item property overrides
Browse files Browse the repository at this point in the history
This allows configuring things like "Sort by", "Display as" and "View
content as" by mirroring the exact value observed on a `defaults read`.

The existing options and values weren't formalized in the schema as I
have no expectations of stability across OS versions.
  • Loading branch information
aisamu committed Nov 12, 2024
1 parent e2db06b commit c3058f9
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions modules/system/defaults/dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,32 @@ in
};

system.defaults.dock.persistent-others = mkOption {
type = types.nullOr (types.listOf (types.either types.path types.str));
type = types.nullOr (types.listOf (types.oneOf [ types.path types.str types.attrs ]));
default = null;
example = [ "/Users/my_user_name/Documents" "/Users/my_user_name/Downloads" ];
example = [
"/Users/my_user_name/Documents"
{ name = "/Users/my_user_name/Downloads"; tile-data = { arrangement = 2; showas = 1; }; }
];
description = ''
Persistent folders in the dock.
Note: tilde(`~`) does not get reliably expanded.
'';
apply = value:
if !(isList value)
then value
else map (folder: { tile-data = { file-data = { _CFURLString = "file://" + folder; _CFURLStringType = 15; }; }; tile-type = if strings.hasInfix "." (last (splitString "/" folder)) then "file-tile" else "directory-tile"; }) value;
if !(isList value) then value else
let
pathToConfig = (path: {
tile-data = { file-data = { _CFURLString = "file://" + path; _CFURLStringType = 15; }; };
tile-type = if strings.hasInfix "." (last (splitString "/" path)) then "file-tile" else "directory-tile";
});
in
map
(folder:
if (isString folder)
then pathToConfig folder
else
(lib.recursiveUpdate (builtins.removeAttrs folder [ "name" ])
(pathToConfig folder.name)))
value;
};

system.defaults.dock.show-process-indicators = mkOption {
Expand Down

0 comments on commit c3058f9

Please sign in to comment.