From fb2507afe7d6884a6c0dd44edb26f83dca44bd21 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 23 Aug 2025 16:42:12 +0200 Subject: [PATCH] feature(xdg): Include file picker configuration --- home/default.nix | 15 ++++++++++-- modules/programs/gnomeServices.nix | 1 + modules/programs/hypr/hyprland.nix | 22 +++-------------- modules/programs/media.nix | 38 ++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/home/default.nix b/home/default.nix index 8b6d079..ee4f804 100644 --- a/home/default.nix +++ b/home/default.nix @@ -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 = { diff --git a/modules/programs/gnomeServices.nix b/modules/programs/gnomeServices.nix index 01ab872..29bdea8 100644 --- a/modules/programs/gnomeServices.nix +++ b/modules/programs/gnomeServices.nix @@ -71,6 +71,7 @@ nautilus sushi nautilus-python + nautilus-open-any-terminal ]; in lib.mkIf config.mods.nautilus.enable packages; diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index 65beb78..d46f83e 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -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; diff --git a/modules/programs/media.nix b/modules/programs/media.nix index 207fa9c..f05500d 100644 --- a/modules/programs/media.nix +++ b/modules/programs/media.nix @@ -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