add user-places

This commit is contained in:
caandt 2024-11-07 14:42:00 -06:00
parent 312342801f
commit e3089d72d8
3 changed files with 107 additions and 0 deletions

View file

@ -1,4 +1,5 @@
{...}: {
imports = [./user-places.nix];
xdg.configFile.arkrc.source = ./arkrc;
xdg.configFile.kdeglobals.source = ./kdeglobals;
xdg.configFile.kiorc.source = ./kiorc;

View file

@ -0,0 +1,84 @@
{
config,
lib,
...
}: {
u.bookmarks = let
home = config.home.homeDirectory;
in
lib.mkDefault [
{
href = "file://${home}";
name = "Home";
icon = "user-home";
}
{
href = "file://${home}/Desktop";
name = "Desktop";
icon = "user-desktop";
}
{
href = "file://${home}/Downloads";
name = "Downloads";
icon = "folder-downloads";
}
{
href = "file:///tmp";
name = "tmp";
icon = "folder-temp";
}
{
href = "trash:/";
name = "Trash";
icon = "user-trash";
}
{
href = "remote:/";
name = "Network";
icon = "folder-network";
}
];
# dolphin complains if user-places.xbel is read-only
home.activation.user-places = let
path = "${config.xdg.dataHome}/user-places.xbel";
bookmarks =
lib.strings.concatMapStrings ({
href,
name,
icon,
}: ''
<bookmark href="${href}">
<title>${name}</title>
<info><metadata owner="http://freedesktop.org">
<bookmark:icon name="${icon}"/>
</metadata></info>
</bookmark>
'')
config.u.bookmarks;
file-content = ''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xbel>
<xbel>
<info>
<metadata>
<kde_places_version>4</kde_places_version>
<GroupState-Places-IsHidden>false</GroupState-Places-IsHidden>
<GroupState-Remote-IsHidden>false</GroupState-Remote-IsHidden>
<GroupState-Devices-IsHidden>false</GroupState-Devices-IsHidden>
<GroupState-RemovableDevices-IsHidden>false</GroupState-RemovableDevices-IsHidden>
<GroupState-Tags-IsHidden>false</GroupState-Tags-IsHidden>
<withBaloo>true</withBaloo>
<GroupState-SearchFor-IsHidden>false</GroupState-SearchFor-IsHidden>
<GroupState-RecentlySaved-IsHidden>false</GroupState-RecentlySaved-IsHidden>
</metadata>
</info>
${bookmarks}
</xbel>
'';
in
lib.hm.dag.entryAfter ["writeBoundary"] ''
[ ! -e "${path}" ] && cat > "${path}" <<EOF
${file-content}
EOF
'';
}

View file

@ -11,5 +11,27 @@
default = "";
};
};
bookmarks = lib.mkOption {
type = lib.types.listOf (lib.types.submodule {
options = {
href = lib.mkOption {
type = lib.types.str;
description = "link of the bookmark";
example = "file:///tmp";
};
name = lib.mkOption {
type = lib.types.str;
description = "name of the bookmark";
example = "tmp";
};
icon = lib.mkOption {
type = lib.types.str;
description = "icon name of the bookmark";
example = "folder-temp";
};
};
});
description = "list of file manager bookmarks";
};
};
}