config/users/pbsds/home/profiles/desktop/mime.nix

131 lines
3.1 KiB
Nix
Raw Normal View History

2024-10-07 11:42:46 +02:00
{ lib, ... }:
# TODO: midi
# TODO: mod-music
# TODO: vgmstream
# TODO: 3d
let
mime-map = {
image = {
apng = "image/apng";
avif = "image/avif";
bmp = "image/bmp";
gif = "image/gif";
ico = "image/vnd.microsoft.icon";
icox = "image/x-icon";
jpg = "image/jpeg";
jxl = "image/jxl";
pic = "image/x-pict";
png = "image/png";
psd = "image/vnd.adobe.photoshop";
svg = "image/svg+xml";
tif = "image/tif";
tiff = "image/tiff";
webp = "image/webp";
xbm = "image/x-xbitmap";
xpm = "image/x-xpixmap";
};
audio = {
"3g2-audio" = "audio/3gpp";
"3gp-audio" = "audio/3gpp";
aac = "audio/aac";
aiff = "audio/aiff";
flac = "audio/flac";
mkv = "audio/x-matroska";
mpeg = "audio/mpeg"; # NOTE: this is the real mp3, but the other one also exists
mpeg3 = "audio/mpeg3";
mp3 = "audio/mp3";
mp4 = "audio/mp4";
ogg = "audio/ogg";
opus = "audio/opus";
wav = "audio/wav";
wavx = "audio/x-wav";
webm-audio = "audio/webm";
};
video = {
"3g2-video" = "video/3gpp";
"3gp-video" = "video/3gpp";
avi = "video/x-msvideo";
flv = "video/x-flv";
m4v = "video/x-m4v";
mkv = "video/x-matroska";
mov = "video/quicktime";
mp4 = "video/mp4";
mpeg = "video/mpeg";
ogv = "video/ogg";
webm-video = "video/webm";
wmv = "video/x-ms-wmv";
};
fonts = {
otf = "font/otf";
ttf = "font/ttf";
woff = "font/woff";
woff2 = "font/woff2";
};
docs = {
azv = "application/vnd.amazon.ebook";
cbr = "application/vnd.comicbook+rar";
cbrx = "application/x-cbr";
cbz = "application/vnd.comicbook+zip";
cbzx = "application/x-cbz";
djvu = "image/vnd.djvu";
epub = "application/epub+zip";
pdf = "application/pdf";
};
web = {
html = "text/html";
xhtml = "application/xhtml+xml";
http = "x-scheme-handler/http";
https = "x-scheme-handler/https";
url = "application/x-mswinurl";
};
code = {
css = "text/css";
csv = "text/csv";
txt = "text/plain";
xml = "text/xml";
py = "text/x-script.python";
wine-ini = "application/x-wine-extension-ini";
ics = "text/calendar";
};
};
# Applications
app-map = {
/* image = ["org.gnome.eog.desktop"]; */
image = ["org.gnome.Loupe.desktop"];
audio = ["mpv.desktop"];
video = ["mpv.desktop"];
fonts = ["org.gnome.font-viewer.desktop"];
2024-10-08 15:15:46 +02:00
docs = ["org.gnome.Papers.desktop" "org.gnome.Evince.desktop"];
2024-10-07 11:42:46 +02:00
web = ["firefox.desktop"];
/* code = ["Pulsar.desktop"]; */
/* code = ["micro.desktop"]; */
code = ["dev.zed.Zed.desktop"];
};
in {
xdg.configFile."mimeapps.list".force = true;
xdg.mimeApps = {
enable = true;
# associations.added = {};
# associations.removed = {};
defaultApplications = lib.pipe app-map [
(lib.mapAttrsToList (key: apps:
lib.forEach (lib.attrValues mime-map.${key}) (mime:
lib.nameValuePair mime apps
)
))
lib.flatten
lib.listToAttrs
];
};
}