nix/home/file/yazi/module/Yazi.nix

177 lines
4 KiB
Nix
Raw Normal View History

{
2024-11-04 04:37:29 +03:00
pkgs,
...
}: {
# REF: https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/yazi.toml
file = (pkgs.formats.toml { }).generate "YaziYaziConfig" {
manager = {
# linemode = "mtime";
mouse_events = [ ];
ratio = [ 1 4 3 ];
scrolloff = 1;
show_hidden = false;
show_symlink = true;
sort_by = "natural";
sort_dir_first = true;
sort_sensitive = true;
sort_translit = true;
};
2024-06-22 23:34:03 +03:00
2024-11-04 04:37:29 +03:00
preview = {
# image_filter = "triangle";
image_filter = "lanczos3";
image_quality = 80;
};
2024-06-22 23:34:03 +03:00
2024-11-04 04:37:29 +03:00
opener = let
openWith = app: "${app} \"$@\"";
in {
default = [{
desc = "Default";
orphan = true;
run = openWith "xdg-open";
}];
2024-11-19 05:27:31 +03:00
archive = [{
desc = "Archive";
run = openWith "archive";
}];
archive_fast = [{
desc = "Archive Fast";
run = openWith "archive_fast";
}];
2024-11-04 04:37:29 +03:00
audio = [{
desc = "Audio";
orphan = true;
run = openWith "mpv --no-video";
}];
audio_shuffle = [{
2024-11-12 13:18:42 +03:00
desc = "Audio Shuffle";
orphan = true;
run = "mpv --no-video --shuffle \"$@\"/**";
}];
2024-11-04 04:37:29 +03:00
browser = [{
desc = "Browser";
orphan = true;
run = openWith "firefox-esr";
}];
document = [{
desc = "Document";
orphan = true;
run = openWith "onlyoffice-desktopeditors";
}];
hex = [{
desc = "Hex";
block = true;
run = openWith "radare2 -c V -w";
}];
2024-11-20 22:57:12 +03:00
picture = [{
desc = "Picture";
2024-11-04 04:37:29 +03:00
orphan = true;
run = openWith "loupe";
}];
2024-11-20 22:57:12 +03:00
picture_edit = [{
desc = "Picture Edit";
2024-11-04 04:37:29 +03:00
orphan = true;
run = openWith "gimp";
}];
2024-11-20 22:57:12 +03:00
picture_edit_quick = [{
desc = "Picture Quick Edit";
orphan = true;
run = openWith "pic_edit";
}];
picture_copy = [{
desc = "Picture Copy";
run = openWith "pic_copy";
}];
2024-11-19 05:27:31 +03:00
mount = [{
desc = "Mount";
run = openWith "fmount";
}];
2024-11-04 04:37:29 +03:00
pdf = [{
desc = "Pdf";
orphan = true;
run = openWith "evince";
}];
2024-12-09 09:31:27 +03:00
switch_install = [{
desc = "Switch Install";
run = openWith "switch_install";
}];
2024-12-11 17:46:07 +03:00
steam_run = [{
desc = "Run";
run = openWith "steam-run";
}];
2024-12-12 05:27:20 +03:00
bottle_run = [{
desc = "Run bottle";
run = openWith "btp";
}];
2024-11-19 05:27:31 +03:00
unlock = [{
desc = "Unlock";
block = true;
run = openWith "funlock";
}];
2024-11-04 04:37:29 +03:00
text = [{
desc = "Text";
block = true;
run = openWith "nvim";
}];
video = [{
desc = "Video";
orphan = true;
run = openWith "mpv";
}];
unpack = [{
desc = "Unpack";
run = openWith "unpack";
}];
};
2024-06-22 23:34:03 +03:00
2024-11-04 04:37:29 +03:00
open = {
rules = let
defaultUse = [
"text"
2024-11-19 05:27:31 +03:00
"archive_fast"
2024-11-04 04:37:29 +03:00
"hex"
];
mkMime = mime: use: {
inherit mime;
use = use ++ defaultUse;
};
mkName = name: use: {
inherit name;
use = use ++ defaultUse;
};
in [
2024-12-13 10:16:23 +03:00
(mkName "*.xlsx" [ "document" ])
(mkName "*.mka" [ "audio" ])
(mkName "*.nsp" [ "switch_install" ])
(mkName "*.nsz" [ "switch_install" ])
2024-11-04 04:37:29 +03:00
# Use `file -i file.txt` to find file mime type.
# Use `xdg-mime query default "text/plain"` to find default app.
(mkMime "application/gzip" [ "unpack" ])
(mkMime "application/x-tar" [ "unpack" ])
(mkMime "application/x-xz" [ "unpack" ])
(mkMime "application/zip" [ "unpack" ])
(mkMime "application/x-7z-compressed" [ "unpack" ])
2024-11-19 05:27:31 +03:00
(mkMime "application/x-iso9660-image" [ "mount" ])
(mkMime "application/x-raw-disk-image" [ "unlock" ])
2024-11-04 04:37:29 +03:00
(mkMime "application/pdf" [ "pdf" ])
(mkMime "audio/*" [ "audio" ])
2024-11-20 22:57:12 +03:00
(mkMime "image/*" [ "picture" "picture_copy" "picture_edit" "picture_edit_quick" ])
2024-11-04 04:37:29 +03:00
(mkMime "video/*" [ "video" ])
(mkMime "text/html" [ "browser" ])
(mkMime "application/vnd.openxmlformats-officedocument.*" [ "document" ])
2024-12-11 17:46:07 +03:00
(mkMime "application/x-executable" [ "steam_run" ])
2024-12-13 10:16:23 +03:00
2024-12-12 05:27:20 +03:00
{ mime = "inode/directory"; use = [ "archive" "bottle_run" "audio_shuffle" ]; }
2024-11-04 04:37:29 +03:00
(mkMime "*" [ ])
];
};
2024-11-02 06:44:33 +03:00
2024-11-04 04:37:29 +03:00
which = {
sort_by = "key";
sort_sensitive = false;
};
};
2024-06-22 23:34:03 +03:00
}