feature(xdg): Include file picker configuration

This commit is contained in:
DashieTM 2025-08-23 16:42:12 +02:00
parent 29b5237c28
commit fb2507afe7
4 changed files with 55 additions and 21 deletions

View file

@ -18,10 +18,21 @@
...
}: {
xdg = {
portal.config.common.default = mkDashDefault "*";
portal.config.common = {
default = mkDashDefault "hyprland;gtk";
"org.freedesktop.impl.portal.FileChooser" = lib.mkIf (config.mods.media.filePickerPortal != "Default") "shana";
};
portal = {
enable = mkDashDefault true;
extraPortals = [pkgs.xdg-desktop-portal-gtk];
extraPortals = with pkgs; [
xdg-desktop-portal-gtk # prob needed either way
(lib.mkIf (config.mods.media.filePickerPortal != "Default") xdg-desktop-portal-shana)
(lib.mkIf (config.mods.media.filePickerPortal == "Kde") kdePackages.xdg-desktop-portal-kde)
# Gnome uses their file manager, kinda cool tbh
(lib.mkIf (config.mods.media.filePickerPortal == "Gnome" && !config.mods.nautilus.enable) nautilus)
(lib.mkIf (config.mods.media.filePickerPortal == "Lxqt") xdg-desktop-portal-lxqt)
(lib.mkIf (config.mods.media.filePickerPortal == "Term") xdg-desktop-portal-termfilechooser)
];
};
};
home-manager = {

View file

@ -71,6 +71,7 @@
nautilus
sushi
nautilus-python
nautilus-open-any-terminal
];
in
lib.mkIf config.mods.nautilus.enable packages;

View file

@ -140,15 +140,6 @@ in {
Please note, plugins tend to break VERY often.
'';
};
filePickerPortal = lib.mkOption {
default = "gtk";
example = "kde";
type = with lib.types; (enum ["gnome" "kde" "gtk" "disable"]);
description = ''
The file picker portal to use with Hyprland.
Disable removes the config, allowing you to set it yourself.
'';
};
};
config = lib.mkIf config.mods.hypr.hyprland.enable (
@ -160,22 +151,15 @@ in {
slurp
satty
xdg-desktop-portal-gtk
xdg-desktop-portal-gnome
kdePackages.xdg-desktop-portal-kde
xdg-desktop-portal-shana
copyq
wl-clipboard
hyprcursor
hyprpicker
(lib.mkIf (config.mods.hypr.hyprland.filePickerPortal == "kde") xdg-desktop-portal-kde)
(lib.mkIf (config.mods.hypr.hyprland.filePickerPortal == "gnome") xdg-desktop-portal-gnome)
];
xdg.configFile."xdg-desktop-portal/portals.conf" = lib.mkIf (config.mods.hypr.hyprland.filePickerPortal != "none") {
text = ''
[preferred]
default = hyprland;gtk
org.freedesktop.impl.portal.FileChooser = ${config.mods.hypr.hyprland.filePickerPortal}
'';
};
wayland.windowManager.hyprland = {
enable = true;
package = mkDashDefault pkgs.hyprland;

View file

@ -36,8 +36,46 @@
special services configuration to be added which require an services.something notation.
'';
};
filePickerPortal = lib.mkOption {
default = "Term";
example = "Gnome";
type = with lib.types; oneOf [(enum ["Gnome" "Kde" "Lxqt" "Gtk" "Term" "Default"]) string];
description = ''
The file picker portal to use (set with shana).
Default removes the config, allowing you to set it yourself.
'';
};
termFileChooserConfig = lib.mkOption {
default = {
cmd = "${pkgs.xdg-desktop-portal-termfilechooser}/share/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh";
default_dir = "$HOME";
};
example = {};
type = with lib.types; attrsOf anything;
description = ''
Termfilechooser config
'';
};
};
config = lib.optionalAttrs (options ? home.packages) {
xdg.configFile."xdg-desktop-portal-termfilechooser/config" = lib.mkIf (config.mods.media.filePickerPortal != "Term") {
source = (pkgs.formats.ini {}).generate "termchooser" {
filechooser = config.mods.media.termFileChooserConfig;
};
};
xdg.configFile."xdg-desktop-portal-shana/config.toml" = lib.mkIf (config.mods.media.filePickerPortal != "Default") {
source = let
name =
if (config.mods.media.filePickerPortal == "Term")
then "org.freedesktop.impl.portal.desktop.termfilechooser"
else config.mods.media.filePickerPortal;
in
(pkgs.formats.toml {}).generate "shana" {
open_file = name;
save_file = name;
save_files = name;
};
};
home.packages =
if config.mods.media.useBasePackages
then