Commit d75e0e2
Changed files (3)
modules
desktop
apps
thunar
desktop-environment
discrete
modules/desktop/apps/thunar/config.nix
@@ -0,0 +1,34 @@
+{lib, ...}: {
+ flake.modules.nixos.de-discrete = {pkgs, ...}: {
+ programs.thunar = {
+ enable = true;
+ plugins = with pkgs.xfce; [
+ thunar-archive-plugin
+ thunar-volman
+ ];
+ };
+ };
+
+ flake.modules.homeManager.de-discrete = {config, ...}: {
+ xfconf.settings.thunar = {
+ "misc-symbolic-icons-in-sidepane" = true;
+ };
+
+ programs.thunar.actions =
+ []
+ ++ (lib.optional (config.programs.ghostty.enable) {
+ name = "在 Ghostty 中打开";
+ submenu = "在终端中打开";
+ icon = "terminal";
+ command = "for f in %F; do ghostty --working-directory=\"$f\"; done";
+ appears.directories = true;
+ })
+ ++ (lib.optional (config.programs.foot.enable) {
+ name = "在 Foot 中打开";
+ submenu = "在终端中打开";
+ icon = "terminal";
+ command = "for f in %F; do foot --working-directory=\"$f\"; done";
+ appears.directories = true;
+ });
+ };
+}
modules/desktop/apps/thunar/option.nix
@@ -0,0 +1,64 @@
+{lib, ...}: {
+ flake.modules.homeManager.de-discrete = {config, ...}: {
+ options.programs.thunar.actions = lib.mkOption {
+ default = [];
+ type = lib.types.listOf (lib.types.submodule {
+ options = {
+ icon = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ name = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ submenu = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ command = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ description = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ range = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ patterns = lib.mkOption {
+ default = "";
+ type = lib.types.str;
+ };
+ appears =
+ lib.genAttrs'
+ ["directories" "audio-files" "image-files" "other-files" "text-files" "video-files"]
+ (s: lib.nameValuePair s (lib.mkEnableOption ""));
+ };
+ });
+ };
+
+ config = {
+ xdg.configFile."Thunar/uca.xml".text = lib.mkIf ((lib.length config.programs.thunar.actions) > 0) ''
+ <?xml version="1.0" encoding="UTF-8"?>
+ <actions>
+ ${lib.concatImapStringsSep "\n" (index: action: ''
+ <action>
+ <unique-id>${builtins.toString index}</unique-id>
+ ${lib.concatMapAttrsStringSep "\n " (
+ name: value:
+ if (lib.typeOf value == "string")
+ then "<${name}>${lib.escapeXML value}</${name}>"
+ else lib.concatMapAttrsStringSep "\n " (name: _: "<${name}/>") (lib.filterAttrs (_: v: v) value)
+ )
+ action}
+ </action>
+ '')
+ config.programs.thunar.actions}
+ </actions>
+ '';
+ };
+ };
+}
modules/desktop/desktop-environment/discrete/file-manager.nix
@@ -1,11 +0,0 @@
-{
- flake.modules.nixos.de-discrete = {pkgs, ...}: {
- programs.thunar = {
- enable = true;
- plugins = with pkgs.xfce; [
- thunar-archive-plugin
- thunar-volman
- ];
- };
- };
-}