# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
"$schema" = "https://yazi-rs.github.io/schemas/yazi.json"

[manager]
ratio = [0, 4, 3]
sort_by = "natural"
sort_sensitive = false
sort_reverse = false
sort_dir_first = true
sort_translit  = false
linemode = "size"
show_hidden = false
show_symlink = false
scrolloff = 5
mouse_events = ["scroll"]
title_format = ""

[preview]
wrap = "no"
tab_size = 2
max_width = 600
max_height = 900
#cache_dir       = "~/.cache/yazi/"
image_delay = 10
image_filter = "lanczos3"
image_quality = 75
sixel_fraction = 15
ueberzug_scale = 1
ueberzug_offset = [0, 0, 0, 0]

[opener]
edit = [
  { run = 'nvim "$@"', block = true, for = "unix" },
]

open = [
  #	{ run = 'xdg-open "$@"', orphan = true,  desc = "Open", for = "linux" },
  { run = 'xdg-open "$@"', desc = "Open", for = "linux" },

  #  { run = 'gimp "$1"',                desc = "Gimp", for = "linux" },
  #  { run = 'mpv-single "$1"',                desc = "Play MPV", for = "linux" },
]
reveal = [
  #	{ run = '''exiftool "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show EXIF", for = "unix" },
  #  { run = 'nvim "$@"', block = true, for = "unix" },
  { run = '''exiftool "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show EXIF", for = "unix" },
]

extract = [
  #  { run = 'unrar e "$1"', desc = "Unrar Extract here", for = "unix" },
  #  { run = 'unzip "$1"', desc = "Unzip Extract here", for = "unix" },
  #  { run = 'ya pub extract --list "$@"', desc = "Extract here", for = "unix" },
  { run = 'atool --extract --each "$1"', desc = "Atool Extract here", for = "unix" },
  { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
]

play = [
  { run = 'mpv-single "$@"', desc = "Play MPV (single)", orphan = true, for = "unix" },
  { run = 'mpv "$@"', desc = "Play MPV", orphan = true, for = "unix" },
  #{ run = '''mediainfo "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show media info", for = "unix" },
  { run = '''mediainfo "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show media info", for = "unix" },
]


# Открытие в файлов в GIMP
imgedit = [
  { run = 'gimp "$@"', desc = "Gimp", orphan = true, for = "unix" },
]

#extrar = [
#  { run = 'unrar e "$@"', desc = "Extract RAR", for = "unix" },
#]

plaympvs = [
  { run = 'mpv-single "$@"', desc = "Mpv-single", for = "unix" },
]

plaympv = [
  { run = 'mpv "$@"', desc = "Mpv", for = "unix" },
]

editaudio = [
  { run = 'QT_FONT_DPI=140 ocenaudio "$@"', desc = "Ocenaudio", for = "unix" },
]

#tarxf = [
#  { run = 'tar xf "$@"', desc = "tar -xf", for = "unix" },
#]
#unrar = [
#  { run = 'unrar x "$@"', desc = "unrar", for = "unix" },
#]

[open]
rules = [
  #	{ name = "*/", use = [ "edit", "open", "plaympv", "reveal" ] },
  { name = "*/", use = ["edit", "plaympvs", "plaympv"] },
  #	{ mime = "inode/directory", use = [ "plaympvs", "open", "reveal" ] },
  { name = "*.html", use = ["open", "edit"] },
  { mime = "text/*", use = ["edit", "reveal"] },
  { mime = "image/*", use = ["open", "imgedit", "reveal"] },
  { mime = "video/*", use = ["play", "reveal"] },
  { mime = "audio/*", use = ["play", "editaudio"] },
  { mime = "inode/x-empty", use = ["edit", "reveal"] },
  { mime = "application/json", use = ["edit", "reveal"] },
  { mime = "*/javascript", use = ["edit", "reveal"] },
  { mime = "message/rfc822", use = ["open", "edit", "reveal"] },
  { mime = "*", use = ["open", "edit", "reveal"] },
]

[tasks]
micro_workers = 10
macro_workers = 25
bizarre_retry = 5
image_alloc = 536870912  # 512MB
image_bound = [0, 0]
suppress_preload = false

[plugin]
fetchers = [
	# Mimetype
	{ id = "mime", name = "*", run = "mime", prio = "high" },
]

spotters = [
  { name = "*/", run = "folder" },
  # Code
  { mime = "text/*", run = "edit" },
  { mime = "application/{mbox,javascript,wine-extension-ini}", run = "code" },
  # Image
  { mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
  { mime = "image/*", run = "image" },
  # Video
  { mime = "video/*", run = "video" },
  # Fallback
  { name = "*", run = "file" },
]

preloaders = [
  # Image
  { mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
  { mime = "image/*", run = "image" },
  # Video
  { mime = "video/*", run = "video" },
  # PDF
  { mime = "application/pdf", run = "pdf" },
  # Font
  { mime = "font/*", run = "font" },
  { mime = "application/ms-opentype", run = "font" },
]

previewers = [
  { name = "*/", run = "folder", sync = true },
  # Code
  { mime = "text/*", run = "code" },
  { mime = "application/{mbox,javascript,wine-extension-ini}", run = "code" },
  # JSON
  { mime = "application/{json,ndjson}", run = "json" },
  # Image
  { mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
  { mime = "image/*", run = "image" },
  # Video
  { mime = "video/*", run = "video" },
  # PDF
  { mime = "application/pdf", run = "pdf" },
  # Archive
  # { mime = "application/{zip,rar,7z*,tar,gzip,xz,zstd,bzip*,lzma,compress,archive,cpio,arj,xar,ms-cab*}", run = "archive" },
  { mime = "application/*zip",            run = "ouch" },
	{ mime = "application/x-tar",           run = "ouch" },
	{ mime = "application/x-bzip2",         run = "ouch" },
	{ mime = "application/x-7z-compressed", run = "ouch" },
	{ mime = "application/x-rar",           run = "ouch" },
  { mime = "application/x-xz",            run = "ouch" },
	{ mime = "application/xz",              run = "ouch" },
  { mime = "application/{debian*-package,redhat-package-manager,rpm,android.package-archive}", run = "archive" },
  { name = "*.{AppImage,appimage}", run = "archive" },
  # Virtual Disk / Disk Image
  { mime = "application/{iso9660-image,qemu-disk,ms-wim,apple-diskimage}", run = "archive" },
  { mime = "application/virtualbox-{vhd,vhdx}", run = "archive" },
  { name = "*.{img,fat,ext,ext2,ext3,ext4,squashfs,ntfs,hfs,hfsx}", run = "archive" },
  # Font
  { mime = "font/*", run = "font" },
  { mime = "application/ms-opentype", run = "font" },
  # Empty file
  { mime = "inode/empty", run = "empty" },
  # Fallback
  { name = "*", run = "file" },
]

#[[commands]]
#name = "Open in GIMP"
#match = "\\.(jpg|jpeg|png|bmp|gif|tiff|webp|xcf)$"
#run = "gimp '$1'"

#[[commands]]
#name = "Play in MPV"
#match = "\\.(mp4|mkv|avi|mov|webm|flv)$"
#run = "mpv-single '$1'"


#[[directories]]
#path = "/home/crud/Загрузки"
#sort_by = "modified"
#sort_order = "desc"



[input]
cursor_blink = false

# cd
cd_title = "Change directory:"
cd_origin = "top-center"
cd_offset = [0, 2, 50, 3]

# create
#create_title  = "Create:", "Create (dir):"
create_title = ["Create:", "Create (dir):"]
create_origin = "top-center"
create_offset = [0, 2, 50, 3]

# rename
rename_title = "Rename:"
rename_origin = "hovered"
rename_offset = [0, 1, 50, 3]

# filter
filter_title = "Filter:"
filter_origin = "top-center"
filter_offset = [0, 2, 50, 3]

# find
find_title = ["Find next:", "Find previous:"]
find_origin = "top-center"
find_offset = [0, 2, 50, 3]

# search
search_title = "Search via {n}:"
search_origin = "top-center"
search_offset = [0, 2, 50, 3]

# shell
shell_title = ["Shell:", "Shell (block):"]
shell_origin = "top-center"
shell_offset = [0, 2, 50, 3]

[confirm]
# trash
trash_title 	= "Trash {n} selected file{s}?"
trash_origin = "center"
trash_offset = [0, 2, 50, 3]

# delete
delete_title 	= "Permanently delete {n} selected file{s}?"
delete_origin	= "center"
delete_offset	= [ 0, 0, 70, 20 ]

# overwrite
overwrite_title   = "Overwrite file?"
overwrite_content = "Will overwrite the following file:"
overwrite_origin  = "center"
overwrite_offset  = [ 0, 0, 50, 15 ]

# quit
quit_title   = "Quit?"
quit_content = "The following tasks are still running, are you sure you want to quit?"
quit_origin  = "center"
quit_offset  = [ 0, 0, 50, 15 ]

#[select]
#open_title = "Open with:"
#open_origin = "hovered"
#open_offset = [0, 1, 50, 7]

[pick]
open_title = "Open with:"
open_origin = "hovered"
open_offset = [0, 1, 50, 7]

[which]
sort_by = "none"
sort_sensitive = false
sort_reverse = false
sort_translit = false
