diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-07 12:50:26 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-04-07 12:50:26 +0200 |
commit | 0863607a87572acda6276b6251778f2294d21ae6 (patch) | |
tree | 50092b650e944c07859cdb10d47ec27dcb6ff4ad | |
parent | refactor(modules/legacy/ytcc): Remove (diff) | |
download | nixos-config-0863607a87572acda6276b6251778f2294d21ae6.zip |
refactor(modules/xdg): Migrate to by-name and fix firefox dep in url-handler
-rw-r--r-- | modules/by-name/xd/xdg/module.nix | 123 | ||||
-rwxr-xr-x | modules/by-name/xd/xdg/scripts/lf-wrapper.sh (renamed from modules/by-name/xd/xdg/lf-wrapper.sh) | 0 | ||||
-rwxr-xr-x | modules/by-name/xd/xdg/scripts/url-handler.sh (renamed from modules/home.legacy/conf/xdg/url-handler.sh) | 4 | ||||
-rw-r--r-- | modules/common/default.nix | 1 | ||||
-rw-r--r-- | modules/home.legacy/conf/default.nix | 1 | ||||
-rw-r--r-- | modules/home.legacy/conf/xdg/default.nix | 59 | ||||
-rw-r--r-- | modules/home.legacy/conf/xdg/xdg_vars.nix | 29 |
7 files changed, 94 insertions, 123 deletions
diff --git a/modules/by-name/xd/xdg/module.nix b/modules/by-name/xd/xdg/module.nix index 1202cd96..f1781d86 100644 --- a/modules/by-name/xd/xdg/module.nix +++ b/modules/by-name/xd/xdg/module.nix @@ -1,60 +1,119 @@ { pkgs, lib, + config, ... }: let - cmd = pkgs.writeShellApplication { - name = "lf_wrapper"; + lf-wrapper = pkgs.writeShellApplication { + name = "lf-wrapper"; runtimeInputs = [pkgs.lf pkgs.alacritty]; inheritPath = true; - text = builtins.readFile ./lf-wrapper.sh; + text = builtins.readFile ./scripts/lf-wrapper.sh; + }; + + url-handler = pkgs.writeShellApplication { + name = "url-handler"; + + runtimeInputs = [pkgs.rofi pkgs.libnotify pkgs.zathura pkgs.tskm]; + inheritPath = false; + + text = builtins.readFile ./scripts/url-handler.sh; }; tfcConfigFile = (pkgs.formats.ini {}).generate "xdg-desktop-portal-termfilechooser.ini" { filechooser = { default_dir = "/tmp"; - cmd = "${lib.getExe cmd}"; + cmd = "${lib.getExe lf-wrapper}"; }; }; + + cfg = config.soispha.xdg; in { - services.dbus.enable = true; - xdg = { - portal = { - enable = true; - wlr = { + options.soispha.xdg = { + enable = lib.mkEnableOption "xdg"; + }; + + config = lib.mkIf cfg.enable { + home-manager.users.soispha = { + xdg = { + desktopEntries = { + url-handler = { + name = "url-handler"; + genericName = "Web Browser"; + exec = "${lib.getExe url-handler} %u"; + terminal = false; + categories = [ + "Application" + "Network" + "WebBrowser" + ]; + mimeType = [ + "text/html" + "text/xml" + "x-scheme-handler/http" + "x-scheme-handler/https" + "x-scheme-handler/about" + "x-scheme-handler/unknown" + ]; + }; + }; + }; + }; + + services.dbus.enable = true; + + xdg = { + mime = { enable = true; + defaultApplications = { + "application/pdf" = ["url-handler.desktop"]; + "application/x-pdf" = ["url-handler.desktop"]; + + "text/html" = ["url-handler.desktop"]; + "text/xml" = ["url-handler.desktop"]; + "x-scheme-handler/http" = ["url-handler.desktop"]; + "x-scheme-handler/https" = ["url-handler.desktop"]; + "x-scheme-handler/about" = ["url-handler.desktop"]; + "x-scheme-handler/unknown" = ["url-handler.desktop"]; + }; }; - config = { - common = { - # NOTE: The next entry is supposedly needed for gtk based apps <2023-08-31> - default = ["wlr" "gtk"]; - "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; + + portal = { + enable = true; + wlr = { + enable = true; }; + config = { + common = { + # NOTE: The next entry is supposedly needed for gtk based apps <2023-08-31> + default = ["wlr" "gtk"]; + "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; + }; - # TODO: Also activate, when on another wlr-based compositor <2023-11-25> - river = { - default = ["wlr" "gtk"]; - "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; + # TODO: Also activate, when on another wlr-based compositor <2023-11-25> + river = { + default = ["wlr" "gtk"]; + "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; + }; }; - }; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-wlr - pkgs.xdg-desktop-portal-termfilechooser - ]; + extraPortals = [ + pkgs.xdg-desktop-portal-gtk + pkgs.xdg-desktop-portal-wlr + pkgs.xdg-desktop-portal-termfilechooser + ]; + }; }; - }; - environment.etc."xdg/xdg-desktop-portal-termfilechooser/config".source = tfcConfigFile; + environment.etc."xdg/xdg-desktop-portal-termfilechooser/config".source = tfcConfigFile; - systemd.user.services.xdg-desktop-portal-termfilechooser = { - serviceConfig.ExecStart = [ - "" - "${pkgs.xdg-desktop-portal-termfilechooser}/libexec/xdg-desktop-portal-termfilechooser --loglevel=TRACE" - ]; + systemd.user.services.xdg-desktop-portal-termfilechooser = { + serviceConfig.ExecStart = [ + "" + "${pkgs.xdg-desktop-portal-termfilechooser}/libexec/xdg-desktop-portal-termfilechooser --loglevel=TRACE" + ]; + }; }; - # TODO: mime = {}; } diff --git a/modules/by-name/xd/xdg/lf-wrapper.sh b/modules/by-name/xd/xdg/scripts/lf-wrapper.sh index f85f7bac..f85f7bac 100755 --- a/modules/by-name/xd/xdg/lf-wrapper.sh +++ b/modules/by-name/xd/xdg/scripts/lf-wrapper.sh diff --git a/modules/home.legacy/conf/xdg/url-handler.sh b/modules/by-name/xd/xdg/scripts/url-handler.sh index f15df384..5aa01a48 100755 --- a/modules/home.legacy/conf/xdg/url-handler.sh +++ b/modules/by-name/xd/xdg/scripts/url-handler.sh @@ -10,9 +10,9 @@ if [ "$project" = "nvim" ]; then elif [ "$project" = "zathura" ]; then zathura "$1" elif [ "$project" ]; then - firefox -P "$project" "$1" + tskm open "$project" "$1" else - notify-send "(URL HANDLER) No project selected" && exit 1 + notify-send "(URL HANDLER) No project selected"; exit 1 fi # vim: ft=sh diff --git a/modules/common/default.nix b/modules/common/default.nix index 21b0f200..ae4dc715 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -29,6 +29,7 @@ }; polkit.enable = true; power.enable = true; + xdg.enable = true; services = { adb = { diff --git a/modules/home.legacy/conf/default.nix b/modules/home.legacy/conf/default.nix index 9d7b2110..767039c6 100644 --- a/modules/home.legacy/conf/default.nix +++ b/modules/home.legacy/conf/default.nix @@ -27,6 +27,5 @@ ./starship ./swayidle ./tridactyl - ./xdg ]; } diff --git a/modules/home.legacy/conf/xdg/default.nix b/modules/home.legacy/conf/xdg/default.nix deleted file mode 100644 index ad0cd226..00000000 --- a/modules/home.legacy/conf/xdg/default.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ - pkgs, - lib, - ... -}: let - url-handler = pkgs.writeShellApplication { - name = "url-handler"; - text = builtins.readFile ./url-handler.sh; - inheritPath = false; - runtimeInputs = [ - pkgs.rofi - pkgs.libnotify - pkgs.zathura - pkgs.tskm - ]; - }; -in { - imports = [ - ./xdg_vars.nix - ]; - - xdg = { - mimeApps = { - enable = true; - defaultApplications = { - "application/pdf" = ["url-handler.desktop"]; - "application/x-pdf" = ["url-handler.desktop"]; - - "text/html" = ["url-handler.desktop"]; - "text/xml" = ["url-handler.desktop"]; - "x-scheme-handler/http" = ["url-handler.desktop"]; - "x-scheme-handler/https" = ["url-handler.desktop"]; - "x-scheme-handler/about" = ["url-handler.desktop"]; - "x-scheme-handler/unknown" = ["url-handler.desktop"]; - }; - }; - desktopEntries = { - url-handler = { - name = "url-handler"; - genericName = "Web Browser"; - exec = "${lib.getExe url-handler} %u"; - terminal = false; - categories = [ - "Application" - "Network" - "WebBrowser" - ]; - mimeType = [ - "text/html" - "text/xml" - "x-scheme-handler/http" - "x-scheme-handler/https" - "x-scheme-handler/about" - "x-scheme-handler/unknown" - ]; - }; - }; - }; -} diff --git a/modules/home.legacy/conf/xdg/xdg_vars.nix b/modules/home.legacy/conf/xdg/xdg_vars.nix deleted file mode 100644 index aa2f30d4..00000000 --- a/modules/home.legacy/conf/xdg/xdg_vars.nix +++ /dev/null @@ -1,29 +0,0 @@ -{config, ...}: let - inherit (config.xdg) dataHome; -in { - # FIXME: Move these options in relevant modules, that are connected to their software. - # <2024-10-21> - - # Variables that only have to be set because special applications fail to set reasonable - # defaults (mostly understandable because of backwards-compatibility, but yeah) - home.sessionVariables = { - CARGO_HOME = "${dataHome}/cargo"; - GRADLE_USER_HOME = "${dataHome}/gradle"; - - #_JAVA_OPTIONS = lib.concatStringsSep " " [ - # ''-Djava.util.prefs.userRoot="${config.xdg.configHome}/java"'' - # ''-Djavafx.cachedir="${config.xdg.cacheHome}/openjfx"'' - # ]; - #GOPATH = "${config.xdg.dataHome}/go"; - #GTK2_RC_FILES = "${config.xdg.configHome}/gtk-2.0/gtkrc"; - #RUSTUP_HOME = "${config.xdg.dataHome}/rustup"; - #NPM_CONFIG_USERCONFIG = "${config.xdg.configHome}/npm/npmrc"; - #NUGET_PACKAGES = "${config.xdg.cacheHome}/NuGetPackages"; - #XAUTHORITY = "${config.xdg.stateHome}/Xauthority"; - #COMPDUMPFILE = "${config.xdg.dataHome}/zsh/.zcompdump}"; - #IPYTHONDIR = "${config.xdg.configHome}/ipython"; - #PARALLEL_HOME = "${config.xdg.configHome}/parallel"; - #STACK_XDG = "1"; - #WINEPREFIX = "${config.xdg.dataHome}/wine"; - }; -} |