xdg.nix
1 { 2 pkgs, 3 config, 4 ... 5 }: let 6 #stolen from https://github.com/linuxmobile/kaku/blob/main/home/software/xdg.nix 7 # browser = ["Schizofox"]; 8 browser = ["floorp"]; 9 imageViewer = ["oculante"]; 10 Terminal = ["foot.desktop"]; 11 videoPlayer = ["io.github.celluloid_player.Celluloid"]; 12 audioPlayer = ["io.bassi.Amberol"]; 13 14 xdgAssociations = type: program: list: 15 builtins.listToAttrs (map (e: { 16 name = "${type}/${e}"; 17 value = program; 18 }) 19 list); 20 21 image = xdgAssociations "image" imageViewer ["png" "svg" "jpeg" "gif"]; 22 video = xdgAssociations "video" videoPlayer ["mp4" "avi" "mkv"]; 23 audio = xdgAssociations "audio" audioPlayer ["mp3" "flac" "wav" "aac"]; 24 browserTypes = 25 (xdgAssociations "application" browser [ 26 "json" 27 "x-extension-htm" 28 "x-extension-html" 29 "x-extension-shtml" 30 "x-extension-xht" 31 "x-extension-xhtml" 32 ]) 33 // (xdgAssociations "x-scheme-handler" browser [ 34 "about" 35 "ftp" 36 "http" 37 "https" 38 "unknown" 39 ]); 40 41 # XDG MIME types 42 associations = builtins.mapAttrs (_: v: (map (e: "${e}.desktop") v)) ({ 43 "application/pdf" = ["org.pwmt.zathura-pdf-mupdf"]; 44 "x-scheme-handler/element" = ["Element"]; 45 "x-scheme-handler/steamlink" = ["steam"]; 46 "x-scheme-handler/steam" = ["steam"]; 47 "text/html" = browser; 48 "inode/directory" = ["org.gnome.Nautilus"]; 49 "text/plain" = ["Helix"]; 50 "x-scheme-handler/chrome" = ["chromium-browser"]; 51 } 52 // image 53 // video 54 // audio 55 // browserTypes); 56 in { 57 config = { 58 hm = { 59 home.packages = with pkgs; [ 60 qimgv 61 zathura 62 celluloid 63 amberol 64 zathura 65 xdg-utils 66 ]; 67 68 xdg = { 69 enable = true; 70 cacheHome = "/home/${config.users.main}/.local/cache"; 71 72 mimeApps = { 73 enable = true; 74 defaultApplications = associations; 75 }; 76 77 userDirs = { 78 enable = true; 79 createDirectories = true; 80 extraConfig = { 81 # XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots"; 82 }; 83 }; 84 }; 85 }; 86 }; 87 }