Compare commits
88
Commits
b4fbca1db9
...
d93a549427
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d93a549427 | ||
|
|
ef0089273d | ||
|
|
84d43eaaaf | ||
|
|
463cdf8805 | ||
|
|
8e79e53783 | ||
|
|
43dcdfa875 | ||
|
|
f0130deaec | ||
|
|
1a5ccf6eae | ||
|
|
1d0c4aabf4 | ||
|
|
664a5a88cc | ||
|
|
da02c8f161 | ||
|
|
8391a3d407 | ||
|
|
ca9c7ecdda | ||
|
|
319e27f008 | ||
|
|
b9b3ce527f | ||
|
|
b45d007e4c | ||
|
|
4a1d3930e9 | ||
|
|
43771700e5 | ||
|
|
7413c69940 | ||
|
|
dd8f227c4c | ||
|
|
40827fc977 | ||
|
|
73141baa20 | ||
|
|
a04b034085 | ||
|
|
cb769ee022 | ||
|
|
7ce29f8543 | ||
|
|
643e2293e1 | ||
|
|
491af915ef | ||
|
|
70f212529f | ||
|
|
8223112c5b | ||
|
|
a8241b7300 | ||
|
|
ff4926651c | ||
|
|
f1f983f4c0 | ||
|
|
ea9594dc43 | ||
|
|
fda4240f2f | ||
|
|
8412a86519 | ||
|
|
1decd61b48 | ||
|
|
d354fd2c40 | ||
|
|
a5663674fe | ||
|
|
c13d02d433 | ||
|
|
398a020c63 | ||
|
|
ee534f54c9 | ||
|
|
6f55246606 | ||
|
|
382b6a6cb0 | ||
|
|
75f9ba1579 | ||
|
|
a8ffd55df6 | ||
|
|
05a71d65be | ||
|
|
4a91aaf447 | ||
|
|
d3007484fa | ||
|
|
fb64d3314e | ||
|
|
6dec3bf52d | ||
|
|
a7e0f242c2 | ||
|
|
f4051dd241 | ||
|
|
ca267f0798 | ||
|
|
0b15fde74b | ||
|
|
50bab49840 | ||
|
|
4525341834 | ||
|
|
1f8d1ee194 | ||
|
|
df5d129f2a | ||
|
|
8ba0eced5b | ||
|
|
8879b3c6fa | ||
|
|
6c096f15ee | ||
|
|
44795fb3f9 | ||
|
|
cc54b000d6 | ||
|
|
55eae6bc7b | ||
|
|
f1e4df1431 | ||
|
|
3d9d2532d2 | ||
|
|
ba3e3927e5 | ||
|
|
2da3fea10d | ||
|
|
8e6546f468 | ||
|
|
97dc31437a | ||
|
|
8474b3f840 | ||
|
|
6cbf7a213a | ||
|
|
007b60f04a | ||
|
|
a94bbd7ea6 | ||
|
|
3bc18e582c | ||
|
|
6293173d01 | ||
|
|
021f1dc500 | ||
|
|
f021af19ce | ||
|
|
561853422d | ||
|
|
3202914993 | ||
|
|
8ba2a04a1f | ||
|
|
337028ce7c | ||
|
|
60e546e2b8 | ||
|
|
cfca5a109a | ||
|
|
1ccdfda5cd | ||
|
|
701b086075 | ||
|
|
7f375dc4cf | ||
|
|
2a8a07039b |
No files matched your search
@@ -4,24 +4,72 @@ packages:
|
|||||||
- age
|
- age
|
||||||
- base-devel
|
- base-devel
|
||||||
- bat
|
- bat
|
||||||
- btop
|
|
||||||
- bitwarden-cli
|
- bitwarden-cli
|
||||||
|
- breeze-gtk
|
||||||
|
- btop
|
||||||
|
- cmus
|
||||||
- curl
|
- curl
|
||||||
- dotnet-sdk
|
- dotnet-sdk
|
||||||
- eza
|
- eza
|
||||||
|
- fd
|
||||||
|
- ffmpeg
|
||||||
- fzf
|
- fzf
|
||||||
- git
|
- git
|
||||||
|
- grim
|
||||||
|
- imagemagick
|
||||||
|
- jq
|
||||||
|
- kvantum
|
||||||
|
- kvantum-qt5
|
||||||
- lazygit
|
- lazygit
|
||||||
- npm
|
- npm
|
||||||
|
- noctalia
|
||||||
|
- noctalia-greeter
|
||||||
- openssh
|
- openssh
|
||||||
|
- poppler
|
||||||
- python-pip
|
- python-pip
|
||||||
|
- qt5ct
|
||||||
|
- qt6ct
|
||||||
|
- resvg
|
||||||
- ripgrep
|
- ripgrep
|
||||||
|
- rofi
|
||||||
|
- satty
|
||||||
|
- slurp
|
||||||
- tmux
|
- tmux
|
||||||
- wget
|
|
||||||
- unzip
|
- unzip
|
||||||
|
- wget
|
||||||
|
- wtype
|
||||||
|
- xdg-terminal-exec
|
||||||
|
- yazi
|
||||||
|
- zoxide
|
||||||
- zsh
|
- zsh
|
||||||
aur:
|
aur:
|
||||||
|
- nil-git
|
||||||
- nixfmt
|
- nixfmt
|
||||||
- prizrak-box-bin
|
- flclashx-bin
|
||||||
- python-xmlformatter
|
- python-xmlformatter
|
||||||
|
- still
|
||||||
- tree-sitter-cli-github-bin
|
- tree-sitter-cli-github-bin
|
||||||
|
go:
|
||||||
|
- id: github.com/davidbudnick/redis-tui
|
||||||
|
version: v1.0.41
|
||||||
|
|
||||||
|
flatpak_remotes:
|
||||||
|
- name: flathub
|
||||||
|
url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||||
|
- name: flathub-beta
|
||||||
|
url: https://dl.flathub.org/beta-repo/flathub-beta.flatpakrepo
|
||||||
|
|
||||||
|
x-fp-stable: &fp_stable
|
||||||
|
remote: flathub
|
||||||
|
branch: stable
|
||||||
|
x-fp-beta: &fp_beta
|
||||||
|
remote: flathub-beta
|
||||||
|
branch: beta
|
||||||
|
|
||||||
|
flatpak:
|
||||||
|
- <<: *fp_stable
|
||||||
|
id: com.github.tchx84.Flatseal
|
||||||
|
- <<: *fp_stable
|
||||||
|
id: com.usebottles.bottles
|
||||||
|
- <<: *fp_beta
|
||||||
|
id: com.discordapp.DiscordCanary
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
defaultAgeKeyPath: "~/.config/age/key.txt"
|
defaultAgeKeyPath: "~/.config/age/key.txt"
|
||||||
nixosAgeKeyPath: "/etc/age/key.txt"
|
nixosAgeKeyPath: "/etc/age/key.txt"
|
||||||
skipCreatingAgeKey: true
|
skipCreatingAgeKey: true
|
||||||
|
use_yazi_picker: true
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "Updating XDG MIME and desktop databases..."
|
||||||
|
|
||||||
|
if ! update-mime-database "$HOME/.local/share/mime"; then
|
||||||
|
echo "warning: update-mime-database failed"
|
||||||
|
fi
|
||||||
|
if ! update-desktop-database "$HOME/.local/share/applications"; then
|
||||||
|
echo "warning: update-desktop-database failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
@@ -1,28 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
UPDATE="${CHEZMOI_SYSTEM_UPDATE:-0}"
|
||||||
|
|
||||||
|
# NixOS
|
||||||
{{ if eq .chezmoi.osRelease.id "nixos" }}
|
{{ if eq .chezmoi.osRelease.id "nixos" }}
|
||||||
exit 0
|
exit 0
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
set -euo pipefail
|
echo "Installing native packages..."
|
||||||
|
|
||||||
echo "Installing packages..."
|
|
||||||
|
|
||||||
|
# Arch-based
|
||||||
{{ if or (eq .chezmoi.osRelease.id "arch") (eq .chezmoi.osRelease.id "cachyos") }}
|
{{ if or (eq .chezmoi.osRelease.id "arch") (eq .chezmoi.osRelease.id "cachyos") }}
|
||||||
sudo pacman -Sy --noconfirm
|
|
||||||
|
|
||||||
|
if [ "$UPDATE" = "1" ]; then
|
||||||
|
sudo pacman -Syu --noconfirm
|
||||||
|
else
|
||||||
|
echo "Skipping system refresh+upgrade (CHEZMOI_SYSTEM_UPDATE!=1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install packages
|
||||||
pkgs=()
|
pkgs=()
|
||||||
{{ range .packages.arch }}
|
{{ range .packages.arch }}
|
||||||
if ! pacman -Q "{{ . }}" &>/dev/null; then
|
pacman -Q "{{ . }}" &>/dev/null || pkgs+=("{{ . }}")
|
||||||
pkgs+=("{{ . }}")
|
|
||||||
fi
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
((${#pkgs[@]})) && sudo pacman -S --noconfirm --needed "${pkgs[@]}"
|
||||||
|
|
||||||
if [[ ${#pkgs[@]} -gt 0 ]]; then
|
# Paru + AUR
|
||||||
echo "Installing pacman packages..."
|
|
||||||
sudo pacman -S --noconfirm --needed "${pkgs[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install paru
|
|
||||||
if command -v paru >/dev/null 2>&1; then
|
if command -v paru >/dev/null 2>&1; then
|
||||||
echo "Paru is already installed."
|
echo "Paru is already installed."
|
||||||
else
|
else
|
||||||
@@ -35,18 +39,96 @@ else
|
|||||||
rm -rf "$build_dir"
|
rm -rf "$build_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install AUR pkgs
|
# Updates only when requested, otherwise install packages that are missing and leave the installed version.
|
||||||
aur_pkgs=()
|
aur_pkgs=()
|
||||||
{{ range .packages.aur }}
|
{{ range .packages.aur }}
|
||||||
if ! pacman -Q "{{ . }}" &>/dev/null; then
|
name="{{ . }}"
|
||||||
aur_pkgs+=("{{ . }}")
|
if [ "$UPDATE" = "1" ] || ! pacman -Q "$name" &>/dev/null; then
|
||||||
|
aur_pkgs+=("$name")
|
||||||
fi
|
fi
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
|
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
|
||||||
echo "Installing AUR packages"
|
if [ "$UPDATE" = "1" ]; then
|
||||||
|
echo "Installing latest AUR packages..."
|
||||||
|
paru -Su --noconfirm
|
||||||
paru -S --noconfirm --needed "${aur_pkgs[@]}"
|
paru -S --noconfirm --needed "${aur_pkgs[@]}"
|
||||||
|
else
|
||||||
|
echo "Installing AUR packages..."
|
||||||
|
paru -S --noconfirm --needed "${aur_pkgs[@]}"
|
||||||
|
fi
|
||||||
|
elif [ "$UPDATE" != "1" ]; then
|
||||||
|
echo "Skipping AUR upgrades (CHEZMOI_SYSTEM_UPDATE!=1)"
|
||||||
fi
|
fi
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
# Go packages
|
||||||
|
go_pkgs=()
|
||||||
|
|
||||||
|
if ! command -v go >/dev/null 2>&1; then
|
||||||
|
echo "Go is not installed, skipping packages installation..."
|
||||||
|
else
|
||||||
|
# Install packages
|
||||||
|
{{ range .packages.go }}
|
||||||
|
name="{{ .id }}"
|
||||||
|
|
||||||
|
# Update package version
|
||||||
|
version=""
|
||||||
|
if [ "$UPDATE" = "1" ]; then
|
||||||
|
version="latest"
|
||||||
|
else
|
||||||
|
version="{{ .version | default "latest" }}" # default to latest instead of fail
|
||||||
|
fi
|
||||||
|
go install "${name}@${version}"
|
||||||
|
{{ end }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Nix packages
|
||||||
|
if ! command -v nix > /dev/null 2>&1; then
|
||||||
|
echo "Nix is not installed, skipping packages installation..."
|
||||||
|
else
|
||||||
|
FLAKE_DIR="$HOME/.config/nixpkgs"
|
||||||
|
|
||||||
|
# Latest bumps flake.lock, (same as for go), otherwise install from the existing lock.
|
||||||
|
if [ -d "$FLAKE_DIR" ] && [ -f "$FLAKE_DIR/flake.nix" ]; then
|
||||||
|
if [ "$UPDATE" = "1" ]; then
|
||||||
|
echo "Updating Nix packages to latest..."
|
||||||
|
nix flake update --flake "$FLAKE_DIR"
|
||||||
|
nix profile upgrade --all
|
||||||
|
nix profile install "$FLAKE_DIR" || true
|
||||||
|
else
|
||||||
|
echo "Skipping Nix profile upgrade (CHEZMOI_SYSTEM_UPDATE!=1)"
|
||||||
|
if [ -f "$FLAKE_DIR/flake.lock" ]; then
|
||||||
|
nix profile install --no-update-lock-file "$FLAKE_DIR" || true
|
||||||
|
else
|
||||||
|
nix profile install "$FLAKE_DIR" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Flatpak
|
||||||
|
if ! command -v flatpak > /dev/null 2>&1; then
|
||||||
|
echo "Flatpak not installed, skipping apps installation..."
|
||||||
|
else
|
||||||
|
if [ "$UPDATE" = "1" ]; then
|
||||||
|
flatpak update -y --noninteractive
|
||||||
|
else
|
||||||
|
echo "Skipping Flatpak update (CHEZMOI_SYSTEM_UPDATE!=1)"
|
||||||
|
fi
|
||||||
|
{{ range .packages.flatpak_remotes }}
|
||||||
|
flatpak remote-add --if-not-exists --system "{{ .name }}" "{{ .url }}" || true
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range .packages.flatpak }}
|
||||||
|
remote="{{ .remote | default "flathub" }}"
|
||||||
|
branch="{{ .branch | default "stable" }}"
|
||||||
|
app="{{ .id }}"
|
||||||
|
if ! flatpak info --system "$app//$branch" &>/dev/null; then
|
||||||
|
echo "Installing Flatpak: $app ($remote/$branch)"
|
||||||
|
flatpak install -y --system --noninteractive "$remote" "$app//$branch"
|
||||||
|
fi
|
||||||
|
{{ end }}
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 990 KiB |
@@ -39,6 +39,7 @@ shell zsh -l
|
|||||||
editor .
|
editor .
|
||||||
close_on_child_death no
|
close_on_child_death no
|
||||||
allow_hyperlinks yes
|
allow_hyperlinks yes
|
||||||
|
enabled_layouts splits
|
||||||
|
|
||||||
# Keymaps
|
# Keymaps
|
||||||
map ctrl+a>q close_window
|
map ctrl+a>q close_window
|
||||||
@@ -55,8 +56,15 @@ map ctrl+a>j neighboring_window down
|
|||||||
map ctrl+a>k neighboring_window up
|
map ctrl+a>k neighboring_window up
|
||||||
map ctrl+a>l neighboring_window right
|
map ctrl+a>l neighboring_window right
|
||||||
|
|
||||||
map ctrl+a>left resize_window narrower
|
# Resize window
|
||||||
map ctrl+a>right resize_window wider
|
map --new-mode resize --timeout 0 kitty_mod+r
|
||||||
map ctrl+a>up resize_window taller
|
map --mode resize escape pop_keyboard_mode
|
||||||
map ctrl+a>down resize_window shorter 3
|
map --mode resize ctrl+c pop_keyboard_mode
|
||||||
map ctrl+a>home resize_window reset
|
map --mode resize left resize_window narrower 2
|
||||||
|
map --mode resize right resize_window wider 2
|
||||||
|
map --mode resize up resize_window taller 2
|
||||||
|
map --mode resize down resize_window shorter 2
|
||||||
|
|
||||||
|
# Yank from screen
|
||||||
|
env read_from_login_shell=NVIM_APPNAME
|
||||||
|
map ctrl+a>y launch --type=overlay --env NVIM_APPNAME=${NVIM_APPNAME} --stdin-source=@screen_scrollback --stdin-add-formatting nvim -c 'luafile ~/.config/kitty/scrollback.lua' -
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
local buffer = 0
|
||||||
|
local table = table.concat(vim.api.nvim_buf_get_lines(buffer, 0, -1, false), "\n")
|
||||||
|
|
||||||
|
if table ~= "" and table:sub(-1) ~= "\n" then
|
||||||
|
table = table .. "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, 0, -1, false, {})
|
||||||
|
local channel = vim.api.nvim_open_term(buffer, {})
|
||||||
|
vim.api.nvim_chan_send(channel, table)
|
||||||
|
vim.bo.modified = false
|
||||||
|
vim.opt.clipboard = "unnamedplus"
|
||||||
|
vim.api.nvim_create_autocmd("TextYankPost", { buffer = buffer, callback = function() vim.schedule(function() vim.cmd("qa!") end) end })
|
||||||
|
vim.api.nvim_create_autocmd("QuitPre", { buffer = buffer, callback = function() vim.bo.modified = false end })
|
||||||
|
vim.cmd("normal! G")
|
||||||
+28
-21
@@ -1,14 +1,14 @@
|
|||||||
[Added Associations]
|
[Added Associations]
|
||||||
application/json=vim.desktop;
|
application/json=nvim.desktop;
|
||||||
application/pdf=librewolf.desktop;
|
application/pdf=librewolf.desktop;
|
||||||
application/x-docbook+xml=vim.desktop;
|
application/x-docbook+xml=nvim.desktop;
|
||||||
application/x-matroska=mpv.desktop;
|
application/x-matroska=mpv.desktop;
|
||||||
application/x-osu!lazer=osu-lazer.desktop;
|
application/x-osu-lazer=osu-lazer.desktop;
|
||||||
application/x-yaml=vim.desktop;
|
application/x-yaml=nvim.desktop;
|
||||||
text/html=librewolf.desktop;
|
text/html=librewolf.desktop;
|
||||||
text/markdown=vim.desktop;
|
text/markdown=nvim.desktop;
|
||||||
text/plain=vim.desktop;
|
text/plain=nvim.desktop;
|
||||||
text/x-cmake=vim.desktop;
|
text/x-cmake=nvim.desktop;
|
||||||
video/3gp=mpv.desktop;
|
video/3gp=mpv.desktop;
|
||||||
video/3gpp=mpv.desktop;
|
video/3gpp=mpv.desktop;
|
||||||
video/3gpp2=mpv.desktop;
|
video/3gpp2=mpv.desktop;
|
||||||
@@ -45,20 +45,28 @@ x-scheme-handler/http=librewolf.desktop;
|
|||||||
x-scheme-handler/https=librewolf.desktop;
|
x-scheme-handler/https=librewolf.desktop;
|
||||||
|
|
||||||
[Default Applications]
|
[Default Applications]
|
||||||
application/json=vim.desktop;
|
application/json=nvim.desktop;
|
||||||
application/pdf=librewolf.desktop;
|
application/pdf=librewolf.desktop;
|
||||||
application/x-docbook+xml=vim.desktop;
|
application/x-docbook+xml=nvim.desktop;
|
||||||
application/x-matroska=mpv.desktop;
|
application/x-matroska=mpv.desktop;
|
||||||
application/x-osu!lazer=osu-lazer.desktop;
|
application/x-osu-lazer=osu-lazer.desktop;
|
||||||
application/x-osu-lazer='osu!lazer.desktop';
|
application/x-yaml=nvim.desktop;
|
||||||
application/x-yaml=vim.desktop;
|
image/bmp=org.gnome.gThumb.desktop;
|
||||||
|
image/gif=org.gnome.gThumb.desktop;
|
||||||
|
image/jpeg=org.gnome.gThumb.desktop;
|
||||||
|
image/jpg=org.gnome.gThumb.desktop;
|
||||||
|
image/png=org.gnome.gThumb.desktop;
|
||||||
|
image/svg+xml=org.gnome.gThumb.desktop;
|
||||||
|
image/tiff=org.gnome.gThumb.desktop;
|
||||||
|
image/webp=org.gnome.gThumb.desktop;
|
||||||
|
inode/directory=org.gnome.Nautilus.desktop;
|
||||||
text/html=librewolf.desktop;
|
text/html=librewolf.desktop;
|
||||||
text/markdown=vim.desktop;
|
text/markdown=nvim.desktop;
|
||||||
text/plain=vim.desktop;
|
text/plain=nvim.desktop;
|
||||||
text/x-cmake=vim.desktop;
|
text/x-cmake=nvim.desktop;
|
||||||
video/3gp=mpv.desktop;
|
video/3gp=mpv.desktop;
|
||||||
video/3gpp=mpv.desktop;
|
|
||||||
video/3gpp2=mpv.desktop;
|
video/3gpp2=mpv.desktop;
|
||||||
|
video/3gpp=mpv.desktop;
|
||||||
video/avi=mpv.desktop;
|
video/avi=mpv.desktop;
|
||||||
video/divx=mpv.desktop;
|
video/divx=mpv.desktop;
|
||||||
video/dv=mpv.desktop;
|
video/dv=mpv.desktop;
|
||||||
@@ -84,15 +92,14 @@ video/x-ms-asf=mpv.desktop;
|
|||||||
video/x-ms-wmv=mpv.desktop;
|
video/x-ms-wmv=mpv.desktop;
|
||||||
video/x-ms-wmx=mpv.desktop;
|
video/x-ms-wmx=mpv.desktop;
|
||||||
video/x-msvideo=mpv.desktop;
|
video/x-msvideo=mpv.desktop;
|
||||||
video/x-ogm=mpv.desktop;
|
|
||||||
video/x-ogm+ogg=mpv.desktop;
|
video/x-ogm+ogg=mpv.desktop;
|
||||||
video/x-theora=mpv.desktop;
|
video/x-ogm=mpv.desktop;
|
||||||
video/x-theora+ogg=mpv.desktop;
|
video/x-theora+ogg=mpv.desktop;
|
||||||
|
video/x-theora=mpv.desktop;
|
||||||
x-scheme-handler/bitwarden=bitwarden.desktop
|
x-scheme-handler/bitwarden=bitwarden.desktop
|
||||||
x-scheme-handler/clash=koala-clash.desktop
|
|
||||||
x-scheme-handler/discord=vesktop.desktop
|
|
||||||
x-scheme-handler/discord-1216669957799018608=discord-1216669957799018608.desktop
|
x-scheme-handler/discord-1216669957799018608=discord-1216669957799018608.desktop
|
||||||
x-scheme-handler/http=librewolf.desktop;
|
x-scheme-handler/http=librewolf.desktop;
|
||||||
x-scheme-handler/https=librewolf.desktop;
|
x-scheme-handler/https=librewolf.desktop;
|
||||||
x-scheme-handler/koala-clash=koala-clash-handler.desktop
|
|
||||||
x-scheme-handler/prizrak-box=prizrak-box.desktop
|
x-scheme-handler/prizrak-box=prizrak-box.desktop
|
||||||
|
x-scheme-handler/ror2mm=gale-handler.desktop
|
||||||
|
x-scheme-handler/gale=gale-handler.desktop
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
animations {
|
||||||
|
workspace-switch {
|
||||||
|
spring damping-ratio=1.0 stiffness=1000 epsilon=0.0001
|
||||||
|
}
|
||||||
|
window-open {
|
||||||
|
duration-ms 200
|
||||||
|
curve "ease-out-quad"
|
||||||
|
}
|
||||||
|
window-close {
|
||||||
|
duration-ms 200
|
||||||
|
curve "ease-out-cubic"
|
||||||
|
}
|
||||||
|
horizontal-view-movement {
|
||||||
|
spring damping-ratio=1.0 stiffness=900 epsilon=0.0001
|
||||||
|
}
|
||||||
|
window-movement {
|
||||||
|
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||||||
|
}
|
||||||
|
window-resize {
|
||||||
|
spring damping-ratio=1.0 stiffness=1000 epsilon=0.0001
|
||||||
|
}
|
||||||
|
config-notification-open-close {
|
||||||
|
spring damping-ratio=0.6 stiffness=1200 epsilon=0.001
|
||||||
|
}
|
||||||
|
screenshot-ui-open {
|
||||||
|
duration-ms 300
|
||||||
|
curve "ease-out-quad"
|
||||||
|
}
|
||||||
|
overview-open-close {
|
||||||
|
spring damping-ratio=1.0 stiffness=900 epsilon=0.0001
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// ────────────── Startup Applications ──────────────
|
||||||
|
// https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#spawn-sh-at-startup
|
||||||
|
|
||||||
|
spawn-at-startup "noctalia"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Mi
|
||||||
|
output "DP-3" {
|
||||||
|
mode "2560x1440@240.001"
|
||||||
|
position x=0 y=0
|
||||||
|
scale 1.1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Benq
|
||||||
|
output "DP-2" {
|
||||||
|
mode "1920x1080@144.001"
|
||||||
|
position x=2328 y=0
|
||||||
|
scale 1.0
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
input {
|
||||||
|
keyboard {
|
||||||
|
xkb {
|
||||||
|
layout "us,ru"
|
||||||
|
options "grp:alt_shift_toggle"
|
||||||
|
}
|
||||||
|
repeat-delay 250
|
||||||
|
repeat-rate 50
|
||||||
|
}
|
||||||
|
|
||||||
|
mouse {
|
||||||
|
accel-profile "flat"
|
||||||
|
accel-speed 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
focus-follows-mouse max-scroll-amount="0%"
|
||||||
|
workspace-auto-back-and-forth
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
binds {
|
||||||
|
// ─── Applications ───
|
||||||
|
Mod+Comma hotkey-overlay-title="Noctalia Settings" { spawn-sh "noctalia msg settings-toggle"; }
|
||||||
|
Mod+Shift+Slash hotkey-overlay-title="Niri keybinds" { show-hotkey-overlay; }
|
||||||
|
Mod+Return hotkey-overlay-title="Open Terminal: kitty" { spawn "kitty"; }
|
||||||
|
Mod+R hotkey-overlay-title="Open App Launcher: noctalia launcher" { spawn-sh "noctalia msg panel-toggle launcher"; }
|
||||||
|
Mod+B hotkey-overlay-title="Open Browser: Librewolf" { spawn "librewolf"; }
|
||||||
|
Mod+Shift+E hotkey-overlay-title="Session Menu: noctalia session" { spawn-sh "noctalia msg panel-toggle session"; }
|
||||||
|
Mod+E hotkey-overlay-title="File Manager: Nautilus" { spawn "nautilus"; }
|
||||||
|
|
||||||
|
// ─── Media Controls ───
|
||||||
|
XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "noctalia msg volume-up"; }
|
||||||
|
XF86AudioLowerVolume allow-when-locked=true { spawn-sh "noctalia msg volume-down"; }
|
||||||
|
XF86AudioMute allow-when-locked=true { spawn-sh "noctalia msg volume-mute"; }
|
||||||
|
XF86AudioMicMute allow-when-locked=true { spawn-sh "noctalia msg mic-mute"; }
|
||||||
|
XF86AudioNext allow-when-locked=true { spawn-sh "noctalia msg media next"; }
|
||||||
|
XF86AudioPrev allow-when-locked=true { spawn-sh "noctalia msg media previous"; }
|
||||||
|
XF86AudioPlay allow-when-locked=true { spawn-sh "noctalia msg media toggle"; }
|
||||||
|
XF86AudioPause allow-when-locked=true { spawn-sh "noctalia msg media toggle"; }
|
||||||
|
|
||||||
|
// ─── Brightness Controls ───
|
||||||
|
XF86MonBrightnessUp allow-when-locked=true { spawn-sh "noctalia msg brightness-up"; }
|
||||||
|
XF86MonBrightnessDown allow-when-locked=true { spawn-sh "noctalia msg brightness-down"; }
|
||||||
|
|
||||||
|
// ─── Window Movement and Focus ───
|
||||||
|
Mod+Shift+Q { close-window; }
|
||||||
|
Mod+V { switch-focus-between-floating-and-tiling; }
|
||||||
|
|
||||||
|
Mod+Home { focus-column-first; }
|
||||||
|
Mod+End { focus-column-last; }
|
||||||
|
Mod+H { focus-column-left; }
|
||||||
|
Mod+WheelScrollUp { focus-column-left; }
|
||||||
|
Mod+L { focus-column-right; }
|
||||||
|
Mod+WheelScrollDown { focus-column-right; }
|
||||||
|
Mod+K { focus-workspace-up; }
|
||||||
|
Mod+CTRL+WheelScrollUp cooldown-ms=150 { focus-workspace-up; }
|
||||||
|
Mod+J { focus-workspace-down; }
|
||||||
|
Mod+CTRL+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
|
||||||
|
|
||||||
|
Mod+CTRL+H { focus-monitor-left; }
|
||||||
|
Mod+CTRL+L { focus-monitor-right; }
|
||||||
|
|
||||||
|
Mod+Shift+K { move-window-up; }
|
||||||
|
Mod+Shift+J { move-window-down; }
|
||||||
|
Mod+Shift+H { move-column-left; }
|
||||||
|
Mod+Shift+L { move-column-right; }
|
||||||
|
|
||||||
|
Mod+Shift+CTRL+K { move-column-to-workspace-up; }
|
||||||
|
Mod+Shift+CTRL+J { move-column-to-workspace-down; }
|
||||||
|
Mod+Shift+CTRL+H { move-column-to-monitor-left; }
|
||||||
|
Mod+Shift+CTRL+L { move-column-to-monitor-right; }
|
||||||
|
|
||||||
|
// ─── Workspace Switching ───
|
||||||
|
Mod+1 { focus-workspace 1; }
|
||||||
|
Mod+2 { focus-workspace 2; }
|
||||||
|
Mod+3 { focus-workspace 3; }
|
||||||
|
Mod+4 { focus-workspace 4; }
|
||||||
|
Mod+5 { focus-workspace 5; }
|
||||||
|
Mod+6 { focus-workspace 6; }
|
||||||
|
Mod+7 { focus-workspace 7; }
|
||||||
|
Mod+8 { focus-workspace 8; }
|
||||||
|
Mod+9 { focus-workspace 9; }
|
||||||
|
|
||||||
|
Mod+Shift+1 { move-column-to-workspace 1; }
|
||||||
|
Mod+Shift+2 { move-column-to-workspace 2; }
|
||||||
|
Mod+Shift+3 { move-column-to-workspace 3; }
|
||||||
|
Mod+Shift+4 { move-column-to-workspace 4; }
|
||||||
|
Mod+Shift+5 { move-column-to-workspace 5; }
|
||||||
|
Mod+Shift+6 { move-column-to-workspace 6; }
|
||||||
|
Mod+Shift+7 { move-column-to-workspace 7; }
|
||||||
|
Mod+Shift+8 { move-column-to-workspace 8; }
|
||||||
|
Mod+Shift+9 { move-column-to-workspace 9; }
|
||||||
|
|
||||||
|
Mod+TAB { focus-workspace-previous; }
|
||||||
|
|
||||||
|
// ─── Layout Controls ───
|
||||||
|
Mod+F { expand-column-to-available-width; }
|
||||||
|
Mod+C { center-column; }
|
||||||
|
Mod+CTRL+C { center-visible-columns; }
|
||||||
|
Mod+Minus { set-column-width "-10%"; }
|
||||||
|
Mod+Equal { set-column-width "+10%"; }
|
||||||
|
Mod+Shift+Minus { set-window-height "-10%"; }
|
||||||
|
Mod+Shift+Equal { set-window-height "+10%"; }
|
||||||
|
Mod+BracketLeft hotkey-overlay-title="Consume into column" { consume-window-into-column; }
|
||||||
|
Mod+BracketRight hotkey-overlay-title="Expel from column" { expel-window-from-column; }
|
||||||
|
Mod+CTRL+K { focus-window-up; }
|
||||||
|
Mod+CTRL+J { focus-window-down; }
|
||||||
|
|
||||||
|
// ─── Modes ───
|
||||||
|
Mod+T { toggle-window-floating; }
|
||||||
|
Mod+Shift+F { fullscreen-window; }
|
||||||
|
Mod+W { toggle-column-tabbed-display; }
|
||||||
|
|
||||||
|
// ─── Emergency Escape Key ───
|
||||||
|
Mod+ESCAPE allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }
|
||||||
|
|
||||||
|
// ─── Exit / Power ───
|
||||||
|
CTRL+ALT+Delete { quit; }
|
||||||
|
Mod+Shift+P { power-off-monitors; }
|
||||||
|
Mod+O repeat=false { toggle-overview; }
|
||||||
|
|
||||||
|
// --- Discord keybinds dirty trick ---
|
||||||
|
CTRL+BracketLeft repeat=false { spawn "~/.local/scripts/discord/toggle-key.sh" "m"; }
|
||||||
|
CTRL+BracketRight repeat=false { spawn "~/.local/scripts/discord/toggle-key.sh" "d"; }
|
||||||
|
|
||||||
|
// --- Screnshot with grim+slurp+satty ---
|
||||||
|
Mod+S hotkey-overlay-title="Screenshot (region)" { spawn "~/.local/scripts/gss-screenshot.sh" "region"; }
|
||||||
|
Mod+Shift+S hotkey-overlay-title="Screenshot (monitor-focused)" { spawn "~/.local/scripts/gss-screenshot.sh" "monitor-focused"; }
|
||||||
|
Mod+Ctrl+Shift+S hotkey-overlay-title="Screenshot (monitor-all)" { spawn "~/.local/scripts/gss-screenshot.sh" "monitor-all"; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
layout {
|
||||||
|
gaps 16
|
||||||
|
center-focused-column "never"
|
||||||
|
|
||||||
|
background-color "transparent"
|
||||||
|
|
||||||
|
preset-column-widths {
|
||||||
|
proportion 0.33333
|
||||||
|
proportion 0.5
|
||||||
|
proportion 0.66667
|
||||||
|
}
|
||||||
|
|
||||||
|
struts {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
prefer-no-csd
|
||||||
|
screenshot-path null
|
||||||
|
|
||||||
|
environment {
|
||||||
|
XDG_CURRENT_DESKTOP "Niri"
|
||||||
|
GTK_USE_PORTAL "1"
|
||||||
|
QT_QPA_PLATFORM "wayland"
|
||||||
|
QT_QPA_PLATFORMTHEME "xdgdesktopportal"
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor {
|
||||||
|
xcursor-theme "capitaine-cursors"
|
||||||
|
xcursor-size 40
|
||||||
|
}
|
||||||
|
|
||||||
|
debug {
|
||||||
|
honor-xdg-activation-with-invalid-serial
|
||||||
|
}
|
||||||
|
|
||||||
|
hotkey-overlay {
|
||||||
|
skip-at-startup
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
window-rule {
|
||||||
|
geometry-corner-radius 20
|
||||||
|
clip-to-geometry true
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id="steam"
|
||||||
|
exclude title=r#"^[Ss]team$"#
|
||||||
|
open-floating true
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id="steam" title=r#"^notificationtoasts_\d+_desktop$"#
|
||||||
|
default-floating-position x=10 y=10 relative-to="bottom-right"
|
||||||
|
open-focused false
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id=r#"^steam_app_\d+$"#
|
||||||
|
|
||||||
|
open-floating false
|
||||||
|
open-fullscreen true
|
||||||
|
|
||||||
|
geometry-corner-radius 0
|
||||||
|
clip-to-geometry false
|
||||||
|
|
||||||
|
border {
|
||||||
|
off
|
||||||
|
}
|
||||||
|
shadow {
|
||||||
|
off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id="librewolf" title="Picture-in-Picture"
|
||||||
|
|
||||||
|
open-floating true
|
||||||
|
open-focused false
|
||||||
|
open-maximized false
|
||||||
|
|
||||||
|
geometry-corner-radius 0
|
||||||
|
|
||||||
|
border {
|
||||||
|
off
|
||||||
|
}
|
||||||
|
|
||||||
|
default-column-width { fixed 480; }
|
||||||
|
default-window-height { fixed 270; }
|
||||||
|
default-floating-position x=40 y=40 relative-to="bottom-right"
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id="librewolf"
|
||||||
|
match app-id="chromium"
|
||||||
|
match app-id="brave"
|
||||||
|
match app-id="prizrak-box"
|
||||||
|
match app-id="^discord.*"
|
||||||
|
match app-id="org.telegram.desktop"
|
||||||
|
match app-id="kitty"
|
||||||
|
open-maximized true
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id=r#"^com\.gabm\.satty$"#
|
||||||
|
open-floating true
|
||||||
|
min-width 800
|
||||||
|
min-height 600
|
||||||
|
}
|
||||||
|
|
||||||
|
layer-rule {
|
||||||
|
match namespace="^noctalia-wallpaper"
|
||||||
|
place-within-backdrop true
|
||||||
|
}
|
||||||
|
|
||||||
|
window-rule {
|
||||||
|
match app-id="^mpv$"
|
||||||
|
open-floating true
|
||||||
|
open-focused true
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
include "./cfg/animation.kdl"
|
||||||
|
include "./cfg/autostart.kdl"
|
||||||
|
include "./cfg/keybinds.kdl"
|
||||||
|
include "./cfg/input.kdl"
|
||||||
|
include "./cfg/display.kdl"
|
||||||
|
include "./cfg/layout.kdl"
|
||||||
|
include "./cfg/rules.kdl"
|
||||||
|
include "./cfg/misc.kdl"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
experimental-features = nix-command flakes
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
description = "Nix packages";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
packages.${system}.default = pkgs.buildEnv {
|
||||||
|
name = "user-packages";
|
||||||
|
paths = with pkgs; [
|
||||||
|
nixfmt
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
[shell]
|
||||||
|
avatar_path = "/home/benq/.face"
|
||||||
|
font_family = "Noto Sans"
|
||||||
|
setup_wizard_enabled = true
|
||||||
|
|
||||||
|
[shell.animation]
|
||||||
|
enabled = false
|
||||||
|
speed = 1.0
|
||||||
|
|
||||||
|
[shell.launcher]
|
||||||
|
app_grid = false
|
||||||
|
categories = true
|
||||||
|
compact = false
|
||||||
|
show_icons = true
|
||||||
|
sort_by_usage = true
|
||||||
|
|
||||||
|
[shell.launcher.providers.session]
|
||||||
|
global = true
|
||||||
|
|
||||||
|
[shell.mpris]
|
||||||
|
blacklist = []
|
||||||
|
|
||||||
|
[shell.panel]
|
||||||
|
transparency_mode = "solid"
|
||||||
|
control_center_placement = "attached"
|
||||||
|
launcher_placement = "floating"
|
||||||
|
launcher_position = "center"
|
||||||
|
session_placement = "floating"
|
||||||
|
session_position = "center"
|
||||||
|
|
||||||
|
[shell.shadow]
|
||||||
|
alpha = 0.55
|
||||||
|
direction = "down"
|
||||||
|
|
||||||
|
[theme]
|
||||||
|
mode = "dark"
|
||||||
|
source = "builtin"
|
||||||
|
builtin = "Catppuccin"
|
||||||
|
wallpaper_scheme = "m3-content"
|
||||||
|
|
||||||
|
[bar]
|
||||||
|
order = ["main"]
|
||||||
|
|
||||||
|
[bar.main]
|
||||||
|
position = "top"
|
||||||
|
enabled = true
|
||||||
|
thickness = 34
|
||||||
|
background_opacity = 0.0
|
||||||
|
border = "outline"
|
||||||
|
border_width = 0.0
|
||||||
|
radius = 12
|
||||||
|
concave_edge_corners = true
|
||||||
|
margin_ends = 4
|
||||||
|
margin_edge = 4
|
||||||
|
padding = 8
|
||||||
|
widget_spacing = 6
|
||||||
|
scale = 1.0
|
||||||
|
font_weight = 500
|
||||||
|
hover_highlight = true
|
||||||
|
layer = "top"
|
||||||
|
reserve_space = true
|
||||||
|
show_on_workspace_switch = true
|
||||||
|
shadow = true
|
||||||
|
contact_shadow = false
|
||||||
|
panel_overlap = 1
|
||||||
|
|
||||||
|
capsule = true
|
||||||
|
capsule_fill = "surface_variant"
|
||||||
|
capsule_opacity = 0.9
|
||||||
|
capsule_padding = 6
|
||||||
|
capsule_thickness = 0.76
|
||||||
|
|
||||||
|
[dock]
|
||||||
|
enabled = true
|
||||||
|
position = "bottom"
|
||||||
|
auto_hide = true
|
||||||
|
icon_size = 48
|
||||||
|
radius = 16
|
||||||
|
background_opacity = 0.88
|
||||||
|
shadow = true
|
||||||
|
magnification = true
|
||||||
|
magnification_scale = 1.45
|
||||||
|
pinned = []
|
||||||
|
show_running = true
|
||||||
|
show_dots = true
|
||||||
|
reserve_space = false
|
||||||
|
|
||||||
|
[desktop_widgets]
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[desktop_widgets.grid]
|
||||||
|
visible = true
|
||||||
|
cell_size = 16
|
||||||
|
major_interval = 4
|
||||||
|
|
||||||
|
[wallpaper]
|
||||||
|
enabled = true
|
||||||
|
directory = "/home/benq/Pictures/Wallpapers"
|
||||||
|
fill_mode = "crop"
|
||||||
|
transition = ["fade", "disc", "stripes", "wipe", "honeycomb"]
|
||||||
|
transition_duration = 1500.0
|
||||||
|
transition_on_startup = false
|
||||||
|
|
||||||
|
[wallpaper.automation]
|
||||||
|
enabled = false
|
||||||
|
interval_seconds = 300
|
||||||
|
order = "random"
|
||||||
|
recursive = true
|
||||||
|
|
||||||
|
[location]
|
||||||
|
address = "Saint-Petersburg"
|
||||||
|
auto_locate = false
|
||||||
|
|
||||||
|
[weather]
|
||||||
|
enabled = true
|
||||||
|
unit = "metric"
|
||||||
|
refresh_minutes = 30
|
||||||
|
effects = true
|
||||||
|
|
||||||
|
[nightlight]
|
||||||
|
enabled = true
|
||||||
|
force = true
|
||||||
|
temperature_day = 6500
|
||||||
|
temperature_night = 4577
|
||||||
|
|
||||||
|
[idle]
|
||||||
|
pre_action_fade_seconds = 5.0
|
||||||
|
|
||||||
|
[idle.behavior.lock]
|
||||||
|
enabled = true
|
||||||
|
timeout = 660.0
|
||||||
|
action = "lock"
|
||||||
|
|
||||||
|
[idle.behavior.screen-off]
|
||||||
|
enabled = true
|
||||||
|
timeout = 600.0
|
||||||
|
action = "screen_off"
|
||||||
|
|
||||||
|
[idle.behavior.lock-and-suspend]
|
||||||
|
enabled = false
|
||||||
|
timeout = 1800.0
|
||||||
|
action = "lock_and_suspend"
|
||||||
|
|
||||||
|
[notification]
|
||||||
|
position = "top_right"
|
||||||
|
background_opacity = 0.97
|
||||||
|
show_actions = true
|
||||||
|
show_app_name = true
|
||||||
|
|
||||||
|
[osd]
|
||||||
|
position = "top_right"
|
||||||
|
background_opacity = 0.97
|
||||||
|
|
||||||
|
[osd.kinds]
|
||||||
|
media = false
|
||||||
|
|
||||||
|
[brightness]
|
||||||
|
enable_ddcutil = true
|
||||||
|
|
||||||
|
[audio]
|
||||||
|
enable_overdrive = false
|
||||||
|
|
||||||
|
[system.monitor]
|
||||||
|
enabled = true
|
||||||
|
cpu_poll_seconds = 2.0
|
||||||
|
memory_poll_seconds = 2.0
|
||||||
|
disk_poll_seconds = 10.0
|
||||||
|
|
||||||
|
[lockscreen]
|
||||||
|
enabled = true
|
||||||
|
blur_intensity = 0.5
|
||||||
|
fingerprint = false
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-2"]
|
||||||
|
type = "login_box"
|
||||||
|
output = "DP-2"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-2".settings]
|
||||||
|
show_media = false
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-3"]
|
||||||
|
type = "login_box"
|
||||||
|
output = "DP-3"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-3".settings]
|
||||||
|
show_media = false
|
||||||
|
|
||||||
|
[control_center]
|
||||||
|
hidden_tabs = ["media"]
|
||||||
|
|
||||||
|
[widget.media]
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
enabled = []
|
||||||
|
|
||||||
|
[keybinds]
|
||||||
|
# use tab instead of arrows
|
||||||
|
up = ["up", "shift+tab", "shift+iso_left_tab"]
|
||||||
|
down = ["down", "tab"]
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
require("config.autocmds")
|
|
||||||
require("config.filetypes")
|
require("config.filetypes")
|
||||||
require("config.keymaps")
|
require("config.keymaps")
|
||||||
require("config.options")
|
require("config.options")
|
||||||
|
require("config.autocmds")
|
||||||
|
|
||||||
require("config.lazy")
|
require("config.lazy")
|
||||||
require("config.theme") -- ignored by git
|
require("config.theme") -- ignored by git
|
||||||
|
|
||||||
require("config.lsp")
|
|
||||||
|
|
||||||
vim.lsp.enable({
|
vim.lsp.enable({
|
||||||
"lua_ls",
|
|
||||||
"html",
|
"html",
|
||||||
|
"lua_ls",
|
||||||
|
"nil_ls",
|
||||||
"roslyn_ls",
|
"roslyn_ls",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,56 +2,53 @@
|
|||||||
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
||||||
"blink.cmp": { "branch": "main", "commit": "4b18c32adef2898f95cdef6192cbd5796c1a332d" },
|
"blink.cmp": { "branch": "main", "commit": "4b18c32adef2898f95cdef6192cbd5796c1a332d" },
|
||||||
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
|
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
|
||||||
"conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" },
|
"conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" },
|
||||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||||
"easy-dotnet.nvim": { "branch": "main", "commit": "9a761b062e911dd709c6b31e857038e6c4981654" },
|
"easy-dotnet.nvim": { "branch": "main", "commit": "9a761b062e911dd709c6b31e857038e6c4981654" },
|
||||||
"flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" },
|
"flash.nvim": { "branch": "main", "commit": "b6346946d10d07998efee029fb0f7a593806d0cd" },
|
||||||
"fzf-lua": { "branch": "main", "commit": "d9508cc1d05ffcdc91a32dfd38fc1013a56b20da" },
|
"fzf-lua": { "branch": "main", "commit": "532d463f5c83595192fe740572d8fd6902b2217a" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" },
|
"gitsigns.nvim": { "branch": "main", "commit": "eb60cc7b94c46005237fd34170d76f3a089a90aa" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||||
"lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" },
|
"lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" },
|
||||||
"lsp_signature.nvim": { "branch": "master", "commit": "af7e4074d85d785cf6614352ba9ad3b28a1f8a56" },
|
"lsp_signature.nvim": { "branch": "master", "commit": "b7ace9ddb1640ce266012a45a672dfdaedfa5ec6" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
|
"lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "a324581a3c83fdacdb9804b79de1cbe00ce18550" },
|
"markview.nvim": { "branch": "main", "commit": "2471f4097f8561a6880a0fe05ee0f21cbc82b374" },
|
||||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" },
|
|
||||||
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
|
|
||||||
"midnight.nvim": { "branch": "main", "commit": "fe062a6f2e5bd77cd8a260f61e6e12789eaf4f13" },
|
"midnight.nvim": { "branch": "main", "commit": "fe062a6f2e5bd77cd8a260f61e6e12789eaf4f13" },
|
||||||
"mini.ai": { "branch": "main", "commit": "bfb26d9072670c3aaefab0f53024b2f3729c8083" },
|
"mini.ai": { "branch": "main", "commit": "d73c36349aa7b0bab5f77ad71701a1d42211a1df" },
|
||||||
"mini.align": { "branch": "main", "commit": "4d45e0e4f1fd8baefb6ae52a44659704fe7ebe8b" },
|
"mini.align": { "branch": "main", "commit": "77d7446b9f2452193f13ced9fb73a8b3aa4a4f4d" },
|
||||||
"mini.bracketed": { "branch": "main", "commit": "75369c33613b911d1ce304475dc4d30cd255c9ed" },
|
"mini.bracketed": { "branch": "main", "commit": "203eb35f386b4fc9abcff1518c84d5537d41c80a" },
|
||||||
"mini.bufremove": { "branch": "main", "commit": "ee69f823f84508c556127a5882760d9783692023" },
|
"mini.bufremove": { "branch": "main", "commit": "281bb1a2c60c3618c854bef2c0933276eb2362c2" },
|
||||||
"mini.cursorword": { "branch": "main", "commit": "dda0f57d55bb1fa19423b7201b2ba892c7d2bb3c" },
|
"mini.cursorword": { "branch": "main", "commit": "331bc17172e41343d39d91a4ab571d510766812e" },
|
||||||
"mini.diff": { "branch": "main", "commit": "ff3cd5e76e812fa18bde0f8126d6f3bb62008c79" },
|
"mini.diff": { "branch": "main", "commit": "be4ca6953040332d77a5a05bb5600152c5c36e7a" },
|
||||||
"mini.indentscope": { "branch": "main", "commit": "0308f949f31769e509696af5d5f91cebb2159c69" },
|
"mini.indentscope": { "branch": "main", "commit": "d3f955f09b1a05d25d5a7740338fba2baaee41a3" },
|
||||||
"mini.jump": { "branch": "main", "commit": "e79d45a15097bf3a5101e917be73e9e43f80f1b7" },
|
"mini.jump": { "branch": "main", "commit": "6a1688315d69e4f8428d529e194714447b0d4e82" },
|
||||||
"mini.notify": { "branch": "main", "commit": "29ec27f60bf4b63e447c851d9061c434d80795a6" },
|
"mini.notify": { "branch": "main", "commit": "821db7d464f7a9bb8666b4ba3be7d2ed637cfcfc" },
|
||||||
"mini.pairs": { "branch": "main", "commit": "b7fde3719340946feb75017ef9d75edebdeb0566" },
|
"mini.pairs": { "branch": "main", "commit": "b1fd9df3bb4a41c8f45778a3859ee80ef6b367e3" },
|
||||||
"mini.surround": { "branch": "main", "commit": "d205d1741d1fcc1f3117b4e839bf00f74ad72fa2" },
|
"mini.surround": { "branch": "main", "commit": "c30ec60393b256427512c6996a2b37d9cbcbb66a" },
|
||||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "9d6826582a3e8c84787bd7355df22a2812a1ad59" },
|
"neo-tree.nvim": { "branch": "v3.x", "commit": "ebd66767191714e008ce73b769518a763ff31bdc" },
|
||||||
"neonuget": { "branch": "main", "commit": "bc174044b009a19a6fa39fbcb5b90ddf1f874267" },
|
"neonuget": { "branch": "main", "commit": "bc174044b009a19a6fa39fbcb5b90ddf1f874267" },
|
||||||
"neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" },
|
"neotest": { "branch": "master", "commit": "fb84d87285698f7055f618083c351984449119b8" },
|
||||||
"neotest-vstest": { "branch": "main", "commit": "0bf64ea98fc8e6ca168424ad48f13f7ff1895311" },
|
"neotest-vstest": { "branch": "main", "commit": "8588c3c988c7ed49879dddf937b42681cfa7ce30" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "ef211089af881bea206c7aa3f2693a81feee7e90" },
|
"nvim-colorizer.lua": { "branch": "master", "commit": "149fbd9f5e25511b0a8bad3ccecd43d1bc584f86" },
|
||||||
"nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" },
|
"nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" },
|
||||||
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
|
"nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "0203a9608d63eda57679b01e69f33a7b4c34b0d1" },
|
"nvim-lspconfig": { "branch": "master", "commit": "d5b6e3db4c17b0146f63a2fc47e2027a754b2cb1" },
|
||||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||||
"nvim-treesitter": { "branch": "main", "commit": "5cb05e1b0fa3c469958a2b26f36b3fe930af221c" },
|
"nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "main", "commit": "4e91b5d0394329a229725b021a8ea217099826ef" },
|
"nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "88c1453db4ba7dd24131086fe51fdf74e587d275" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
|
"nvim-web-devicons": { "branch": "master", "commit": "09d1324e264c6950262dbe02a9bce2933a6800db" },
|
||||||
"oasis.nvim": { "branch": "main", "commit": "fe388c81d31f4ae974b93619608e4e2a1e9b10a8" },
|
"oasis.nvim": { "branch": "main", "commit": "eec440927108a2eea256b70886e821986c2df008" },
|
||||||
"oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" },
|
"oil.nvim": { "branch": "master", "commit": "b73018b75affd13fa38e2fc94ef753b465f770d7" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
|
||||||
"ramboe-dotnet-utils": { "branch": "main", "commit": "051ed455e797853b548f857f895c81599803ba12" },
|
"ramboe-dotnet-utils": { "branch": "main", "commit": "a1baee01fca7aab4b238c7fe017a7e2114482d6b" },
|
||||||
"roslyn.nvim": { "branch": "main", "commit": "7deb9bb5b6afcb3c03c70741c6d364ffd8b59bda" },
|
"roslyn.nvim": { "branch": "main", "commit": "7deb9bb5b6afcb3c03c70741c6d364ffd8b59bda" },
|
||||||
"screenkey.nvim": { "branch": "main", "commit": "16390931d847b1d5d77098daccac4e55654ac9e2" },
|
"screenkey.nvim": { "branch": "main", "commit": "16390931d847b1d5d77098daccac4e55654ac9e2" },
|
||||||
"sshfs.nvim": { "branch": "main", "commit": "6071224a845d4bb6d70a0ed912797281a80e109d" },
|
"sshfs.nvim": { "branch": "main", "commit": "57f586251d788dae38fd12998b9a208f7d54c1ef" },
|
||||||
"tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "ba133b3e932416e4b9507095731a6d7276878fe8" },
|
|
||||||
"vim-dadbod": { "branch": "master", "commit": "6d1d41da4873a445c5605f2005ad2c68c99d8770" },
|
"vim-dadbod": { "branch": "master", "commit": "6d1d41da4873a445c5605f2005ad2c68c99d8770" },
|
||||||
"vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" },
|
"vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" },
|
||||||
"vim-dadbod-ui": { "branch": "master", "commit": "07e92e22114cc5b1ba4938d99897d85b58e20475" },
|
"vim-dadbod-ui": { "branch": "master", "commit": "afd07819d8efcefc3317205b855ad4e3513b0011" },
|
||||||
"vscode.nvim": { "branch": "main", "commit": "aa1102a7e15195c9cca22730b09224a7f7745ba8" },
|
"vscode.nvim": { "branch": "main", "commit": "aa1102a7e15195c9cca22730b09224a7f7745ba8" },
|
||||||
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
workspace = {
|
||||||
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---@brief
|
||||||
|
---
|
||||||
|
--- https://github.com/oxalica/nil
|
||||||
|
---
|
||||||
|
--- A new language server for Nix Expression Language.
|
||||||
|
---
|
||||||
|
--- If you are using Nix with Flakes support, run `nix profile install github:oxalica/nil` to install.
|
||||||
|
--- Check the repository README for more information.
|
||||||
|
---
|
||||||
|
--- _See an example config at https://github.com/oxalica/nil/blob/main/dev/nvim-lsp.nix._
|
||||||
|
|
||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { 'nil' },
|
||||||
|
filetypes = { 'nix' },
|
||||||
|
root_markers = { 'flake.nix', '.git' },
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
return {
|
||||||
|
cmd = {
|
||||||
|
'roslyn-language-server',
|
||||||
|
'--logLevel',
|
||||||
|
'Information',
|
||||||
|
'--extensionLogDirectory',
|
||||||
|
vim.fs.joinpath(vim.uv.os_tmpdir(), 'roslyn_ls/logs'),
|
||||||
|
'--stdio',
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
return {
|
||||||
|
cmd = {
|
||||||
|
'roslyn-language-server',
|
||||||
|
'--logLevel',
|
||||||
|
'Information',
|
||||||
|
'--extensionLogDirectory',
|
||||||
|
vim.fs.joinpath(vim.uv.os_tmpdir(), 'roslyn_ls/logs'),
|
||||||
|
'--stdio',
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
local vue_language_server_path = vim.fn.expand("~/.local/lib/node_modules/@vue/language-server")
|
||||||
|
|
||||||
|
return {
|
||||||
|
cmd = { "vtsls", "--stdio" },
|
||||||
|
init_options = {
|
||||||
|
hostInfo = "neovim",
|
||||||
|
},
|
||||||
|
filetypes = {
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"vue",
|
||||||
|
},
|
||||||
|
root_dir = function(bufnr, on_dir)
|
||||||
|
-- The project root is where the LSP can be started from
|
||||||
|
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
|
||||||
|
-- We select then from the project root, which is identified by the presence of a package
|
||||||
|
-- manager lock file.
|
||||||
|
local root_markers = { "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock" }
|
||||||
|
-- Give the root markers equal priority by wrapping them in a table
|
||||||
|
root_markers = vim.fn.has("nvim-0.11.3") == 1 and { root_markers, { ".git" } }
|
||||||
|
or vim.list_extend(root_markers, { ".git" })
|
||||||
|
-- exclude deno
|
||||||
|
local deno_root = vim.fs.root(bufnr, { "deno.json", "deno.jsonc" })
|
||||||
|
local deno_lock_root = vim.fs.root(bufnr, { "deno.lock" })
|
||||||
|
local project_root = vim.fs.root(bufnr, root_markers)
|
||||||
|
if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then
|
||||||
|
-- deno lock is closer than package manager lock, abort
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if deno_root and (not project_root or #deno_root >= #project_root) then
|
||||||
|
-- deno config is closer than or equal to package manager lock, abort
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- project is standard TS, not deno
|
||||||
|
-- We fallback to the current working directory if no project root is found
|
||||||
|
on_dir(project_root or vim.fn.getcwd())
|
||||||
|
end,
|
||||||
|
settings = {
|
||||||
|
vtsls = {
|
||||||
|
tsserver = {
|
||||||
|
globalPlugins = {
|
||||||
|
{
|
||||||
|
name = "@vue/typescript-plugin",
|
||||||
|
location = vue_language_server_path,
|
||||||
|
languages = { "vue" },
|
||||||
|
configNamespace = "typescript",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -3,16 +3,22 @@ vim.api.nvim_create_autocmd("TextYankPost", {
|
|||||||
desc = "Highlight in yanking",
|
desc = "Highlight in yanking",
|
||||||
group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }),
|
group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.hl.hl_op({
|
||||||
|
higroup = 'IncSearch',
|
||||||
|
timeout = 100,
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
vim.keymap.del('n', "gra")
|
local function safe_del(mode, lhs)
|
||||||
vim.keymap.del('n', "gri")
|
pcall(vim.keymap.del, mode, lhs)
|
||||||
vim.keymap.del('n', "grn")
|
end
|
||||||
vim.keymap.del('n', "grr")
|
safe_del('n', "gra")
|
||||||
vim.keymap.del('n', "grt")
|
safe_del('n', "gri")
|
||||||
|
safe_del('n', "grn")
|
||||||
|
safe_del('n', "grr")
|
||||||
|
safe_del('n', "grt")
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = vim.api.nvim_create_augroup("LspKeymaps", { clear = true }),
|
group = vim.api.nvim_create_augroup("LspKeymaps", { clear = true }),
|
||||||
@@ -38,3 +44,69 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
map("<leader>K", vim.lsp.buf.hover, "Hover documentation")
|
map("<leader>K", vim.lsp.buf.hover, "Hover documentation")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Floating terminal
|
||||||
|
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
|
||||||
|
|
||||||
|
local state = {
|
||||||
|
floating = {
|
||||||
|
buf = -1,
|
||||||
|
win = -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function create_floating_window(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local width = opts.width or math.floor(vim.o.columns * 0.8)
|
||||||
|
local height = opts.height or math.floor(vim.o.lines * 0.8)
|
||||||
|
|
||||||
|
local col = math.floor((vim.o.columns - width) / 2)
|
||||||
|
local row = math.floor((vim.o.lines - height) / 2)
|
||||||
|
|
||||||
|
local buf = nil
|
||||||
|
if vim.api.nvim_buf_is_valid(opts.buf) then
|
||||||
|
buf = opts.buf
|
||||||
|
else
|
||||||
|
buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local win_config = {
|
||||||
|
relative = "editor",
|
||||||
|
width = width,
|
||||||
|
height = height,
|
||||||
|
col = col,
|
||||||
|
row = row,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
}
|
||||||
|
|
||||||
|
local win = vim.api.nvim_open_win(buf, true, win_config)
|
||||||
|
|
||||||
|
return { buf = buf, win = win }
|
||||||
|
end
|
||||||
|
|
||||||
|
local toggle_terminal = function()
|
||||||
|
if not vim.api.nvim_win_is_valid(state.floating.win) then
|
||||||
|
state.floating = create_floating_window { buf = state.floating.buf }
|
||||||
|
if vim.bo[state.floating.buf].buftype ~= "terminal" then
|
||||||
|
vim.cmd.terminal()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
vim.api.nvim_win_hide(state.floating.win)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("FloatingTerminal", toggle_terminal, {})
|
||||||
|
vim.keymap.set({ "n", "t" }, "<leader>tt", toggle_terminal, { desc = "Toggle floating terminal" })
|
||||||
|
|
||||||
|
-- Make flash.nvim not trigger in quicklist buffers
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "qf",
|
||||||
|
callback = function(event)
|
||||||
|
vim.keymap.set("n", "<CR>", function()
|
||||||
|
local info = vim.fn.getwininfo(vim.api.nvim_get_current_win())[1]
|
||||||
|
vim.cmd(info.loclist == 1 and ".ll" or ".cc")
|
||||||
|
end, { buffer = event.buf, desc = "Open list entry" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -1,3 +1,28 @@
|
|||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = {
|
||||||
|
spacing = 2,
|
||||||
|
source = "if_many",
|
||||||
|
prefix = "●",
|
||||||
|
},
|
||||||
|
signs = true,
|
||||||
|
update_in_insert = true,
|
||||||
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
border = "rounded",
|
||||||
|
source = true,
|
||||||
|
},
|
||||||
|
jump = {
|
||||||
|
wrap = true,
|
||||||
|
on_jump = function(_, bufnr)
|
||||||
|
vim.diagnostic.open_float({
|
||||||
|
bufnr = bufnr,
|
||||||
|
scope = "cursor",
|
||||||
|
focus = false,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
vim.fn.sign_define('DapBreakpoint', {
|
vim.fn.sign_define('DapBreakpoint', {
|
||||||
text = '⚪',
|
text = '⚪',
|
||||||
texthl = 'DapBreakpointSymbol',
|
texthl = 'DapBreakpointSymbol',
|
||||||
|
|||||||
@@ -10,8 +10,19 @@ vim.keymap.set("n", "<ESC>",
|
|||||||
end,
|
end,
|
||||||
{ desc = "Clear search highlight" })
|
{ desc = "Clear search highlight" })
|
||||||
|
|
||||||
-- Toggle whitespace characters
|
-- Move current line/selection up/down
|
||||||
vim.keymap.set('n', '<leader>w', function()
|
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down", silent = true })
|
||||||
|
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up", silent = true })
|
||||||
|
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down", silent = true })
|
||||||
|
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up", silent = true })
|
||||||
|
|
||||||
|
-- Buffers
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>bn", "<cmd>enew<cr>", { desc = "New buffer" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>bd", "<cmd>bdelete<cr>", { desc = "Close buffer" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>bD", "<cmd>bdelete!<cr>", { desc = "Close buffer (force)" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
||||||
|
vim.keymap.set('n', '<leader>bw', function()
|
||||||
if vim.wo.list then
|
if vim.wo.list then
|
||||||
vim.wo.list = false
|
vim.wo.list = false
|
||||||
else
|
else
|
||||||
@@ -27,26 +38,13 @@ vim.keymap.set('n', '<leader>w', function()
|
|||||||
end
|
end
|
||||||
end, { desc = 'Toggle whitespace characters' })
|
end, { desc = 'Toggle whitespace characters' })
|
||||||
|
|
||||||
-- Move current line/selection up/down
|
|
||||||
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down", silent = true })
|
|
||||||
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up", silent = true })
|
|
||||||
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down", silent = true })
|
|
||||||
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up", silent = true })
|
|
||||||
|
|
||||||
-- Buffers
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>bn", "<cmd>enew<cr>", { desc = "New buffer" })
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>bd", "<cmd>bdelete<cr>", { desc = "Close buffer" })
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>bD", "<cmd>bdelete!<cr>", { desc = "Close buffer (force)" })
|
|
||||||
vim.keymap.set({ "n", "v" }, "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
|
||||||
vim.keymap.set({ "n", "v" }, "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
|
||||||
|
|
||||||
-- Tabs
|
-- Tabs
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>n", "<cmd>tabnew<cr>", { desc = "New tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>n", "<cmd>tabnew<cr>", { desc = "New tab" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close tab" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next tab" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>[", "<cmd>tabprevious<cr>", { desc = "Previous tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>[", "<cmd>tabprevious<cr>", { desc = "Previous tab" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>h", "<cmd>tabmove -1<cr>", { desc = "Move tab left" })
|
||||||
vim.keymap.set({ "n", "v" }, "<leader><tab>f", "<cmd>tabfirst<cr>", { desc = "First tab" })
|
vim.keymap.set({ "n", "v" }, "<leader><tab>l", "<cmd>tabmove +1<cr>", { desc = "Move tab right" })
|
||||||
|
|
||||||
-- Windows
|
-- Windows
|
||||||
vim.keymap.set({ "n", "v" }, "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
vim.keymap.set({ "n", "v" }, "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
||||||
@@ -58,7 +56,11 @@ vim.keymap.set("n", "<C-w>-", "<cmd>split<cr>", { desc = "Split window horizonta
|
|||||||
vim.keymap.set("n", "<C-w>|", "<cmd>vsplit<cr>", { desc = "Split window vertically" })
|
vim.keymap.set("n", "<C-w>|", "<cmd>vsplit<cr>", { desc = "Split window vertically" })
|
||||||
|
|
||||||
-- Diagnostics
|
-- Diagnostics
|
||||||
vim.keymap.set('n', "<leader>ld", vim.diagnostic.open_float, { desc = "Show line diagnostics" })
|
vim.keymap.set("n", "<leader>ld", vim.diagnostic.open_float, { desc = "Show line diagnostics" })
|
||||||
|
vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = vim.v.count1 }) end, { desc = "Next diagnostic" })
|
||||||
|
vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = -vim.v.count1 }) end, { desc = "Previous diagnostic" })
|
||||||
|
vim.keymap.set("n", "]D", function() vim.diagnostic.jump({ count = math.huge, wrap = false }) end, { desc = "Last diagnostic" })
|
||||||
|
vim.keymap.set("n", "[D", function() vim.diagnostic.jump({ count = -math.huge, wrap = false }) end, { desc = "First diagnostic" })
|
||||||
|
|
||||||
-- Quickfix
|
-- Quickfix
|
||||||
vim.keymap.set("n", "<leader>q",
|
vim.keymap.set("n", "<leader>q",
|
||||||
@@ -78,5 +80,6 @@ vim.keymap.set("n", "<leader>q",
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{ desc = "Toggle quickfix" })
|
{ desc = "Toggle quickfix" })
|
||||||
|
|
||||||
vim.keymap.set("n", "[q", "<cmd>cprev<CR>", { desc = "Previous quickfix item" })
|
vim.keymap.set("n", "[q", "<cmd>cprev<CR>", { desc = "Previous quickfix item" })
|
||||||
vim.keymap.set("n", "]q", "<cmd>cnext<CR>", { desc = "Next quickfix item" })
|
vim.keymap.set("n", "]q", "<cmd>cnext<CR>", { desc = "Next quickfix item" })
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
||||||
|
|
||||||
vim.lsp.config("html", {
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
@@ -1 +1,4 @@
|
|||||||
vim.cmd.colorscheme("vscode")
|
vim.cmd.colorscheme("vscode")
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "@lsp.type.extensionMethod", { link = "@function.method" })
|
||||||
|
vim.api.nvim_set_hl(0, "@lsp.type.extensionMethod.cs", { link = "@function.method" })
|
||||||
@@ -27,7 +27,7 @@ return {
|
|||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
mode = { "n", "v" },
|
mode = { "n", "v" },
|
||||||
"<leader>cF",
|
"<leader>bF",
|
||||||
function()
|
function()
|
||||||
require("conform").format({ async = true, lsp_fallback = true })
|
require("conform").format({ async = true, lsp_fallback = true })
|
||||||
end,
|
end,
|
||||||
@@ -35,7 +35,7 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
mode = "n",
|
mode = "n",
|
||||||
"<leader>cf",
|
"<leader>bf",
|
||||||
function()
|
function()
|
||||||
local start_line = vim.fn.line(".")
|
local start_line = vim.fn.line(".")
|
||||||
local end_line = start_line
|
local end_line = start_line
|
||||||
|
|||||||
@@ -7,17 +7,22 @@ return {
|
|||||||
require("nvim-treesitter").install({
|
require("nvim-treesitter").install({
|
||||||
"bash",
|
"bash",
|
||||||
"c",
|
"c",
|
||||||
"caddy",
|
|
||||||
"c_sharp",
|
"c_sharp",
|
||||||
|
"caddy",
|
||||||
"css",
|
"css",
|
||||||
"csv",
|
"csv",
|
||||||
"html",
|
"html",
|
||||||
"javascript",
|
"javascript",
|
||||||
"json",
|
"json",
|
||||||
|
"latex",
|
||||||
|
"markdown",
|
||||||
|
"markdown_inline",
|
||||||
"nix",
|
"nix",
|
||||||
"sql",
|
"sql",
|
||||||
"typescript",
|
"typescript",
|
||||||
|
"typst",
|
||||||
"vimdoc",
|
"vimdoc",
|
||||||
|
"yaml",
|
||||||
"zsh",
|
"zsh",
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
@@ -29,18 +34,36 @@ return {
|
|||||||
vim.g.no_plugin_maps = true
|
vim.g.no_plugin_maps = true
|
||||||
end,
|
end,
|
||||||
opts = {
|
opts = {
|
||||||
-- select = {
|
},
|
||||||
-- enable = true,
|
keys = {
|
||||||
-- lookahead = true,
|
{
|
||||||
-- keymaps = {
|
"<leader>a",
|
||||||
-- ["aa"] = "@parameter.outer",
|
function()
|
||||||
-- ["ia"] = "@parameter.inner",
|
require("nvim-treesitter-textobjects.swap").swap_next("@parameter.inner")
|
||||||
-- ["af"] = "@function.outer",
|
end,
|
||||||
-- ["if"] = "@function.inner",
|
desc = "Swap argument with next",
|
||||||
-- ["ac"] = "@class.outer",
|
},
|
||||||
-- ["ic"] = "@class.inner",
|
{
|
||||||
-- }
|
"<leader>A",
|
||||||
-- },
|
function()
|
||||||
|
require("nvim-treesitter-textobjects.swap").swap_previous("@parameter.inner")
|
||||||
|
end,
|
||||||
|
desc = "Swap argument with previous",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"]a",
|
||||||
|
function()
|
||||||
|
require("nvim-treesitter-textobjects.move").goto_next_start("@parameter.inner", "textobjects")
|
||||||
|
end,
|
||||||
|
desc = "Next argument",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"[a",
|
||||||
|
function()
|
||||||
|
require("nvim-treesitter-textobjects.move").goto_previous_start("@parameter.inner", "textobjects")
|
||||||
|
end,
|
||||||
|
desc = "Previous argument",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
|
local function search_in_root()
|
||||||
|
local oil_ok, oil = pcall(require, "oil")
|
||||||
|
if oil_ok and vim.bo.filetype == "oil" then
|
||||||
|
return oil.get_current_dir()
|
||||||
|
end
|
||||||
|
local buf = vim.api.nvim_buf_get_name(0)
|
||||||
|
if buf ~= "" and vim.fn.filereadable(buf) == 1 then
|
||||||
|
return vim.fn.fnamemodify(buf, ":p:h")
|
||||||
|
end
|
||||||
|
return vim.fn.getcwd()
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ibhagwan/fzf-lua",
|
"ibhagwan/fzf-lua",
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
@@ -21,11 +33,21 @@ return {
|
|||||||
function() require("fzf-lua").files() end,
|
function() require("fzf-lua").files() end,
|
||||||
desc="Find files in project directory"
|
desc="Find files in project directory"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"<leader>fF",
|
||||||
|
function() require("fzf-lua").files({ cwd = search_in_root() }) end,
|
||||||
|
desc="Find files in current buffer's directory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"<leader>fg",
|
"<leader>fg",
|
||||||
function() require("fzf-lua").live_grep() end,
|
function() require("fzf-lua").live_grep() end,
|
||||||
desc="Find by grepping in project directory"
|
desc="Find by grepping in project directory"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"<leader>fG",
|
||||||
|
function() require("fzf-lua").live_grep({ cwd = search_in_root() }) end,
|
||||||
|
desc="Find by grepping in current buffer's directory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"<leader>fc",
|
"<leader>fc",
|
||||||
function() require("fzf-lua").files({cwd=vim.fn.stdpath("config")}) end,
|
function() require("fzf-lua").files({cwd=vim.fn.stdpath("config")}) end,
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
"OXY2DEV/markview.nvim",
|
||||||
|
lazy = false,
|
||||||
|
opts = {},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>bm", "<cmd>Markview toggle<cr>", desc = "Toggle markview for buffer" },
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
return {
|
||||||
|
"seblyng/roslyn.nvim",
|
||||||
|
---@module 'roslyn.config'
|
||||||
|
---@type RoslynNvimConfig
|
||||||
|
opts = {},
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
return {
|
return {
|
||||||
"akinsho/bufferline.nvim",
|
"akinsho/bufferline.nvim",
|
||||||
|
lazy = false,
|
||||||
version = "*",
|
version = "*",
|
||||||
dependencies = "nvim-tree/nvim-web-devicons",
|
dependencies = "nvim-tree/nvim-web-devicons",
|
||||||
opts = {}
|
opts = {},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>bh", "<cmd>BufferLineMovePrev<cr>", desc = "Move buffer left" },
|
||||||
|
{ "<leader>bl", "<cmd>BufferLineMoveNext<cr>", desc = "Move buffer right" },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,4 @@ return {
|
|||||||
"nvim-mini/mini.notify",
|
"nvim-mini/mini.notify",
|
||||||
version = "*",
|
version = "*",
|
||||||
opts = {},
|
opts = {},
|
||||||
keys = {
|
|
||||||
{ "<ESC>", function() require("mini.notify").clear() end, desc = "Clear notification popup" },
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
return {
|
|
||||||
"rachartier/tiny-inline-diagnostic.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
|
||||||
require("tiny-inline-diagnostic").setup({
|
|
||||||
preset = "classic",
|
|
||||||
options = {
|
|
||||||
add_messages = {
|
|
||||||
disaplay_count = true
|
|
||||||
},
|
|
||||||
multilines = {
|
|
||||||
enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[general]
|
||||||
|
copy-command = "wl-copy"
|
||||||
|
actions-on-enter = ["save-to-clipboard", "save-to-file", "exit"]
|
||||||
|
actions-on-escape = ["exit"]
|
||||||
|
early-exit = ["copy", "save"]
|
||||||
@@ -2,20 +2,42 @@ benq-password: ENC[AES256_GCM,data:j5G3ozD5zPh2YQlkeT0YH7tQtrVl71O1d29d8yb7/TEAr
|
|||||||
private-keys:
|
private-keys:
|
||||||
- gh: ENC[AES256_GCM,data:saw/50s9ev0iFcciFzzhKDbyAFf94XbUd7cWDULZDYsv2S6/YrH63nKc7vLrqLtIZjleo1WBaAMMI71uHcEgLrbIRi3/ncJ/YaEuR4TpiMPcpT2cTXi82qp/cDGB/fazFzNyuXjXq8iZkmUCfbOVb5NYtfiLoZmg5vOUn2Ht9RZGC7x753C8e/9PVNcHH1Osn+kFkB7UisPCYESNoYWjr5Wa8alGyUo6bw3bW2M8ztPwE7YygCTu0mdrurmdybjluovJrAu+GfiU+z6g8SoQeGfjmEhmBsIE9oFh+pXt7vov3LZIQ1h2u5C/rkhZF0l6LD7anMzNFOOUCUiwOrMBi77iIHPmbmpvft6mtFPleMYU6+IQEnMUlu2Dk5ZX+3mR+WXvEQKP2gThRjlfTg47JMqicpXa/KIq6n+HF4RXum1T5bQjlIc7Ld10dE0JkCWN/ZBy4IIcVGSZjvnHVaDPZw34pAM9OXdEsZOt1to4S/P6YAdGriSk4pWgEOV3Wum5ntR77oA6QhMw8vE2o/MA,iv:lwlezQnZQ0XD7QiWZkeUrPppNJ+XBRRd/3v5uhhGLto=,tag:kxBC3AmFhj8B25CztFBNgg==,type:str]
|
- gh: ENC[AES256_GCM,data:saw/50s9ev0iFcciFzzhKDbyAFf94XbUd7cWDULZDYsv2S6/YrH63nKc7vLrqLtIZjleo1WBaAMMI71uHcEgLrbIRi3/ncJ/YaEuR4TpiMPcpT2cTXi82qp/cDGB/fazFzNyuXjXq8iZkmUCfbOVb5NYtfiLoZmg5vOUn2Ht9RZGC7x753C8e/9PVNcHH1Osn+kFkB7UisPCYESNoYWjr5Wa8alGyUo6bw3bW2M8ztPwE7YygCTu0mdrurmdybjluovJrAu+GfiU+z6g8SoQeGfjmEhmBsIE9oFh+pXt7vov3LZIQ1h2u5C/rkhZF0l6LD7anMzNFOOUCUiwOrMBi77iIHPmbmpvft6mtFPleMYU6+IQEnMUlu2Dk5ZX+3mR+WXvEQKP2gThRjlfTg47JMqicpXa/KIq6n+HF4RXum1T5bQjlIc7Ld10dE0JkCWN/ZBy4IIcVGSZjvnHVaDPZw34pAM9OXdEsZOt1to4S/P6YAdGriSk4pWgEOV3Wum5ntR77oA6QhMw8vE2o/MA,iv:lwlezQnZQ0XD7QiWZkeUrPppNJ+XBRRd/3v5uhhGLto=,tag:kxBC3AmFhj8B25CztFBNgg==,type:str]
|
||||||
- benq: ENC[AES256_GCM,data:l944rSd2vmQvkrCqpQM2PywYBkypg/iWOo9LFuUi6I7PWAQc0rAwnPYzu7YNuYujH8h5bOxzeQ+VzdHCnQYsiivvKnXSCjV7IDBzoCm4TeKQiRVFFTFaxR6mNgIbQR+C4SIsn3hPbwM07DOu00s8Cg3YBMPOFITzT26HP4eFTiiFnjR1qzDHqoKzV+Ub8oImEM6qMuIWqurNs3F5B05gqZpbOardy+LgSPukXy2tXQiFF8E6Darjvyf86nypsQDZZ/gXjlucEDvplEYmlLMWDyWsKM/ltP5PF8ugDOy1pWyLe5p6f5Xowzb97dPMYPMd29phh1Fn4wmrLlR4J2s+kTyPPV1n112zB31jmC4NGakmGNbr9UjcMui0OjJ7qPWNW+kVRi5eqbJiKL7fSwiQ+Gc4AGc76uFiRGN3O9ad4VOWQfl9SNdwgvX2vgfqMe9s8Z3whsMkFxDN3Vf7bRWtmGHIVtv6LScT/Pes1peZbMpk3psccV5ftvEinPTumrBTBFl5,iv:WfagFszwdz0kg5Mw8rk3Yo+K4xfZkHjM/ZscbQPJTS4=,tag:yy5Su0HzhxnRyfBt5WFWIQ==,type:str]
|
- benq: ENC[AES256_GCM,data:l944rSd2vmQvkrCqpQM2PywYBkypg/iWOo9LFuUi6I7PWAQc0rAwnPYzu7YNuYujH8h5bOxzeQ+VzdHCnQYsiivvKnXSCjV7IDBzoCm4TeKQiRVFFTFaxR6mNgIbQR+C4SIsn3hPbwM07DOu00s8Cg3YBMPOFITzT26HP4eFTiiFnjR1qzDHqoKzV+Ub8oImEM6qMuIWqurNs3F5B05gqZpbOardy+LgSPukXy2tXQiFF8E6Darjvyf86nypsQDZZ/gXjlucEDvplEYmlLMWDyWsKM/ltP5PF8ugDOy1pWyLe5p6f5Xowzb97dPMYPMd29phh1Fn4wmrLlR4J2s+kTyPPV1n112zB31jmC4NGakmGNbr9UjcMui0OjJ7qPWNW+kVRi5eqbJiKL7fSwiQ+Gc4AGc76uFiRGN3O9ad4VOWQfl9SNdwgvX2vgfqMe9s8Z3whsMkFxDN3Vf7bRWtmGHIVtv6LScT/Pes1peZbMpk3psccV5ftvEinPTumrBTBFl5,iv:WfagFszwdz0kg5Mw8rk3Yo+K4xfZkHjM/ZscbQPJTS4=,tag:yy5Su0HzhxnRyfBt5WFWIQ==,type:str]
|
||||||
|
bulwark:
|
||||||
|
admin_password: ENC[AES256_GCM,data:2Jf4h1dXkzvApFxuxhWXYWB4nC5TgmOeKg/p3poheno=,iv:0ts4Zkg0U/i+9/JhUlb6wPpOjPEeBsJpid7JHU1gYas=,tag:bjm0NKkdnDwSifQYCubzsw==,type:str]
|
||||||
|
session_secret: ENC[AES256_GCM,data:vQKJIk8jBupLN2BTvMAWgBrUPsDsA/dvCtj6csV6UrqMgMMQ83BQNAgSThw=,iv:ltpMOthFy3EwT/ZO553nWQu5wz8cQHRhzF2a7Viy5ZE=,tag:wLfU7oaLA93Ot1ySJmeJ+A==,type:str]
|
||||||
|
crowdsec:
|
||||||
|
netbird_proxy_bouncer_key: ENC[AES256_GCM,data:1VpmOdB/bkvjN1nC532/CKE9sggU+6pXNPjz5oEGUrY49DcuQhMsLej2Yg5iDUFsDcwE+Jdtd4tZVfPNPM6huQ==,iv:5yWMBFtq+cKimh2OwuQT9KDt61GRZUPAwlNTZ4tRKIk=,tag:0SFE8iwUo8PzfI3O4b5dig==,type:str]
|
||||||
domains:
|
domains:
|
||||||
serv: ENC[AES256_GCM,data:AlbQ9rZXpZZwXgS9pA==,iv:kFG6GD9IEkpLtdwnJaeMrvTSOHgxIG+aHrslRMGdGd0=,tag:MJf/T8kl/VHqYVPMMh9yDQ==,type:str]
|
serv: ENC[AES256_GCM,data:AlbQ9rZXpZZwXgS9pA==,iv:kFG6GD9IEkpLtdwnJaeMrvTSOHgxIG+aHrslRMGdGd0=,tag:MJf/T8kl/VHqYVPMMh9yDQ==,type:str]
|
||||||
gitea:
|
gitea:
|
||||||
db_password: ENC[AES256_GCM,data:Lk6E2bXy7vIswpZHkH2UAlmmBVJ6Pn+KFkS4G1qePCI=,iv:pDkRN09jGSNtMo+ry1jX9rfW0hKgahq5RTPgD5sfuws=,tag:MYgEhCN2gY2siYZm9kh9ZQ==,type:str]
|
db_password: ENC[AES256_GCM,data:Lk6E2bXy7vIswpZHkH2UAlmmBVJ6Pn+KFkS4G1qePCI=,iv:pDkRN09jGSNtMo+ry1jX9rfW0hKgahq5RTPgD5sfuws=,tag:MYgEhCN2gY2siYZm9kh9ZQ==,type:str]
|
||||||
client_id: ENC[AES256_GCM,data:MwVn1IeUEP9HK91Y/qakNOw338vDqb49rBHMAQaDbL5oOaDu,iv:9ZhqPxtOVedUrJK+JTN6mNDBtUGTsx7UYSEgPdBXjsA=,tag:6uCW0sJF4SkyVbRY7cxJIg==,type:str]
|
client_id: ENC[AES256_GCM,data:MwVn1IeUEP9HK91Y/qakNOw338vDqb49rBHMAQaDbL5oOaDu,iv:9ZhqPxtOVedUrJK+JTN6mNDBtUGTsx7UYSEgPdBXjsA=,tag:6uCW0sJF4SkyVbRY7cxJIg==,type:str]
|
||||||
client_secret: ENC[AES256_GCM,data:8QiOG4AUn5os/aYka4ziUxfsCs1QGIS/SgABGXmhAzY=,iv:PUiDeJqvuzX/WuNe+an3e+kCVUZmR0VHI/KhmBJs0Sk=,tag:epN+cBVcnp2DceKMxFsWgQ==,type:str]
|
client_secret: ENC[AES256_GCM,data:8QiOG4AUn5os/aYka4ziUxfsCs1QGIS/SgABGXmhAzY=,iv:PUiDeJqvuzX/WuNe+an3e+kCVUZmR0VHI/KhmBJs0Sk=,tag:epN+cBVcnp2DceKMxFsWgQ==,type:str]
|
||||||
|
grafana:
|
||||||
|
admin_password: ENC[AES256_GCM,data:DZkX35TYXjny95Ys0SSBItWNjqlOdp4iVcYC4k7JSXcmV5QmGBDuw/cDhjY=,iv:Skmdi+5ydRn9rVCVtTyasF3MNK1FklgAebg8yYynjic=,tag:MeoT8zEollOlG3teWNFyPQ==,type:str]
|
||||||
|
client_secret: ENC[AES256_GCM,data:Ap8k+k9RsIRaNYxLUngaIUHztaN4aF9oZiQsr7wsxXI=,iv:C1m84nwuD1hwixqhxluyA/inGdwzjneKxrAJq2n5T1I=,tag:aIA4DekZuxDFt2qeluvGhA==,type:str]
|
||||||
homarr:
|
homarr:
|
||||||
enc_key: ENC[AES256_GCM,data:oxPopcBfb2o0DrkvSdyJPA/vBpBoWqVtvc3UNQAJx5e5NTmdAfLUYSXPAYLeqzrjixp+oHjJKnNoOWr/kYpkQQ==,iv:06mNrs80Qe+v1GRNfDSB5ZFDzejCyifeBZhQxdComP4=,tag:ls7fsB74wtXx9Pjmrs0K/w==,type:str]
|
enc_key: ENC[AES256_GCM,data:oxPopcBfb2o0DrkvSdyJPA/vBpBoWqVtvc3UNQAJx5e5NTmdAfLUYSXPAYLeqzrjixp+oHjJKnNoOWr/kYpkQQ==,iv:06mNrs80Qe+v1GRNfDSB5ZFDzejCyifeBZhQxdComP4=,tag:ls7fsB74wtXx9Pjmrs0K/w==,type:str]
|
||||||
client_id: ENC[AES256_GCM,data:GfKNRXaZ1lovWawXrIrHn7KSIi1T81uaiNpiAGiQw3r3fbor,iv:OokFIR5aXfBtZtdS3JFQNkZzLm7ajcJGcV8kaFDwMiU=,tag:Ui5LcPBhqf3k1XUlfpQqpw==,type:str]
|
client_id: ENC[AES256_GCM,data:GfKNRXaZ1lovWawXrIrHn7KSIi1T81uaiNpiAGiQw3r3fbor,iv:OokFIR5aXfBtZtdS3JFQNkZzLm7ajcJGcV8kaFDwMiU=,tag:Ui5LcPBhqf3k1XUlfpQqpw==,type:str]
|
||||||
client_secret: ENC[AES256_GCM,data:NpeEOoKWayiDuXrFEVzGgwN4CDgGwC/mfUtHlqll3BE=,iv:w2TpRT/unBjMyP935h9UQhVD/i75RmXV6Y4CCNinP+k=,tag:7SUjIyWQ/rT1I7LG/HNcDg==,type:str]
|
client_secret: ENC[AES256_GCM,data:NpeEOoKWayiDuXrFEVzGgwN4CDgGwC/mfUtHlqll3BE=,iv:w2TpRT/unBjMyP935h9UQhVD/i75RmXV6Y4CCNinP+k=,tag:7SUjIyWQ/rT1I7LG/HNcDg==,type:str]
|
||||||
nextauth_secret: ENC[AES256_GCM,data:2xc6FIfGHWETt73IdT2IkN9VU+F4YNijTfgww0UFBw/y+4am8M/FvU/rmvw=,iv:i+khmD6tbTfFYxnbVSN+xwu7opzmWG/RlA25rpEVm9c=,tag:9s6ZHMjBqOtgj4yobWMqlw==,type:str]
|
nextauth_secret: ENC[AES256_GCM,data:2xc6FIfGHWETt73IdT2IkN9VU+F4YNijTfgww0UFBw/y+4am8M/FvU/rmvw=,iv:i+khmD6tbTfFYxnbVSN+xwu7opzmWG/RlA25rpEVm9c=,tag:9s6ZHMjBqOtgj4yobWMqlw==,type:str]
|
||||||
netbird:
|
immich:
|
||||||
|
db_password: ENC[AES256_GCM,data:uO+Q1mbLWTdAKgQ6kF05vUTJQp/3gSi1BhEE/ANz2TO3G4zJZu6Wf2JvNP4=,iv:XtYulrJG5XRnPZyxhq1P3gchZ59XrUXrg974EqnKlUE=,tag:YHlMimZg4J/hzWYfghFlmg==,type:str]
|
||||||
|
client_id: ENC[AES256_GCM,data:QZKUkPHVtD2FToJqqe2cwYdy1WYWT42hfLsBrB6CaFjZNLLb,iv:CKcQxCMk5CAGgvgubknIjtb86Dy9jDa4PW6B9Alsm8o=,tag:OsK2U6t7RHSpzox+gXt5WA==,type:str]
|
||||||
|
client_secret: ENC[AES256_GCM,data:tvzh3gTtu52qFlrCc782zsTqSnDzb3bnpW2YuNdIcnI=,iv:YAuhSvC27haQW5zxR7Ke3NtfrmRSeBMw9hPvyf7UvQg=,tag:yFOKjEGWzu13hiEJnhpCww==,type:str]
|
||||||
|
jellyfin:
|
||||||
|
client_id: ENC[AES256_GCM,data:JJe2XbwlBpWjjlf0G3P/YIAZaqyV+79SblD0ihkshL4z+JKF,iv:gJey1H5bvGQ9/wXsdsyeR2LT9veOfxtVyHVoEvYGOo4=,tag:khhbIn7nC+VtSHYiiPkXBw==,type:str]
|
||||||
|
client_secret: ENC[AES256_GCM,data:DflkqFVpGs1kzcqMS81IoGrjfPSaoQxJE0FTDESCCg0=,iv:OYheEUzYf9T2gCx6ynVGQU0oRBloUr5GlCQ0eVIIsgI=,tag:ZRA35ifVxakj0DHUg04Dtw==,type:str]
|
||||||
letsEncrypt:
|
letsEncrypt:
|
||||||
email: ENC[AES256_GCM,data:Xb1qETzkOzJiLS0C9PvROKZajWVA4w==,iv:4gDSWhwoERffG2aY1HJT5hedqj5zZCv4u5+0UKzSSX4=,tag:jHheG2bHM2WKzKxiiFNbZg==,type:str]
|
email: ENC[AES256_GCM,data:vme4apGt38/T76cA30e88leXaog8hQ==,iv:Z+Mu+Vk2rg4B50GuLiDdSb7peTHtAMbViH1d+gSGfX4=,tag:MlRsmaqyJoygthqJmph7IA==,type:str]
|
||||||
|
mihomo:
|
||||||
|
subscription_url: ENC[AES256_GCM,data:vPgsNcmxaFWlWVMOjEIbTJjoroksmIhza5W634Xi7JZ9ylR3MuwjI7lemMCNezU=,iv:M2FJHm/qf2AeZTdoRucIOYPekDoqpj150GI+y97c24c=,tag:2XDdBocmMCUHpTFgCdyr9A==,type:str]
|
||||||
|
secret: ENC[AES256_GCM,data:RiDtS2+F80zjKrzWGIxRFnOQ6bPB6K94Dm3Szd2PisxAe8+o3HMthNiDs+w=,iv:I9qfEtdWo+xZulcBgjiiQl1a2HTuGOZRTPqFck5OxeI=,tag:wXfA35qEXCSDlTCHWVClMA==,type:str]
|
||||||
|
mirotalk:
|
||||||
|
client_secret: ENC[AES256_GCM,data:P/nxv4pUYS/Y8Yr3n08Bs8Xm9Kj3ePEnAW0u3k2Tu1U=,iv:XABBnx6xzavz9k9s4L32kVhpxUCfL5mPA4lvW6DOAPI=,tag:5tCmTGMuKFuoPN/ahN4NFw==,type:str]
|
||||||
|
session_secret: ENC[AES256_GCM,data:c+RzEbgqUDLPmxZMXb3FeAnRgvhxT3nr9HtRn9W4Queb4AEDHDAphCavKcEI0DisKdsOZEeSFY62Zpcd7J4wGA==,iv:wTLvP14rNJxxTwLAZW/UP9fhfcQ2Mp+obXNwpy1iKW0=,tag:csZGsLyV2XTcNRWGtjjx+g==,type:str]
|
||||||
|
api_key_secret: ENC[AES256_GCM,data:9q0R2Fm5lrbaL9VAJo9+kY/eNGt6LNs6rbb3TkPJXxhA76X7dUZLq6GjlNHlPvv2Co7Y67ggjSaInpa9m5CPqw==,iv:01pvDJr7u9lmSz46ToQgnkTTRZQLmftSeMBtwALzB6k=,tag:IxXH99x/ctACEN/0RUJz9g==,type:str]
|
||||||
|
netbird:
|
||||||
server:
|
server:
|
||||||
auth_secret: ENC[AES256_GCM,data:rofiudpCucVlgqMVDg1/YRcpWq5l/16z/Mz+bg7K7KRI4z7T4rAnGY6m5w==,iv:6aMZoExes1Rx0XPIxtUPL7IfmFI6HaY4JzjeFnLKtzY=,tag:Bn47oPMc0oBcjrtYrr7BYQ==,type:str]
|
auth_secret: ENC[AES256_GCM,data:rofiudpCucVlgqMVDg1/YRcpWq5l/16z/Mz+bg7K7KRI4z7T4rAnGY6m5w==,iv:6aMZoExes1Rx0XPIxtUPL7IfmFI6HaY4JzjeFnLKtzY=,tag:Bn47oPMc0oBcjrtYrr7BYQ==,type:str]
|
||||||
enc_key: ENC[AES256_GCM,data:Fx8VP788yJtZVXW5Oa+LniE9dBf20m2YWLtx7/JZPBjnnJSD9HH5z2SXuF0=,iv:GCdvQ7Cq0oZDlTAy62uZ7Jj5vHht+iI3IKdS4aDaW7A=,tag:AMaJjVjEV+f+shdcgoxHZw==,type:str]
|
enc_key: ENC[AES256_GCM,data:Fx8VP788yJtZVXW5Oa+LniE9dBf20m2YWLtx7/JZPBjnnJSD9HH5z2SXuF0=,iv:GCdvQ7Cq0oZDlTAy62uZ7Jj5vHht+iI3IKdS4aDaW7A=,tag:AMaJjVjEV+f+shdcgoxHZw==,type:str]
|
||||||
@@ -24,6 +46,9 @@ netbird:
|
|||||||
setup_keys:
|
setup_keys:
|
||||||
homelab: ENC[AES256_GCM,data:W7E4FGZI6dk188RknHWfjmFJtD0gC0saXZkRDazywqim7EsI,iv:A5szXetgudPexpGILZNeTkK5u7bc5iDmV79zIN/BcM4=,tag:X8fIpE5EHzwBGlHH3uVrVA==,type:str]
|
homelab: ENC[AES256_GCM,data:W7E4FGZI6dk188RknHWfjmFJtD0gC0saXZkRDazywqim7EsI,iv:A5szXetgudPexpGILZNeTkK5u7bc5iDmV79zIN/BcM4=,tag:X8fIpE5EHzwBGlHH3uVrVA==,type:str]
|
||||||
site: ENC[AES256_GCM,data:hYUKvzLuTy5NT3ZnRPsew8frUs2JG3NrR1Ids4PzOIHCmWbJ,iv:QxTUVA/mdJAnpjaw7bKH68tJC+zQ+bRAOAgwTTOsOkU=,tag:CCxx/UkUdtWHhN8quJ1Mcw==,type:str]
|
site: ENC[AES256_GCM,data:hYUKvzLuTy5NT3ZnRPsew8frUs2JG3NrR1Ids4PzOIHCmWbJ,iv:QxTUVA/mdJAnpjaw7bKH68tJC+zQ+bRAOAgwTTOsOkU=,tag:CCxx/UkUdtWHhN8quJ1Mcw==,type:str]
|
||||||
|
oidc-debug:
|
||||||
|
client_id: ENC[AES256_GCM,data:C3ahxUAvo2tmwfDiO5hHb/rqA2DclzwFUFX9LT/5FnmEE6CW,iv:qM2XFi2PIxBbRI5WcMJ9a4F/10j8at0Gabs+zS/NQkw=,tag:EWkEO3zUi0TXsX2BHr5lsA==,type:str]
|
||||||
|
client_secret: ENC[AES256_GCM,data:9eJMK3le5L4BQveVaVl8UcZlBv3UdpjCU9enJOGK+fQ=,iv:+JvBgeBTVInD1vaz569P9EeShz1a6WIGPFr9+bKtLU0=,tag:idvMD98wEFOOPxJQpaTMbg==,type:str]
|
||||||
opencloud:
|
opencloud:
|
||||||
client_id: ENC[AES256_GCM,data:tc0njNDdYaPKZZX0yCSc2Aaqsb0HdJWyBZ8FJRCI25+4znOr,iv:1nnOfVpBOR+9/EQ7Y4FW7vmdDENuDwDmiejyZ9qUnxw=,tag:lXZmE8pGosCBNxKdraWU/Q==,type:str]
|
client_id: ENC[AES256_GCM,data:tc0njNDdYaPKZZX0yCSc2Aaqsb0HdJWyBZ8FJRCI25+4znOr,iv:1nnOfVpBOR+9/EQ7Y4FW7vmdDENuDwDmiejyZ9qUnxw=,tag:lXZmE8pGosCBNxKdraWU/Q==,type:str]
|
||||||
initial_admin_password: ENC[AES256_GCM,data:k/1mm9hqaXhHdYiI,iv:tTCCpAYN3BaDWiBYzcCJS6pMarvEwLu5YTt7xhu9guw=,tag:iKBOZ7Ut1s45S56750krmA==,type:str]
|
initial_admin_password: ENC[AES256_GCM,data:k/1mm9hqaXhHdYiI,iv:tTCCpAYN3BaDWiBYzcCJS6pMarvEwLu5YTt7xhu9guw=,tag:iKBOZ7Ut1s45S56750krmA==,type:str]
|
||||||
@@ -35,13 +60,27 @@ porkbun:
|
|||||||
secret_key: ENC[AES256_GCM,data:Qw52vsIdN8OLIUCHQmlhytcXjQWnMG7Hypz9AR3+AL+GWXzyzpiKke+IhSe9eDWfwAhnwpSqEcBIg/Ny25az0GBXC9Q=,iv:mESI5qZHNj+28XssUwqPZQITlNrxhc+sWoD9jQOALgc=,tag:d5SwRXtrxa/0Mkp+J09tAQ==,type:str]
|
secret_key: ENC[AES256_GCM,data:Qw52vsIdN8OLIUCHQmlhytcXjQWnMG7Hypz9AR3+AL+GWXzyzpiKke+IhSe9eDWfwAhnwpSqEcBIg/Ny25az0GBXC9Q=,iv:mESI5qZHNj+28XssUwqPZQITlNrxhc+sWoD9jQOALgc=,tag:d5SwRXtrxa/0Mkp+J09tAQ==,type:str]
|
||||||
remnawave:
|
remnawave:
|
||||||
secret_key: ENC[AES256_GCM,data:TdgaDqAn5YXQOoF1otFq8oiizBcqwOvFYzykvMybr3v/jM9TWysC1u5nulmRaMVGbLmg/SyEYXOrA9/LtyAfIc7WmqGV/M9J+QcGljWW5L1UF1IvT8hwkXATZ8O/2l4vU8nfRD2Z+9H40O/enWYml6I7XtWmGsSeRxm/wq3DSa/WbSi7acz9VVXurS1QfZG4JN2h5sbapSbdZcbJD1L3kezO8BZiBXVNEqSn3a7ja0uda5Qpj+TyGiarWQqR/NZoYTM62SJTYYAVTTKRSCdPrlknneOM6c5GGk388XWKixsEQcVulNbf/TZ1GKIRVuJCb2BwgFvZtcAi8Hz9yF1/wlzLvmnU/qhPt/SVBz/GSS1N/Ai/C+AdCakPAnqlxe1aqM9pib/B4y2YFAuYIekVVSSHbm9v28oE4VpaZ1Z1lJhCqt4eQEF83q9oOjIa9LzlVszms06BgWkCKMwbBFUz4R9VDqgr1iHx8i6G7OuaPAnqkT9b1yecVeh8ZD1qnop5DWI3Qa1xpZN/jgMqNAh08iZlI5YpWqXL5MgzGeTPnikbRU7reohOpqvBG77nqYx6rARUdjb483xYmSDspSVF/4u7u2HXpfbk1ZvhfOpTlTL9cka1SuECMl+oG33ahm52yPBlNtOTJLNixsJKQf5u50ZVwImDzGARLkeO/GZI3oVgkNjImsiqctKSVpTfpmtet6qw2CZDuRp6V5FXKwthg5xvFE4yd11nBWqMg60vjzNdLdBEGVf38H1v26JB2jLVYPHqqe3eiNl9YXdbL/wdY9MTGbT7jbD3OWLRCC5LqBxr+5256d7eSJroB9TGcF9sTStIMnkDyM7aFWJ7noG4GiXmrrsC3Nb75QW7yOccPtBeZqBDvV/ore7jsf7dJ7O2zGNPuqfNCml6O4eurfXNEtP93ZYqeI9Q/M+DfZHASJYyWnSpklCICmn8tLSg/QXBkOAhXRj1Fv7hBIiG5iqiMscEDhlms7fR9ODFLaWjRgPciu1/0BJ0Of/puY9ZtWD6WiKHIk8DI7Yvu1NbWDbnNcLoHvNoEtPSe/lSXRHdGKRkTU2awCoKJ4f6VbvkeZD29xR2zeGXqfE8EqKtzofi+bG4nPVeeK64BteAdpALhoKkoVYBEnwaH/MgSPLPAE4qRlN/+zHnj/BvvvvIahouCp4JXgqnPAa54UsKRMx4GB3wCNtlEU1qdc//5mPsdaTt3VHCz6Mba5QuuftVxoLKb6h1LX8cdhq4Zjp74jhDO47aE3YnJzYM4462EGiHLnEXc3ve4ff/oP1J5lq2vel5XFc/742YFhP344KyXulO0VxN4Fxopw/Oi/HP4UPWD4kEGGN3vOLIqR/jNAOuG0ocOkcSXgTi5596HMxKy0v6C2Qfcs7XfBDR0IOnYBfn521MgLzkZrzDpkYe6eFXXgWwARNouhMw/F4iAM6ITsltEcDQB8vXgjrvFjaiu4WXa3QWOBoQROqMR0eCNavXr6QrAnVigBOhgmVmR8afXwjoTAkWG0zC7k3l5TecptoGqFfb2K3Aq8yfdY+bZ3OcLGvdbguv+E/VXnuo3fsd/h416Jv25xXOrjU++ppS+sZbH+H6IVeAqrprTkgGXRpaJLXz+ZI1VZbap5EpJY5sxOB0VyA0MODlUSTBIxv0zmd/7eMcG7PiLYJH4rHRBu5tiRGQ11mlLmTlKTevBiA48JobW6RSrCn/r234Y7iZSH1sRDXl6D2q6ObmxxZDEODcBJ6w9dzEijAbMuKdXO8P24rq3cWWGwU9oE4/QxkTynvBp9Se3xBmENcMEyzECejE8W/wr1HPDERwYYuLDL5A0kJKGjkyKRND9hBHNTka1Gr7n0pGDDPQJUAwsLC8Gd8VRY0mZzslk9oOiJvH8Kc4oo41nhMGgoQTKqH+Ur03ZiKvFxqV8G5gJzYWF8l9WCBmARXQqogdGeJxMZFWvDAhsWEN5+izm+zQO1wWGKcHC8Y+YYIjbMOeoWNM6WIOqETS5g3fH4Bo+5iY+MaEN5X1RVRVMd8pJl/eSSIsqMgbZRyxySr7zdeLTC7pyASOvL5Iv4jGWECGQ4f4LoOAWCEcfuzTQ6z/6bTKyZKFTvbdVSsreITU0TBoju4mR3S0rpxvHfHU4J1nOx9W5nW4lnhvnmPCikoujbemXkm4yKFmYylFClEikplRVPdUvaSBAHJFEhWxhIJ7JwIHZUAjNxwx98bO9IVxDK9ehMiKr6DGKpFQC9tGG4/HsYlTw+BjxhRPBjWcHQrXoR5+YZ6aeLZHlnavbqeMjXbIN5cADlwxG7QW1SOhICRxwFKaVL/0JKSNLpA8Nmy7P+SDVO1hzuFI7Fhydg2iE3VA5a3qFygeZTt394MO+xMqMaTy2E3rfzTAkPiTScX7a+TR1mZmmPP8Vb5JeB7MHsYnqksSkl/ppY/Ki07+o5A2YagvC6owCiqAHbRJntYM99nYboNYW7xc+DfSNL6RdJq7YpO357NAXa8Wwdu94hDETtzh21h8tB0QEoD/TfbP0wzq/BuRgGErDc7dq/JNwHAfFnQZhD1v78HpxTbjVjHjtG+YuixfclTbI7DXWd/PwUZN6fNlSJDT1Xq2IREluvr/awLTRhrPFpMSm8mICaobfT0VzgW59Tkxn3D6WvTVTyUf0ntRV3MY54mHXwtNmHCGxlpqNE/41NGlLT0yPzcVlDwTj3Idwt1cLAsV8a82gaQrmRCmda6WxWTDBPqXIrnpWIz4rJ4Fb1BhmLNqSHLbiJ5h4AgPGLX+Hiv/8oO200SgxcXNQgrgVME93LbODD3uJKrGeiYIYLH9tBllOHkhE9PdojgonmF1J5z6okpaq6p5FFqGNGtCHAt09YspY5sRjBV1Gq7V4FNoy+1KgS6QMg6zbW+FWT1me1npJy2MF5S3kTUBF+icZRzGje1KMXpG09ylzAgOXaK8aW7d64nx0sqPqdRjDI9h4ycjh27hyrMYBNhdEJPpnvd5BY0gKdR/pdUhuA7Rkwb5bVDvWW6zMymW3qa/1NsSsH71GkHNa7xdjbMVZZF5ruWkOgIjHE4YcYKpTIYbPR/iP04bhnjeLv00IA2u8gJCTdILaQZlD3/g/ytxnGGeNryJGcwdvM+sPJiO77IQSOYYUzJW2yr6NFKz3A+D2wyj9CMqbW1PBwWCkhI0Sy8H9gEA8NnetRu+qEsgugpKLJ4arw+u8SUGyJR06rlxbx4oBppTMc8CjfmrR54+mpjBC9WzKWzzHR/sQbm8iAHDXMx0lmRZERh1uOhnpIoHwow/0XFHJy53vjcsTMdarmhMd5NqtgDZX+Ac/2syWRps3wAHi/AHfmQV597ScEdLFnSZvEHgV1bdNNNNA8yfmfwyK+HsUiO0/kUiPaJhKblH+oqd3/4jqEFJpeuU6pY5Lfr0Vuw+EJFTdOuO/ktpsaSesy+PkcHM6oFkLFCFs0TttgdaaZ+AFEfhpRtVruXBvuFOMTuMtAjde2A=,iv:K8EMSHP+/xAE7jLjpqQ250JkP3Kw/gxThH/seC0O104=,tag:iNleKBA7whvT9PSMtg/dmQ==,type:str]
|
secret_key: ENC[AES256_GCM,data:TdgaDqAn5YXQOoF1otFq8oiizBcqwOvFYzykvMybr3v/jM9TWysC1u5nulmRaMVGbLmg/SyEYXOrA9/LtyAfIc7WmqGV/M9J+QcGljWW5L1UF1IvT8hwkXATZ8O/2l4vU8nfRD2Z+9H40O/enWYml6I7XtWmGsSeRxm/wq3DSa/WbSi7acz9VVXurS1QfZG4JN2h5sbapSbdZcbJD1L3kezO8BZiBXVNEqSn3a7ja0uda5Qpj+TyGiarWQqR/NZoYTM62SJTYYAVTTKRSCdPrlknneOM6c5GGk388XWKixsEQcVulNbf/TZ1GKIRVuJCb2BwgFvZtcAi8Hz9yF1/wlzLvmnU/qhPt/SVBz/GSS1N/Ai/C+AdCakPAnqlxe1aqM9pib/B4y2YFAuYIekVVSSHbm9v28oE4VpaZ1Z1lJhCqt4eQEF83q9oOjIa9LzlVszms06BgWkCKMwbBFUz4R9VDqgr1iHx8i6G7OuaPAnqkT9b1yecVeh8ZD1qnop5DWI3Qa1xpZN/jgMqNAh08iZlI5YpWqXL5MgzGeTPnikbRU7reohOpqvBG77nqYx6rARUdjb483xYmSDspSVF/4u7u2HXpfbk1ZvhfOpTlTL9cka1SuECMl+oG33ahm52yPBlNtOTJLNixsJKQf5u50ZVwImDzGARLkeO/GZI3oVgkNjImsiqctKSVpTfpmtet6qw2CZDuRp6V5FXKwthg5xvFE4yd11nBWqMg60vjzNdLdBEGVf38H1v26JB2jLVYPHqqe3eiNl9YXdbL/wdY9MTGbT7jbD3OWLRCC5LqBxr+5256d7eSJroB9TGcF9sTStIMnkDyM7aFWJ7noG4GiXmrrsC3Nb75QW7yOccPtBeZqBDvV/ore7jsf7dJ7O2zGNPuqfNCml6O4eurfXNEtP93ZYqeI9Q/M+DfZHASJYyWnSpklCICmn8tLSg/QXBkOAhXRj1Fv7hBIiG5iqiMscEDhlms7fR9ODFLaWjRgPciu1/0BJ0Of/puY9ZtWD6WiKHIk8DI7Yvu1NbWDbnNcLoHvNoEtPSe/lSXRHdGKRkTU2awCoKJ4f6VbvkeZD29xR2zeGXqfE8EqKtzofi+bG4nPVeeK64BteAdpALhoKkoVYBEnwaH/MgSPLPAE4qRlN/+zHnj/BvvvvIahouCp4JXgqnPAa54UsKRMx4GB3wCNtlEU1qdc//5mPsdaTt3VHCz6Mba5QuuftVxoLKb6h1LX8cdhq4Zjp74jhDO47aE3YnJzYM4462EGiHLnEXc3ve4ff/oP1J5lq2vel5XFc/742YFhP344KyXulO0VxN4Fxopw/Oi/HP4UPWD4kEGGN3vOLIqR/jNAOuG0ocOkcSXgTi5596HMxKy0v6C2Qfcs7XfBDR0IOnYBfn521MgLzkZrzDpkYe6eFXXgWwARNouhMw/F4iAM6ITsltEcDQB8vXgjrvFjaiu4WXa3QWOBoQROqMR0eCNavXr6QrAnVigBOhgmVmR8afXwjoTAkWG0zC7k3l5TecptoGqFfb2K3Aq8yfdY+bZ3OcLGvdbguv+E/VXnuo3fsd/h416Jv25xXOrjU++ppS+sZbH+H6IVeAqrprTkgGXRpaJLXz+ZI1VZbap5EpJY5sxOB0VyA0MODlUSTBIxv0zmd/7eMcG7PiLYJH4rHRBu5tiRGQ11mlLmTlKTevBiA48JobW6RSrCn/r234Y7iZSH1sRDXl6D2q6ObmxxZDEODcBJ6w9dzEijAbMuKdXO8P24rq3cWWGwU9oE4/QxkTynvBp9Se3xBmENcMEyzECejE8W/wr1HPDERwYYuLDL5A0kJKGjkyKRND9hBHNTka1Gr7n0pGDDPQJUAwsLC8Gd8VRY0mZzslk9oOiJvH8Kc4oo41nhMGgoQTKqH+Ur03ZiKvFxqV8G5gJzYWF8l9WCBmARXQqogdGeJxMZFWvDAhsWEN5+izm+zQO1wWGKcHC8Y+YYIjbMOeoWNM6WIOqETS5g3fH4Bo+5iY+MaEN5X1RVRVMd8pJl/eSSIsqMgbZRyxySr7zdeLTC7pyASOvL5Iv4jGWECGQ4f4LoOAWCEcfuzTQ6z/6bTKyZKFTvbdVSsreITU0TBoju4mR3S0rpxvHfHU4J1nOx9W5nW4lnhvnmPCikoujbemXkm4yKFmYylFClEikplRVPdUvaSBAHJFEhWxhIJ7JwIHZUAjNxwx98bO9IVxDK9ehMiKr6DGKpFQC9tGG4/HsYlTw+BjxhRPBjWcHQrXoR5+YZ6aeLZHlnavbqeMjXbIN5cADlwxG7QW1SOhICRxwFKaVL/0JKSNLpA8Nmy7P+SDVO1hzuFI7Fhydg2iE3VA5a3qFygeZTt394MO+xMqMaTy2E3rfzTAkPiTScX7a+TR1mZmmPP8Vb5JeB7MHsYnqksSkl/ppY/Ki07+o5A2YagvC6owCiqAHbRJntYM99nYboNYW7xc+DfSNL6RdJq7YpO357NAXa8Wwdu94hDETtzh21h8tB0QEoD/TfbP0wzq/BuRgGErDc7dq/JNwHAfFnQZhD1v78HpxTbjVjHjtG+YuixfclTbI7DXWd/PwUZN6fNlSJDT1Xq2IREluvr/awLTRhrPFpMSm8mICaobfT0VzgW59Tkxn3D6WvTVTyUf0ntRV3MY54mHXwtNmHCGxlpqNE/41NGlLT0yPzcVlDwTj3Idwt1cLAsV8a82gaQrmRCmda6WxWTDBPqXIrnpWIz4rJ4Fb1BhmLNqSHLbiJ5h4AgPGLX+Hiv/8oO200SgxcXNQgrgVME93LbODD3uJKrGeiYIYLH9tBllOHkhE9PdojgonmF1J5z6okpaq6p5FFqGNGtCHAt09YspY5sRjBV1Gq7V4FNoy+1KgS6QMg6zbW+FWT1me1npJy2MF5S3kTUBF+icZRzGje1KMXpG09ylzAgOXaK8aW7d64nx0sqPqdRjDI9h4ycjh27hyrMYBNhdEJPpnvd5BY0gKdR/pdUhuA7Rkwb5bVDvWW6zMymW3qa/1NsSsH71GkHNa7xdjbMVZZF5ruWkOgIjHE4YcYKpTIYbPR/iP04bhnjeLv00IA2u8gJCTdILaQZlD3/g/ytxnGGeNryJGcwdvM+sPJiO77IQSOYYUzJW2yr6NFKz3A+D2wyj9CMqbW1PBwWCkhI0Sy8H9gEA8NnetRu+qEsgugpKLJ4arw+u8SUGyJR06rlxbx4oBppTMc8CjfmrR54+mpjBC9WzKWzzHR/sQbm8iAHDXMx0lmRZERh1uOhnpIoHwow/0XFHJy53vjcsTMdarmhMd5NqtgDZX+Ac/2syWRps3wAHi/AHfmQV597ScEdLFnSZvEHgV1bdNNNNA8yfmfwyK+HsUiO0/kUiPaJhKblH+oqd3/4jqEFJpeuU6pY5Lfr0Vuw+EJFTdOuO/ktpsaSesy+PkcHM6oFkLFCFs0TttgdaaZ+AFEfhpRtVruXBvuFOMTuMtAjde2A=,iv:K8EMSHP+/xAE7jLjpqQ250JkP3Kw/gxThH/seC0O104=,tag:iNleKBA7whvT9PSMtg/dmQ==,type:str]
|
||||||
|
seafile:
|
||||||
|
admin_email: ENC[AES256_GCM,data:g6dmlD1xyna3TxAbl4ure8R7Og==,iv:epfMf6rZ5W7DWrFrSe/6LJAg5JAzCgSvgSzl8DYRqSE=,tag:bsK2KIlq1xdzvrAwfqNB8A==,type:str]
|
||||||
|
admin_password: ENC[AES256_GCM,data:+JHz6R0tKsSpa2OW4Rs=,iv:Ej4UhEOKo4lzHlAv/cxBs8h9EMecYi8/w6qBr5muz/U=,tag:l6pri4nid/nEGNbtfZ/vvw==,type:str]
|
||||||
|
client_id: ENC[AES256_GCM,data:x+l5/7zJitzR1GqnHlq3/lPsudNZi5UG3PCfitpqd+k6JtQT,iv:CckRQ1qM7xfvGpTK8vyxM2rszPgAC5BxYRGekP5LINM=,tag:sslPaYoWs5yPyPqEtlYSwg==,type:str]
|
||||||
|
client_secret: ENC[AES256_GCM,data:YKe2OrEbUuggm/PpjBgK1+XBG/24i17J4EBdeRdq2WQ=,iv:wWe1GKP09NrNhcHgp9b/gvB81+QrasCqp9RQxZJl9Ks=,tag:XYa2cyf+yG18QRm2mcLQCQ==,type:str]
|
||||||
|
jwt_private_key: ENC[AES256_GCM,data:GOVQWfLdX44yy8BT/LohJSkHrI2VvvQWbLcV5Q/8aSE8A3b4BC40t7B/hQvM+kvIgkJYxqFJDr7Iqe01LgdarQ==,iv:c/NtYAeWze0/O6i4yGjeIJP6Eq3fNV5TE+Smvv9JYXs=,tag:RB8w10G7miGZemm8LgGlRg==,type:str]
|
||||||
|
mysql_password: ENC[AES256_GCM,data:51cPn7bwwqSlxxGh8Gc=,iv:dh1jwvkMyowWb39BkOhsBB0Bedu/xDKergj+T++dtPg=,tag:LJMHF5pivPYsy5jzlFDYVg==,type:str]
|
||||||
|
redis_password: ENC[AES256_GCM,data:dyP0WUcVRbs/KtU7sLI=,iv:vj5V1zi6R9pwPO0CyOq7qi7DK1X8OWsTik0ahPznslU=,tag:2afrBpy0I8+2oxYdUhn25g==,type:str]
|
||||||
|
stalwart:
|
||||||
|
admin_password: ENC[AES256_GCM,data:jov1bbGR7lcCGUomYMg=,iv:FheHq6pNHWOJxhnB6UqYfy5Z2h3jlJ0nerkA8dXRwe8=,tag:txBlGaw0j52XF8drT2fzqg==,type:str]
|
||||||
|
turn:
|
||||||
|
password: ENC[AES256_GCM,data:n18l0IAjdNBiPE0C0nXcUZaCIah+cwqnZOZKKKZ4iGA0tjLZYfIv9vFU/WM=,iv:HTsGFA7VBy2F+ZBamGpwnNkhJwhjX47yn97qTfZGM/E=,tag:KPrDQl1Ux1VNTQNKClBItw==,type:str]
|
||||||
|
public-ip: ENC[AES256_GCM,data:PO8cKdgZcvxxRL0V,iv:WAUbp3SI57C1GdBorw5bOsm/k1fdx6RrBxcku8VhgBI=,tag:6N5Nzp7z79yJuPowOWR1qg==,type:str]
|
||||||
vaultwarden:
|
vaultwarden:
|
||||||
admin_token: ENC[AES256_GCM,data:rRYMd861GiCXIt44Q0gT6js+AIrkE8WOe7FTf1JTvHg7CA4il809B3edeCY=,iv:w338YooNVMfdDab2/gcmRcOPdUnUYN/Dw3fkX9dP3Q4=,tag:q25HqgQnxaU1yh5wXyJxIQ==,type:str]
|
admin_token: ENC[AES256_GCM,data:rRYMd861GiCXIt44Q0gT6js+AIrkE8WOe7FTf1JTvHg7CA4il809B3edeCY=,iv:w338YooNVMfdDab2/gcmRcOPdUnUYN/Dw3fkX9dP3Q4=,tag:q25HqgQnxaU1yh5wXyJxIQ==,type:str]
|
||||||
client_id: ENC[AES256_GCM,data:oujuPecz3vp/DZB6nJHycJjwMc6TrX7lqrwlgOpVbIdD9Jur,iv:KllzucXB+KMDlz4ea2DOO2ar2pgO+KIEwrA+kJbKTzg=,tag:WUZ4ZMPgW7pPXUgYdnYx4Q==,type:str]
|
client_id: ENC[AES256_GCM,data:oujuPecz3vp/DZB6nJHycJjwMc6TrX7lqrwlgOpVbIdD9Jur,iv:KllzucXB+KMDlz4ea2DOO2ar2pgO+KIEwrA+kJbKTzg=,tag:WUZ4ZMPgW7pPXUgYdnYx4Q==,type:str]
|
||||||
client_secret: ENC[AES256_GCM,data:HzgNuYi3tG6McequVxiDnfxVKkQ33gg1xiRDHfP2EYY=,iv:QDOok/akzn45ObrZ+g2R1qBu6VtoVmJxvXYNjcV/VkY=,tag:vn4phkBu6vdAL7Yc/uevUg==,type:str]
|
client_secret: ENC[AES256_GCM,data:HzgNuYi3tG6McequVxiDnfxVKkQ33gg1xiRDHfP2EYY=,iv:QDOok/akzn45ObrZ+g2R1qBu6VtoVmJxvXYNjcV/VkY=,tag:vn4phkBu6vdAL7Yc/uevUg==,type:str]
|
||||||
|
smtp_password: ENC[AES256_GCM,data:4Yya86cXauXG7DG+ljO3KxY7j345mQy7mmrlE1zVjS7hzHf7O4Tqtg==,iv:zTO/nUmoCVtWtSrJdAiTE1dBEOYLDOI7lYGU02t21ww=,tag:fBXbYpBxbxHUYAsqPgwfew==,type:str]
|
||||||
wud:
|
wud:
|
||||||
client_id: ENC[AES256_GCM,data://OJ0JmagnvSysAPuT5FbNDiSSbm+utibsueIpk/DtbeRTqc,iv:pMk3qvNT0BwFqQ/gR5eu+UoUsHbXB7ogKvDRYt5Psxc=,tag:/Wn0l2769P6cH3j7xnuYpw==,type:str]
|
client_id: ENC[AES256_GCM,data://OJ0JmagnvSysAPuT5FbNDiSSbm+utibsueIpk/DtbeRTqc,iv:pMk3qvNT0BwFqQ/gR5eu+UoUsHbXB7ogKvDRYt5Psxc=,tag:/Wn0l2769P6cH3j7xnuYpw==,type:str]
|
||||||
client_secret: ENC[AES256_GCM,data:yVUBcEGqDEp+/2bodVVYo/13eAkHAqGjRcMRZ4jrsVA=,iv:IJLepDXtrzWsmkHuSEGevr8zxFpHEben3gqu+1+ZM1o=,tag:cD9oP1f+4MtDRQFWQqtpqA==,type:str]
|
client_secret: ENC[AES256_GCM,data:POzQkGTEeOEoI1M0ACR4rz7wwSF01ZOBCX+uOgN2tnY=,iv:h2aBM2BmD70bxgTKCzOcC3SIpBl9wC52+g33EpUI7YA=,tag:EI17jUjJu3zBq5K3t2otkw==,type:str]
|
||||||
zerobyte:
|
zerobyte:
|
||||||
app_secret: ENC[AES256_GCM,data:Z5I9Z1YpC0qHkoVEleq/8gz5l21bsHqMnPNTRgbVpPKWUkcYFeIqadVwA0vKZIS6GdQYVvYgO/yjN0sJtcXHjQ==,iv:j0fH7OG+ygsUU5qS94eG3qUfooos3qM+GKAL+zXzKN0=,tag:6rp87IKTOBvxy6txgnS87g==,type:str]
|
app_secret: ENC[AES256_GCM,data:Z5I9Z1YpC0qHkoVEleq/8gz5l21bsHqMnPNTRgbVpPKWUkcYFeIqadVwA0vKZIS6GdQYVvYgO/yjN0sJtcXHjQ==,iv:j0fH7OG+ygsUU5qS94eG3qUfooos3qM+GKAL+zXzKN0=,tag:6rp87IKTOBvxy6txgnS87g==,type:str]
|
||||||
sops:
|
sops:
|
||||||
@@ -55,7 +94,7 @@ sops:
|
|||||||
cXdySWpLdjgvUStuRlR3UkRHdEZBWW8KpZbcGZKk8Sj0s2cwk7FRC0XPgxMmqRYt
|
cXdySWpLdjgvUStuRlR3UkRHdEZBWW8KpZbcGZKk8Sj0s2cwk7FRC0XPgxMmqRYt
|
||||||
0QsTennzYel9vXCAmxgrwppq1RKsAHq9IfRAROz3X4ngb7UGHjFo7A==
|
0QsTennzYel9vXCAmxgrwppq1RKsAHq9IfRAROz3X4ngb7UGHjFo7A==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
lastmodified: "2026-06-07T15:31:16Z"
|
lastmodified: "2026-10-11T14:28:34Z"
|
||||||
mac: ENC[AES256_GCM,data:l4gW1lJuO5H7Ty/0V4JE8o+VotbPSgo3dDfi7u/8Td3WX9FEkFfQehKr3aWsGSMb3A0mYBwvIZSDSI3VW7rouFvkI6RXhGKXq1e7ThzXJaY7NL/kcj4VmjHf87DLBgxFiKIoZsjeLgT3anWKpSUTbofQ3+vE4fycEGu3TEvgeGE=,iv:tEeEYfc216KnlxZfs13yyosDFH/jGt1dnRtL3WNR4Sw=,tag:O5ZzaUZoZgMwBtmBE9rBlQ==,type:str]
|
mac: ENC[AES256_GCM,data:Crsax1Z6LX9LcZecPiCGTlelhY+s3QYhOxY8XPwpA6sRBQdyIFjQjYfizAumBsgG4w86zNB0uaVJYJnyo1IqMX0xTUiMzO/SknteGyRyEHP8BuxDhmucZz5rCf4XgYazk5KoXDRyMIlIsDeWbT4qa5rU8giQS7Tkai1TEwrbIEM=,iv:4jFA8vp67BbryVgSDKXvIkGPzYHLE3OoSG6oKaf9CYc=,tag:Ibfmj4R49F6fut017OSEIA==,type:str]
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.13.0
|
version: 3.13.2
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Nirinit (Niri Session Manager)
|
|
||||||
PartOf=graphical-session.target
|
|
||||||
After=graphical-session.target niri.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart=/home/%u/.cargo/bin/nirinit --save-interval 300
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=graphical-session.target
|
|
||||||
@@ -10,13 +10,22 @@ set-option -g history-limit 100000
|
|||||||
set-option -g set-titles on
|
set-option -g set-titles on
|
||||||
set-option -g set-titles-string "#{pane_title}"
|
set-option -g set-titles-string "#{pane_title}"
|
||||||
|
|
||||||
|
# splits
|
||||||
bind c new-window -c "#{pane_current_path}"
|
bind c new-window -c "#{pane_current_path}"
|
||||||
bind '"' split-window -c "#{pane_current_path}"
|
unbind '"'
|
||||||
bind % split-window -h -c "#{pane_current_path}"
|
bind - split-window -c "#{pane_current_path}"
|
||||||
|
unbind %
|
||||||
|
bind | split-window -h -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
# navigation
|
||||||
|
bind h select-pane -L
|
||||||
|
bind j select-pane -D
|
||||||
|
bind k select-pane -U
|
||||||
|
bind l select-pane -R
|
||||||
|
|
||||||
# open lazygit
|
# open lazygit
|
||||||
unbind g
|
unbind g
|
||||||
bind g display-popup -d "#{pane_current_path}" -w 80% -h 80% -E "lazygit"
|
bind g display-popup -d "#{pane_current_path}" -w 90% -h 90% -E "lazygit"
|
||||||
|
|
||||||
# create new session
|
# create new session
|
||||||
unbind N
|
unbind N
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
kitty.desktop
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Dmitry Nefedov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Dmitry Nefedov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/sxyazi/yazi/blob/main/assets/logo.png?raw=true" alt="Yazi logo" width="20%">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 align="center">
|
||||||
|
Kanagawa Flavor for <a href="https://github.com/sxyazi/yazi">Yazi</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
## 👀 Preview
|
||||||
|
|
||||||
|
<img src="preview.png" width="600" />
|
||||||
|
|
||||||
|
## 🎨 Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ya pkg add dangooddd/kanagawa
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚙️ Usage
|
||||||
|
|
||||||
|
> [!Note]
|
||||||
|
> To achieve the look like in the screenshot you also need to install
|
||||||
|
> [full-border](https://github.com/yazi-rs/plugins/tree/main/full-border.yazi) plugin!
|
||||||
|
|
||||||
|
Add these lines to your `theme.toml` configuration file to use it:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[flavor]
|
||||||
|
dark = "kanagawa"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📜 License
|
||||||
|
|
||||||
|
The flavor is MIT-licensed, and the included tmTheme is also MIT-licensed.
|
||||||
|
|
||||||
|
Check the [LICENSE](LICENSE) and [LICENSE-tmtheme](LICENSE-tmtheme) file for more details.
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
## Color palette
|
||||||
|
## Check https://github.com/rebelot/kanagawa.nvim for more details
|
||||||
|
# sumiInk0 "#16161d" dark bg
|
||||||
|
# sumiInk3 "#1f1f28" bg
|
||||||
|
# sumiInk4 "#2a2a37"
|
||||||
|
# sumiInk6 "#54546d"
|
||||||
|
# fujiWhite "#dcd7ba" fg
|
||||||
|
# oldWhite "#c8c093" dark fg
|
||||||
|
# fujiGray "#727169"
|
||||||
|
# peachRed "#ff5d62"
|
||||||
|
# autumnRed "#c34043"
|
||||||
|
# crystalBlue "#7e9cd8"
|
||||||
|
# waveRed "#e46876"
|
||||||
|
# carpYellow "#e6c384"
|
||||||
|
# springGreen "#98bb6c"
|
||||||
|
# autumnGreen "#76946a"
|
||||||
|
# oniViolet "#957fb8"
|
||||||
|
# waveAqua1 "#6a9589"
|
||||||
|
# surimiOrange "#ffa066"
|
||||||
|
# waveAqua2 "#7aa89f"
|
||||||
|
|
||||||
|
[mgr]
|
||||||
|
marker_copied = { fg = "#98bb6c", bg = "#98bb6c" }
|
||||||
|
marker_cut = { fg = "#e46876", bg = "#e46876" }
|
||||||
|
marker_marked = { fg = "#957fb8", bg = "#957fb8" }
|
||||||
|
marker_selected = { fg = "#ffa066", bg = "#ffa066" }
|
||||||
|
|
||||||
|
cwd = { fg = "#e6c384" }
|
||||||
|
|
||||||
|
find_keyword = { fg = "#ffa066", bg = "#1f1f28" }
|
||||||
|
find_position = {}
|
||||||
|
|
||||||
|
count_copied = { fg = "#1f1f28", bg = "#98bb6c" }
|
||||||
|
count_cut = { fg = "#1f1f28", bg = "#e46876" }
|
||||||
|
count_selected = { fg = "#1f1f28", bg = "#ffa066" }
|
||||||
|
|
||||||
|
border_symbol = "│"
|
||||||
|
border_style = { fg = "#dcd7ba" }
|
||||||
|
|
||||||
|
[indicator]
|
||||||
|
parent = { reversed = true }
|
||||||
|
current = { reversed = true }
|
||||||
|
preview = { reversed = true }
|
||||||
|
|
||||||
|
[tabs]
|
||||||
|
active = { fg = "#1f1f28", bg = "#7e9cd8" }
|
||||||
|
inactive = { fg = "#7e9cd8", bg = "#2a2a37" }
|
||||||
|
|
||||||
|
sep_inner = { open = "", close = "" }
|
||||||
|
sep_outer = { open = "", close = "" }
|
||||||
|
|
||||||
|
|
||||||
|
[mode]
|
||||||
|
normal_main = { fg = "#1f1f28", bg = "#7e9cd8" }
|
||||||
|
normal_alt = { fg = "#7e9cd8", bg = "#2a2a37" }
|
||||||
|
select_main = { fg = "#1f1f28", bg = "#957fb8" }
|
||||||
|
select_alt = { fg = "#957fb8", bg = "#2a2a37" }
|
||||||
|
unset_main = { fg = "#1f1f28", bg = "#e6c384" }
|
||||||
|
unset_alt = { fg = "#e6c384", bg = "#2a2a37" }
|
||||||
|
|
||||||
|
|
||||||
|
[status]
|
||||||
|
sep_left = { open = "", close = "" }
|
||||||
|
sep_right = { open = "", close = "" }
|
||||||
|
overall = { fg = "#c8c093", bg = "#16161d" }
|
||||||
|
|
||||||
|
progress_label = { fg = "#7e9cd8", bold = true }
|
||||||
|
progress_normal = { fg = "#2a2a37", bg = "#1f1f28" }
|
||||||
|
progress_error = { fg = "#2a2a37", bg = "#1f1f28" }
|
||||||
|
|
||||||
|
perm_type = { fg = "#98bb6c" }
|
||||||
|
perm_read = { fg = "#e6c384" }
|
||||||
|
perm_write = { fg = "#ff5d62" }
|
||||||
|
perm_exec = { fg = "#7aa89f" }
|
||||||
|
perm_sep = { fg = "#957fb8" }
|
||||||
|
|
||||||
|
|
||||||
|
[pick]
|
||||||
|
border = { fg = "#7fb4ca" }
|
||||||
|
active = { fg = "#957fb8", bold = true }
|
||||||
|
inactive = {}
|
||||||
|
|
||||||
|
[input]
|
||||||
|
border = { fg = "#7fb4ca" }
|
||||||
|
title = {}
|
||||||
|
value = {}
|
||||||
|
selected = { reversed = true }
|
||||||
|
|
||||||
|
[completion]
|
||||||
|
border = { fg = "#7fb4ca" }
|
||||||
|
active = { reversed = true }
|
||||||
|
inactive = {}
|
||||||
|
|
||||||
|
[tasks]
|
||||||
|
border = { fg = "#7fb4ca" }
|
||||||
|
title = {}
|
||||||
|
hovered = { fg = "#957fb8" }
|
||||||
|
|
||||||
|
[which]
|
||||||
|
cols = 2
|
||||||
|
separator = " - "
|
||||||
|
separator_style = { fg = "#727169" }
|
||||||
|
mask = { bg = "#16161d" }
|
||||||
|
rest = { fg = "#727169" }
|
||||||
|
cand = { fg = "#7e9cd8" }
|
||||||
|
desc = { fg = "#54546d" }
|
||||||
|
|
||||||
|
[help]
|
||||||
|
on = { fg = "#7aa89f" }
|
||||||
|
run = { fg = "#957fb8" }
|
||||||
|
desc = {}
|
||||||
|
hovered = { reversed = true, bold = true }
|
||||||
|
footer = { fg = "#1f1f28", bg = "#dcd7ba" }
|
||||||
|
|
||||||
|
[notify]
|
||||||
|
title_info = { fg = "#98bb6c" }
|
||||||
|
title_warn = { fg = "#e6c384" }
|
||||||
|
title_error = { fg = "#ff5d62" }
|
||||||
|
|
||||||
|
[filetype]
|
||||||
|
rules = [
|
||||||
|
# images
|
||||||
|
{ mime = "image/*", fg = "#e6c384" },
|
||||||
|
|
||||||
|
# media
|
||||||
|
{ mime = "{audio,video}/*", fg = "#957fb8" },
|
||||||
|
|
||||||
|
# archives
|
||||||
|
{ mime = "application/{zip,rar,7z*,tar,gzip,xz,zstd,bzip*,lzma,compress,archive,cpio,arj,xar,ms-cab*}", fg = "#e46876" },
|
||||||
|
|
||||||
|
# documents
|
||||||
|
{ mime = "application/{pdf,doc,rtf,vnd.*}", fg = "#6a9589" },
|
||||||
|
|
||||||
|
# broken links
|
||||||
|
{ url = "*", is = "orphan", fg = "#c34043" },
|
||||||
|
|
||||||
|
# executables
|
||||||
|
{ url = "*", is = "exec", fg = "#76946a" },
|
||||||
|
|
||||||
|
# fallback
|
||||||
|
{ url = "*", fg = "#dcd7ba" },
|
||||||
|
{ url = "*/", fg = "#7e9cd8" },
|
||||||
|
]
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
@@ -0,0 +1,448 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Kanagawa</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
|
<string>#1F1F28</string>
|
||||||
|
<key>caret</key>
|
||||||
|
<string>#C8C093</string>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#DCD7BA</string>
|
||||||
|
<key>invisibles</key>
|
||||||
|
<string>#54546D</string>
|
||||||
|
<key>lineHighlight</key>
|
||||||
|
<string>#2D4F67</string>
|
||||||
|
<key>selection</key>
|
||||||
|
<string>#2D4F67</string>
|
||||||
|
<key>findHighlight</key>
|
||||||
|
<string>#2D4F67</string>
|
||||||
|
<key>selectionBorder</key>
|
||||||
|
<string>#222218</string>
|
||||||
|
<key>gutterForeground</key>
|
||||||
|
<string>#54546D</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Comment</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>comment</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#727169</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>String</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>string</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#98BB6C</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Number</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.numeric</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#D27E99</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Built-in constant</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.language</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#FFA066</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>User-defined constant</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.character, constant.other</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E6C384</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Variable</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>variable</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string>#E6C384</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Ruby's @variable</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>variable.other.readwrite.instance</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E6C384</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>String interpolation</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.character.escaped, constant.character.escape, string source, string source.ruby</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#C0A36E</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Keyword</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>keyword</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E46876</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Storage</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>storage</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#957FB8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Storage type</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>storage.type</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#957FB8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Class name</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.name.class</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7AA89F</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Inherited class</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.other.inherited-class</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7AA89F</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Function name</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.name.function</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7E9CD8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Function argument</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>variable.parameter</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#b8b4d0</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Tag name</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.name.tag</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7FB4CA</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Tag attribute</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.other.attribute-name</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E6C384</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Library function</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>support.function</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7FB4CA</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Library constant</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>support.constant</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7FB4CA</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Library class/type</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>support.type, support.class</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7AA89F</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Library variable</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>support.other.variable</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#FFA066</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Invalid</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>invalid</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>fontStyle</key>
|
||||||
|
<string/>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#FF5D62</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Invalid deprecated</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>invalid.deprecated</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#717C7C</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>JSON String</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>meta.structure.dictionary.json string.quoted.double.json</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#957FB8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>diff.header</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>meta.diff, meta.diff.header</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#7E9CD8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>diff.deleted</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>markup.deleted</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
|
<string>#43242B</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>diff.inserted</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>markup.inserted</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
|
<string>#2B3328</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>diff.changed</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>markup.changed</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
|
<string>#49443C</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.numeric.line-number.find-in-files - match</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#54546D</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>entity.name.filename</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#C8C093</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>message.error</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E82424</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>JSON Punctuation</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>punctuation.definition.string.begin.json - meta.structure.dictionary.value.json, punctuation.definition.string.end.json - meta.structure.dictionary.value.json</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#9CABCA</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>JSON Structure</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>meta.structure.dictionary.json string.quoted.double.json</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#957FB8</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>JSON String</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>meta.structure.dictionary.value.json string.quoted.double.json</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#ffffff</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Escape Characters</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>constant.character.escape</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#FF5D62</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Regular Expressions</string>
|
||||||
|
<key>scope</key>
|
||||||
|
<string>string.regexp</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
<string>#E6C384</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>uuid</key>
|
||||||
|
<string>592FC036-6BB7-4676-A2F5-2894D48C8E33</string>
|
||||||
|
<key>colorSpaceName</key>
|
||||||
|
<string>sRGB</string>
|
||||||
|
<key>semanticClass</key>
|
||||||
|
<string>theme.dark.kanagawa</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
require("zoxide"):setup {
|
||||||
|
update_db = true,
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
[mgr]
|
||||||
|
prepend_keymap = [
|
||||||
|
# dual-pane
|
||||||
|
{ on = "\\", run = "plugin split-tabs spl_toggle", desc = "Dual-pane: toggle" },
|
||||||
|
{ on = "<Tab>", run = "plugin split-tabs spl_switch_tab", desc = "Dual-pane: switch pane" },
|
||||||
|
{ on = "P", run = "plugin split-tabs spl_preview", desc = "Dual-pane: toggle bottom preview" },
|
||||||
|
# preview pane
|
||||||
|
{ on = "<C-g>", run = "shell -- rofi -theme fullscreen-preview -show filebrowser -filebrowser-command \"ya emit reveal\" -filebrowser-directory \"$(pwd)\"", desc = "Grid view" },
|
||||||
|
# parent-arrow
|
||||||
|
{ on = "<C-k>", run = "plugin parent-arrow -1" },
|
||||||
|
{ on = "<C-j>", run = "plugin parent-arrow 1" },
|
||||||
|
|
||||||
|
# restore
|
||||||
|
{ on = "u", run = "plugin restore", desc = "Restore last deleted files/folders" },
|
||||||
|
{ on = ["i", "u"], run = "plugin restore -- --interactive", desc = "Restore deleted files/folders (Interactive)" },
|
||||||
|
{ on = ["i", "U"], run = "plugin restore -- --interactive --interactive-overwrite", desc = "Restore deleted files/folders (Interactive overwrite)" },
|
||||||
|
|
||||||
|
# zoxide
|
||||||
|
{ on = [ "z" ], run = "plugin zoxide", desc = "Jump via zoxide" },
|
||||||
|
{ on = [ "Z" ], run = "shell -- zoxide add \"$PWD\"", desc = "Add cwd to zoxide" },
|
||||||
|
{ on = [ "i", "z" ], run = "shell --block -- zoxide edit", desc = "Edit zoxide database" },
|
||||||
|
]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
[[plugin.deps]]
|
||||||
|
use = "boydaihungst/mediainfo"
|
||||||
|
rev = "a6d30a1"
|
||||||
|
hash = "7d4dd1afcb7ecbd3609c29a82d6dbc5c"
|
||||||
|
|
||||||
|
[[plugin.deps]]
|
||||||
|
use = "yazi-rs/flavors:kanagawa"
|
||||||
|
rev = "4770a34"
|
||||||
|
hash = "99aa06d3014798d86001c324468d497f"
|
||||||
|
|
||||||
|
[[plugin.deps]]
|
||||||
|
use = "boydaihungst/restore"
|
||||||
|
rev = "7bfcfcb"
|
||||||
|
hash = "bbb1569978e6d2b3e8343c6ca08a4ea6"
|
||||||
|
|
||||||
|
[[plugin.deps]]
|
||||||
|
use = "yazi-rs/plugins:zoxide"
|
||||||
|
rev = "0be29a9"
|
||||||
|
hash = "99aa06d3014798d86001c324468d497f"
|
||||||
|
|
||||||
|
[[flavor.deps]]
|
||||||
|
use = "dangooddd/kanagawa"
|
||||||
|
rev = "04985d1"
|
||||||
|
hash = "c69a63981e254a3a06a11c2bf0e6af1d"
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 186 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 286 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 261 KiB |
@@ -0,0 +1,20 @@
|
|||||||
|
Copyright (c) 2024 Lauri Niskanen
|
||||||
|
Copyright (c) 2025 Huy Hoang
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
# mediainfo.yazi (fork)
|
||||||
|
|
||||||
|
<!--toc:start-->
|
||||||
|
|
||||||
|
- [mediainfo.yazi (fork)](#mediainfoyazi-fork)
|
||||||
|
- [Preview](#preview)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Configuration:](#configuration)
|
||||||
|
- [Custom theme](#custom-theme)
|
||||||
|
<!--toc:end-->
|
||||||
|
|
||||||
|
This is a Yazi plugin for previewing media files. The preview shows thumbnail
|
||||||
|
using `ffmpeg` if available and media metadata using `mediainfo`.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> Minimum version: yazi v26.1.22.
|
||||||
|
> Check it via command `yazi --debug`
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||
|
- Video
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Audio file with cover
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Images
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- Subtitle
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- SVG+XML file doesn't have useful information, so it only show the image preview.
|
||||||
|
- There are more file extensions which are supported by mediainfo. Just add file's MIME type to `prepend_previewers`, `prepend_preloaders`.
|
||||||
|
Use `spotter` to determine File's MIME type. [Default is `<Tab>` key](https://github.com/sxyazi/yazi/blob/1a6abae974370702c8865459344bf256de58359e/yazi-config/preset/keymap-default.toml#L59)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
- Install mediainfo CLI:
|
||||||
|
- [https://mediaarea.net/en/MediaInfo/Download](https://mediaarea.net/en/MediaInfo/Download)
|
||||||
|
- Run this command in terminal to check if it's installed correctly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mediainfo --version
|
||||||
|
```
|
||||||
|
|
||||||
|
If it output `Not found` then add it to your PATH environment variable. It's better to ask ChatGPT to help you (Prompt: `Add MediaInfo CLI to PATH environment variable in Windows`).
|
||||||
|
|
||||||
|
- Install ImageMagick (for linux, you can use your distro package manager to install):
|
||||||
|
https://imagemagick.org/script/download.php
|
||||||
|
- Install this plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ya pkg add boydaihungst/mediainfo
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration:
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
>
|
||||||
|
> `mediainfo` use built-in video, image, svg, magick plugins behind the scene to render preview image, song cover.
|
||||||
|
> So you can remove those 4 plugins from `prepend_preloaders` and `prepend_previewers` sections in `yazi.toml`.
|
||||||
|
|
||||||
|
If you have cache problem, run this cmd, and follow the tips: `yazi --clear-cache`
|
||||||
|
|
||||||
|
Config folder for each OS: https://yazi-rs.github.io/docs/configuration/overview.
|
||||||
|
|
||||||
|
Create `.../yazi/yazi.toml` and add:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[plugin]
|
||||||
|
prepend_preloaders = [
|
||||||
|
# Replace magick, image, video with mediainfo
|
||||||
|
{ mime = "{audio,video,image}/*", run = "mediainfo" },
|
||||||
|
{ mime = "application/subrip", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Adobe Photoshop is image/adobe.photoshop, already handled above
|
||||||
|
# Adobe Illustrator
|
||||||
|
{ mime = "application/postscript", run = "mediainfo" },
|
||||||
|
{ mime = "application/illustrator", run = "mediainfo" },
|
||||||
|
{ mime = "application/dvb.ait", run = "mediainfo" },
|
||||||
|
{ mime = "application/vnd.adobe.illustrator", run = "mediainfo" },
|
||||||
|
{ mime = "image/x-eps", run = "mediainfo" },
|
||||||
|
{ mime = "application/eps", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Sometimes AI file is recognized as "application/pdf". Lmao.
|
||||||
|
# In this case use file extension instead:
|
||||||
|
{ url = "*.{ai,eps,ait}", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Hide metadata by default.
|
||||||
|
# Example for image mimetype:
|
||||||
|
{ mime = "{image}/*", run = "mediainfo --no-metadata" },
|
||||||
|
|
||||||
|
# Hide image preview by default.
|
||||||
|
# Example for video mimetype:
|
||||||
|
{ mime = "{video}/*", run = "mediainfo --no-preview" },
|
||||||
|
|
||||||
|
# NOTE: Use both --no-metadata and --no-preview will display nothing. :)
|
||||||
|
# Make sure both of your previewers and preloaders has the same arguments (--no-metadata and --no-preview)
|
||||||
|
]
|
||||||
|
|
||||||
|
prepend_previewers = [
|
||||||
|
# Replace magick, image, video with mediainfo
|
||||||
|
{ mime = "{audio,video,image}/*", run = "mediainfo"},
|
||||||
|
{ mime = "application/subrip", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Adobe Photoshop is image/adobe.photoshop, already handled above
|
||||||
|
# Adobe Illustrator
|
||||||
|
{ mime = "application/postscript", run = "mediainfo" },
|
||||||
|
{ mime = "application/illustrator", run = "mediainfo" },
|
||||||
|
{ mime = "application/dvb.ait", run = "mediainfo" },
|
||||||
|
{ mime = "application/vnd.adobe.illustrator", run = "mediainfo" },
|
||||||
|
{ mime = "image/x-eps", run = "mediainfo" },
|
||||||
|
{ mime = "application/eps", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Sometimes AI file is recognized as "application/pdf". Lmao.
|
||||||
|
# In this case use file extension instead:
|
||||||
|
{ url = "*.{ai,eps,ait}", run = "mediainfo" },
|
||||||
|
|
||||||
|
# Hide metadata by default.
|
||||||
|
# Example for image mimetype:
|
||||||
|
{ mime = "{image}/*", run = "mediainfo --no-metadata" },
|
||||||
|
|
||||||
|
# Hide image preview by default.
|
||||||
|
# Example for video mimetype:
|
||||||
|
{ mime = "{video}/*", run = "mediainfo --no-preview" },
|
||||||
|
|
||||||
|
# NOTE: Use both --no-metadata and --no-preview will display nothing. :)
|
||||||
|
# Make sure both of your previewers and preloaders has the same arguments (--no-metadata and --no-preview)
|
||||||
|
]
|
||||||
|
|
||||||
|
# There are more extensions, mime types which are supported by mediainfo.
|
||||||
|
# Just add file's MIME type to `previewers`, `preloaders` above.
|
||||||
|
# https://mediaarea.net/en/MediaInfo/Support/Formats
|
||||||
|
# If it's not working, file an issue at https://github.com/boydaihungst/mediainfo.yazi/issues
|
||||||
|
|
||||||
|
# For a large file like Adobe Illustrator, Adobe Photoshop, etc
|
||||||
|
# you may need to increase the memory limit if no image is rendered.
|
||||||
|
# https://yazi-rs.github.io/docs/configuration/yazi#tasks
|
||||||
|
[tasks]
|
||||||
|
image_alloc = 1073741824 # = 1024*1024*1024 = 1024MB
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom theme
|
||||||
|
|
||||||
|
Using the same style with spotter windows. [Read more](https://github.com/sxyazi/yazi/pull/2391)
|
||||||
|
|
||||||
|
Edit or add `yazi/theme.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[spot]
|
||||||
|
# Section header style.
|
||||||
|
# Example: Video, Text, Image,... with green color in preview images above
|
||||||
|
title = { fg = "green" }
|
||||||
|
|
||||||
|
# Value style.
|
||||||
|
# Example: `Format: FLAC` with blue color in preview images above
|
||||||
|
tbl_col = { fg = "blue" }
|
||||||
|
```
|
||||||
|
|
||||||
|
## (Optional) Keymaps to toggle/show/hide/reset metadata and preview image
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> Use any key you want, but make sure there is no conflicts with [default Keybindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml).
|
||||||
|
|
||||||
|
Since Yazi prioritizes the first matching key, `prepend_keymap` takes precedence over defaults.
|
||||||
|
Or you can use `keymap` to replace all other keys
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[mgr]
|
||||||
|
prepend_keymap = [
|
||||||
|
{ on = "<F3>", run = "plugin mediainfo -- toggle-metadata", desc = "Toggle media preview metadata" },
|
||||||
|
{ on = "<F4>", run = "plugin mediainfo -- toggle-preview", desc = "Toggle media preview image" },
|
||||||
|
|
||||||
|
# Hide and show metadata, image
|
||||||
|
{ on = "<F6>", run = "plugin mediainfo -- hide-metadata", desc = "Hide media preview metadata" },
|
||||||
|
{ on = "<F7>", run = "plugin mediainfo -- hide-preview", desc = "Hide media preview image" },
|
||||||
|
|
||||||
|
{ on = "<F8>", run = "plugin mediainfo -- show-metadata", desc = "Show media preview metadata" },
|
||||||
|
{ on = "<F9>", run = "plugin mediainfo -- show-preview", desc = "Show media preview image" },
|
||||||
|
|
||||||
|
# Reset to defautl settings in yazi.toml file
|
||||||
|
{ on = "<F5>", run = "plugin mediainfo -- reset", desc = "Reset media preview to default settings" },
|
||||||
|
|
||||||
|
# Use multiple actions
|
||||||
|
{ on = "<F10>", run = "plugin mediainfo -- --toggle-preview --toggle-metadata", desc = "Toggle both media preview image and metadata" },
|
||||||
|
{ on = "<F11>", run = "plugin mediainfo -- --show-preview --hide-metadata", desc = "Show media preview image and hide metadata" },
|
||||||
|
# You can also use all of them together (7 actions above). Priority is reset > toggle > hide > show
|
||||||
|
{ on = "<F12>", run = "plugin mediainfo -- --show-preview --hide-metadata --reset --show-metadata --hide-preview", desc = "Show media preview image and hide metadata" },
|
||||||
|
]
|
||||||
|
```
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
local function image_layer_count(job)
|
||||||
|
local cache = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
if not cache then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
local layer_count = utils.get_state("f" .. tostring(cache))
|
||||||
|
if layer_count then
|
||||||
|
return layer_count
|
||||||
|
end
|
||||||
|
local output, err = Command("identify")
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
if err or not output then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
layer_count = 0
|
||||||
|
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||||
|
if line:match("%S") then
|
||||||
|
layer_count = layer_count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.set_state("f" .. tostring(cache), layer_count)
|
||||||
|
return layer_count
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = ui.Line({
|
||||||
|
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
|
||||||
|
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local line_height = ui.height
|
||||||
|
and ui.height(str, { width = max_width, ansi = true, wrap = rt.preview.wrap })
|
||||||
|
or (math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1))
|
||||||
|
if next_str == nil and line_height == 1 then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if (last_line + line_height) > mediainfo_job_skip then
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
if (last_line + line_height) >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
last_line = last_line + line_height
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
if
|
||||||
|
image_layer_count(job)
|
||||||
|
< (
|
||||||
|
1
|
||||||
|
+ math.floor(
|
||||||
|
math.max(
|
||||||
|
0,
|
||||||
|
utils.get_state(const.STATE_KEY.units)
|
||||||
|
and (math.abs(job.skip / utils.get_state(const.STATE_KEY.units)))
|
||||||
|
or 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.force_render()
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if not cache_img_url_cha or cache_img_url_cha.len <= 0 then
|
||||||
|
local cache_img_status, image_preload_err
|
||||||
|
local layer_index = 0
|
||||||
|
local units = utils.get_state(const.STATE_KEY.units)
|
||||||
|
if units ~= nil then
|
||||||
|
local max_layer = image_layer_count(job)
|
||||||
|
layer_index = math.floor(math.max(0, math.abs(job.skip / units)))
|
||||||
|
if layer_index + 1 > max_layer then
|
||||||
|
layer_index = math.max(0, max_layer - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
|
||||||
|
if fs.cha(cache_img_url_tmp) then
|
||||||
|
fs.remove("file", cache_img_url_tmp)
|
||||||
|
end
|
||||||
|
local tmp_file_path, _ = type(fs.unique) == "function" and fs.unique("file", cache_img_url_tmp)
|
||||||
|
or fs.unique_name(cache_img_url_tmp)
|
||||||
|
cache_img_status, image_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-background",
|
||||||
|
"none",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) .. "[" .. tostring(
|
||||||
|
layer_index
|
||||||
|
) .. "]",
|
||||||
|
"-auto-orient",
|
||||||
|
"-strip",
|
||||||
|
"-resize",
|
||||||
|
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
||||||
|
"-quality",
|
||||||
|
rt.preview.image_quality,
|
||||||
|
string.format("PNG32:%s", tostring(tmp_file_path)),
|
||||||
|
})
|
||||||
|
:status()
|
||||||
|
if cache_img_status then
|
||||||
|
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not cache_img_status and image_preload_err then
|
||||||
|
ya.dbg("mediainfo", image_preload_err)
|
||||||
|
err_msg = err_msg .. (image_preload_err and (tostring(image_preload_err)) or "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,336 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
local function image_layer_count(job)
|
||||||
|
local cache = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
if not cache then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
local layer_count = utils.get_state("f" .. tostring(cache))
|
||||||
|
if layer_count then
|
||||||
|
return layer_count
|
||||||
|
end
|
||||||
|
local output, err = Command("identify")
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
if err or not output then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
layer_count = 0
|
||||||
|
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||||
|
if line:match("%S") then
|
||||||
|
layer_count = layer_count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.set_state("f" .. tostring(cache), layer_count)
|
||||||
|
return layer_count
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
local opt = { ansi = true, tab_size = rt.preview.tab_size, wrap = rt.preview.wrap, width = max_width }
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = label .. ": " .. value
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local wrapped = ui.lines(line, opt)
|
||||||
|
local line_height = #wrapped
|
||||||
|
local from = 1
|
||||||
|
local to = math.min(line_height, mediainfo_job_skip + limit - last_line)
|
||||||
|
|
||||||
|
local total_rendered_text_len = 1
|
||||||
|
local total_label_rendered_len = 1
|
||||||
|
local label_total_len = label and utf8.len(label .. ": ") or 0
|
||||||
|
for j = from, to do
|
||||||
|
local current_line_components = {}
|
||||||
|
local wrapped_line_len = wrapped[j]:width() or 0
|
||||||
|
local wrapped_raw =
|
||||||
|
utils.utf8_sub(line, total_rendered_text_len, total_rendered_text_len + wrapped_line_len)
|
||||||
|
wrapped_line_len = utf8.len(wrapped_raw)
|
||||||
|
total_rendered_text_len = total_rendered_text_len + wrapped_line_len
|
||||||
|
|
||||||
|
if last_line + 1 > mediainfo_job_skip then
|
||||||
|
local label_raw = label_total_len - total_label_rendered_len <= 0 and ""
|
||||||
|
or utils.utf8_sub(wrapped_raw, 1, label_total_len - total_label_rendered_len)
|
||||||
|
local label_raw_len = utf8.len(label_raw)
|
||||||
|
if label_raw_len > 0 then
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(label_raw):style(ui.Style():fg("reset"):bold())
|
||||||
|
)
|
||||||
|
total_label_rendered_len = total_label_rendered_len + label_raw_len
|
||||||
|
wrapped_raw = wrapped_raw:gsub("^" .. utils.is_literal_string(label_raw), "", 1)
|
||||||
|
end
|
||||||
|
if total_label_rendered_len >= label_total_len then
|
||||||
|
local value_raw = wrapped_raw
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(value_raw or ""):style(
|
||||||
|
label and (th.spot.tbl_col or ui.Style():fg("blue"))
|
||||||
|
or (th.spot.title or ui.Style():fg("green"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
table.insert(lines, ui.Line(current_line_components))
|
||||||
|
-- last_line = last_line + 1
|
||||||
|
else
|
||||||
|
total_label_rendered_len = total_label_rendered_len + total_rendered_text_len
|
||||||
|
end
|
||||||
|
last_line = last_line + 1
|
||||||
|
if next_str == nil and not wrapped[j + 1] then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if last_line >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
if
|
||||||
|
image_layer_count(job)
|
||||||
|
< (
|
||||||
|
1
|
||||||
|
+ math.floor(
|
||||||
|
math.max(
|
||||||
|
0,
|
||||||
|
utils.get_state(const.STATE_KEY.units)
|
||||||
|
and (math.abs(job.skip / utils.get_state(const.STATE_KEY.units)))
|
||||||
|
or 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.force_render()
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if not cache_img_url_cha or cache_img_url_cha.len <= 0 then
|
||||||
|
local cache_img_status, image_preload_err
|
||||||
|
local layer_index = 0
|
||||||
|
local units = utils.get_state(const.STATE_KEY.units)
|
||||||
|
if units ~= nil then
|
||||||
|
local max_layer = image_layer_count(job)
|
||||||
|
layer_index = math.floor(math.max(0, math.abs(job.skip / units)))
|
||||||
|
if layer_index + 1 > max_layer then
|
||||||
|
layer_index = math.max(0, max_layer - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
|
||||||
|
if fs.cha(cache_img_url_tmp) then
|
||||||
|
fs.remove("file", cache_img_url_tmp)
|
||||||
|
end
|
||||||
|
local tmp_file_path, _ = type(fs.unique) == "function" and fs.unique("file", cache_img_url_tmp)
|
||||||
|
or fs.unique_name(cache_img_url_tmp)
|
||||||
|
cache_img_status, image_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-background",
|
||||||
|
"none",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) .. "[" .. tostring(
|
||||||
|
layer_index
|
||||||
|
) .. "]",
|
||||||
|
"-auto-orient",
|
||||||
|
"-strip",
|
||||||
|
"-resize",
|
||||||
|
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
||||||
|
"-quality",
|
||||||
|
rt.preview.image_quality,
|
||||||
|
string.format("PNG32:%s", tostring(tmp_file_path)),
|
||||||
|
})
|
||||||
|
:status()
|
||||||
|
if cache_img_status then
|
||||||
|
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not cache_img_status and image_preload_err then
|
||||||
|
ya.dbg("mediainfo", image_preload_err)
|
||||||
|
err_msg = err_msg .. (image_preload_err and (tostring(image_preload_err)) or "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,343 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
local function get_cover_layers(job)
|
||||||
|
local cache = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
if not cache then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
local covers = utils.get_state("f" .. tostring(cache))
|
||||||
|
if covers and type(covers) == "table" then
|
||||||
|
return covers
|
||||||
|
end
|
||||||
|
local output, err = Command("ffprobe"):arg({
|
||||||
|
"-v",
|
||||||
|
"error",
|
||||||
|
"-select_streams",
|
||||||
|
"v",
|
||||||
|
"-show_entries",
|
||||||
|
"stream=index:stream_disposition=attached_pic",
|
||||||
|
"-of",
|
||||||
|
"json",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
}):output()
|
||||||
|
if err or not output then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
covers = {}
|
||||||
|
local data = ya.json_decode(output.stdout)
|
||||||
|
if type(data.streams) == "table" then
|
||||||
|
for _, stream in ipairs(data.streams) do
|
||||||
|
if stream.disposition and stream.disposition.attached_pic then
|
||||||
|
covers[#covers + 1] = stream.index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.set_state("f" .. tostring(cache), covers)
|
||||||
|
return covers
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = ui.Line({
|
||||||
|
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
|
||||||
|
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local line_height = ui.height
|
||||||
|
and ui.height(str, { width = max_width, ansi = true, wrap = rt.preview.wrap })
|
||||||
|
or (math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1))
|
||||||
|
if next_str == nil and line_height == 1 then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if (last_line + line_height) > mediainfo_job_skip then
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
if (last_line + line_height) >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
last_line = last_line + line_height
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
local covers = get_cover_layers(job)
|
||||||
|
local cover_index = math.floor(
|
||||||
|
math.max(
|
||||||
|
1,
|
||||||
|
utils.get_state(const.STATE_KEY.units)
|
||||||
|
and (math.abs(job.skip / utils.get_state(const.STATE_KEY.units)))
|
||||||
|
or 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not covers[cover_index] then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- NOTE: Recalculate mediainfo using cached latest valid skip value when reach the end of mediainfo output
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.force_render()
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if cache_img_url and (not cache_img_url_cha or cache_img_url_cha.len <= 0) then
|
||||||
|
local units = utils.get_state(const.STATE_KEY.units)
|
||||||
|
local covers = get_cover_layers(job)
|
||||||
|
local cover_index = covers[1] or 0
|
||||||
|
if units ~= nil then
|
||||||
|
cover_index = math.floor(math.max(1, math.abs(job.skip / units)))
|
||||||
|
if not covers[cover_index] then
|
||||||
|
cover_index = math.max(0, #covers - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local qv = 31 - math.floor(rt.preview.image_quality * 0.3)
|
||||||
|
local audio_preload_output, audio_preload_err = Command("ffmpeg"):arg({
|
||||||
|
"-v",
|
||||||
|
"error",
|
||||||
|
"-threads",
|
||||||
|
1,
|
||||||
|
"-i",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
"-map",
|
||||||
|
string.format("0:v:%d?", cover_index),
|
||||||
|
"-an",
|
||||||
|
"-sn",
|
||||||
|
"-dn",
|
||||||
|
"-vframes",
|
||||||
|
1,
|
||||||
|
"-q:v",
|
||||||
|
qv,
|
||||||
|
"-vf",
|
||||||
|
string.format("scale=-1:'min(%d,ih)':flags=fast_bilinear", rt.preview.max_height / 2),
|
||||||
|
"-f",
|
||||||
|
"image2",
|
||||||
|
"-y",
|
||||||
|
tostring(cache_img_url),
|
||||||
|
}):output()
|
||||||
|
-- NOTE: Some audio types doesn't have cover image -> error ""
|
||||||
|
if audio_preload_err then
|
||||||
|
ya.dbg("mediainfo", audio_preload_err)
|
||||||
|
err_msg = err_msg
|
||||||
|
.. string.format(
|
||||||
|
"Failed to start `%s`.\n Error: %s\n",
|
||||||
|
"ffmpeg",
|
||||||
|
tostring(audio_preload_err or (audio_preload_output and audio_preload_output.stderr or ""))
|
||||||
|
)
|
||||||
|
elseif
|
||||||
|
audio_preload_output
|
||||||
|
and type(audio_preload_output.stderr) == "string"
|
||||||
|
and audio_preload_output.stderr:find("does not contain any stream")
|
||||||
|
then
|
||||||
|
ya.dbg("mediainfo", audio_preload_output and audio_preload_output.stderr)
|
||||||
|
cache_img_url_cha, _ = fs.cha(cache_img_url)
|
||||||
|
if cache_img_url_cha then
|
||||||
|
fs.remove("file", Url(cache_img_url))
|
||||||
|
end
|
||||||
|
-- NOTE: Workaround case audio has no cover image. Prevent regenerate preview image
|
||||||
|
audio_preload_output, audio_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-size",
|
||||||
|
"1x1",
|
||||||
|
"canvas:none",
|
||||||
|
string.format("PNG32:%s", cache_img_url),
|
||||||
|
})
|
||||||
|
:output()
|
||||||
|
if
|
||||||
|
(audio_preload_output and audio_preload_output.stderr ~= nil and audio_preload_output.stderr ~= "")
|
||||||
|
or audio_preload_err
|
||||||
|
then
|
||||||
|
ya.dbg("mediainfo", audio_preload_err or (audio_preload_output and audio_preload_output.stderr))
|
||||||
|
err_msg = err_msg
|
||||||
|
.. string.format(
|
||||||
|
"Failed to start `%s`.\n Error: %s\n",
|
||||||
|
"magick",
|
||||||
|
tostring(audio_preload_err or (audio_preload_output and audio_preload_output.stderr or ""))
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,379 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
local function get_cover_layers(job)
|
||||||
|
local cache = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
if not cache then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
local covers = utils.get_state("f" .. tostring(cache))
|
||||||
|
if covers and type(covers) == "table" then
|
||||||
|
return covers
|
||||||
|
end
|
||||||
|
local output, err = Command("ffprobe"):arg({
|
||||||
|
"-v",
|
||||||
|
"error",
|
||||||
|
"-select_streams",
|
||||||
|
"v",
|
||||||
|
"-show_entries",
|
||||||
|
"stream=index:stream_disposition=attached_pic",
|
||||||
|
"-of",
|
||||||
|
"json",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
}):output()
|
||||||
|
if err or not output then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
covers = {}
|
||||||
|
local data = ya.json_decode(output.stdout)
|
||||||
|
if type(data.streams) == "table" then
|
||||||
|
for _, stream in ipairs(data.streams) do
|
||||||
|
if stream.disposition and stream.disposition.attached_pic then
|
||||||
|
covers[#covers + 1] = stream.index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.set_state("f" .. tostring(cache), covers)
|
||||||
|
return covers
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
local opt = { ansi = true, tab_size = rt.preview.tab_size, wrap = rt.preview.wrap, width = max_width }
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = label .. ": " .. value
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local wrapped = ui.lines(line, opt)
|
||||||
|
local line_height = #wrapped
|
||||||
|
local from = 1
|
||||||
|
local to = math.min(line_height, mediainfo_job_skip + limit - last_line)
|
||||||
|
|
||||||
|
local total_rendered_text_len = 1
|
||||||
|
local total_label_rendered_len = 1
|
||||||
|
local label_total_len = label and utf8.len(label .. ": ") or 0
|
||||||
|
for j = from, to do
|
||||||
|
local current_line_components = {}
|
||||||
|
local wrapped_line_len = wrapped[j]:width() or 0
|
||||||
|
local wrapped_raw =
|
||||||
|
utils.utf8_sub(line, total_rendered_text_len, total_rendered_text_len + wrapped_line_len)
|
||||||
|
wrapped_line_len = utf8.len(wrapped_raw)
|
||||||
|
total_rendered_text_len = total_rendered_text_len + wrapped_line_len
|
||||||
|
|
||||||
|
if last_line + 1 > mediainfo_job_skip then
|
||||||
|
local label_raw = label_total_len - total_label_rendered_len <= 0 and ""
|
||||||
|
or utils.utf8_sub(wrapped_raw, 1, label_total_len - total_label_rendered_len)
|
||||||
|
local label_raw_len = utf8.len(label_raw)
|
||||||
|
if label_raw_len > 0 then
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(label_raw):style(ui.Style():fg("reset"):bold())
|
||||||
|
)
|
||||||
|
total_label_rendered_len = total_label_rendered_len + label_raw_len
|
||||||
|
wrapped_raw = wrapped_raw:gsub("^" .. utils.is_literal_string(label_raw), "", 1)
|
||||||
|
end
|
||||||
|
if total_label_rendered_len >= label_total_len then
|
||||||
|
local value_raw = wrapped_raw
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(value_raw or ""):style(
|
||||||
|
label and (th.spot.tbl_col or ui.Style():fg("blue"))
|
||||||
|
or (th.spot.title or ui.Style():fg("green"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
table.insert(lines, ui.Line(current_line_components))
|
||||||
|
-- last_line = last_line + 1
|
||||||
|
else
|
||||||
|
total_label_rendered_len = total_label_rendered_len + total_rendered_text_len
|
||||||
|
end
|
||||||
|
last_line = last_line + 1
|
||||||
|
if next_str == nil and not wrapped[j + 1] then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if last_line >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
local covers = get_cover_layers(job)
|
||||||
|
local cover_index = math.floor(
|
||||||
|
math.max(
|
||||||
|
1,
|
||||||
|
utils.get_state(const.STATE_KEY.units)
|
||||||
|
and (math.abs(job.skip / utils.get_state(const.STATE_KEY.units)))
|
||||||
|
or 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not covers[cover_index] then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- NOTE: Recalculate mediainfo using cached latest valid skip value when reach the end of mediainfo output
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utils.force_render()
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache(job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if cache_img_url and (not cache_img_url_cha or cache_img_url_cha.len <= 0) then
|
||||||
|
local units = utils.get_state(const.STATE_KEY.units)
|
||||||
|
local covers = get_cover_layers(job)
|
||||||
|
local cover_index = covers[1] or 0
|
||||||
|
if units ~= nil then
|
||||||
|
cover_index = math.floor(math.max(1, math.abs(job.skip / units)))
|
||||||
|
if not covers[cover_index] then
|
||||||
|
cover_index = math.max(0, #covers - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local qv = 31 - math.floor(rt.preview.image_quality * 0.3)
|
||||||
|
local audio_preload_output, audio_preload_err = Command("ffmpeg"):arg({
|
||||||
|
"-v",
|
||||||
|
"error",
|
||||||
|
"-threads",
|
||||||
|
1,
|
||||||
|
"-i",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
"-map",
|
||||||
|
string.format("0:v:%d?", cover_index),
|
||||||
|
"-an",
|
||||||
|
"-sn",
|
||||||
|
"-dn",
|
||||||
|
"-vframes",
|
||||||
|
1,
|
||||||
|
"-q:v",
|
||||||
|
qv,
|
||||||
|
"-vf",
|
||||||
|
string.format("scale=-1:'min(%d,ih)':flags=fast_bilinear", rt.preview.max_height / 2),
|
||||||
|
"-f",
|
||||||
|
"image2",
|
||||||
|
"-y",
|
||||||
|
tostring(cache_img_url),
|
||||||
|
}):output()
|
||||||
|
-- NOTE: Some audio types doesn't have cover image -> error ""
|
||||||
|
if audio_preload_err then
|
||||||
|
ya.dbg("mediainfo", audio_preload_err)
|
||||||
|
err_msg = err_msg
|
||||||
|
.. string.format(
|
||||||
|
"Failed to start `%s`.\n Error: %s\n",
|
||||||
|
"ffmpeg",
|
||||||
|
tostring(audio_preload_err or (audio_preload_output and audio_preload_output.stderr or ""))
|
||||||
|
)
|
||||||
|
elseif
|
||||||
|
audio_preload_output
|
||||||
|
and type(audio_preload_output.stderr) == "string"
|
||||||
|
and audio_preload_output.stderr:find("does not contain any stream")
|
||||||
|
then
|
||||||
|
ya.dbg("mediainfo", audio_preload_output and audio_preload_output.stderr)
|
||||||
|
cache_img_url_cha, _ = fs.cha(cache_img_url)
|
||||||
|
if cache_img_url_cha then
|
||||||
|
fs.remove("file", Url(cache_img_url))
|
||||||
|
end
|
||||||
|
-- NOTE: Workaround case audio has no cover image. Prevent regenerate preview image
|
||||||
|
audio_preload_output, audio_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-size",
|
||||||
|
"1x1",
|
||||||
|
"canvas:none",
|
||||||
|
string.format("PNG32:%s", cache_img_url),
|
||||||
|
})
|
||||||
|
:output()
|
||||||
|
if
|
||||||
|
(audio_preload_output and audio_preload_output.stderr ~= nil and audio_preload_output.stderr ~= "")
|
||||||
|
or audio_preload_err
|
||||||
|
then
|
||||||
|
ya.dbg("mediainfo", audio_preload_err or (audio_preload_output and audio_preload_output.stderr))
|
||||||
|
err_msg = err_msg
|
||||||
|
.. string.format(
|
||||||
|
"Failed to start `%s`.\n Error: %s\n",
|
||||||
|
"magick",
|
||||||
|
tostring(audio_preload_err or (audio_preload_output and audio_preload_output.stderr or ""))
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.skip_labels = {
|
||||||
|
["Complete name"] = true,
|
||||||
|
["CompleteName_Last"] = true,
|
||||||
|
["Unique ID"] = true,
|
||||||
|
["File size"] = true,
|
||||||
|
["Format/Info"] = true,
|
||||||
|
["Codec ID/Info"] = true,
|
||||||
|
["MD5 of the unencoded content"] = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
M.ENTRY_ACTION = {
|
||||||
|
toggle_metadata = "toggle-metadata",
|
||||||
|
toggle_preview = "toggle-preview",
|
||||||
|
hide_metadata = "hide-metadata",
|
||||||
|
hide_preview = "hide-preview",
|
||||||
|
show_metadata = "show-metadata",
|
||||||
|
show_preview = "show-preview",
|
||||||
|
reset = "reset",
|
||||||
|
}
|
||||||
|
|
||||||
|
M.STATE_KEY = {
|
||||||
|
units = "units",
|
||||||
|
no_metadata = "no_metadata",
|
||||||
|
no_preview = "no_preview",
|
||||||
|
prev_metadata_area = "prev_metadata_area",
|
||||||
|
prev_image_height = "prev_image_height",
|
||||||
|
last_valid_mediainfo_skip = "last_valid_mediainfo_skip",
|
||||||
|
cached_mediainfo = "cached_mediainfo",
|
||||||
|
cached_job_args = "cached_job_args",
|
||||||
|
}
|
||||||
|
|
||||||
|
M.magick_image_mimes = {
|
||||||
|
avif = true,
|
||||||
|
hei = true,
|
||||||
|
heic = true,
|
||||||
|
heif = true,
|
||||||
|
["heif-sequence"] = true,
|
||||||
|
["heic-sequence"] = true,
|
||||||
|
jxl = true,
|
||||||
|
tiff = true,
|
||||||
|
xml = true,
|
||||||
|
-- ["svg+xml"] = true,
|
||||||
|
["canon-cr2"] = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
M.seekable_mimes = {
|
||||||
|
-- NOTE: Adobe illustrator photoshop mimetypes
|
||||||
|
["application/postscript"] = true,
|
||||||
|
["application/dvb.ait"] = true,
|
||||||
|
["application/illustrator"] = true,
|
||||||
|
["application/vnd.adobe.illustrator"] = true,
|
||||||
|
["image/x-eps"] = true,
|
||||||
|
["application/eps"] = true,
|
||||||
|
["application/pdf"] = true,
|
||||||
|
|
||||||
|
["image/adobe.photoshop"] = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
M.suffix = "_mediainfo"
|
||||||
|
M.SHELL = os.getenv("SHELL") or ""
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache({
|
||||||
|
skip = 0,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = ui.Line({
|
||||||
|
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
|
||||||
|
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local line_height = ui.height
|
||||||
|
and ui.height(str, { width = max_width, ansi = true, wrap = rt.preview.wrap })
|
||||||
|
or (math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1))
|
||||||
|
if next_str == nil and line_height == 1 then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if (last_line + line_height) > job.skip then
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
if (last_line + line_height) >= job.skip + limit then
|
||||||
|
last_line = job.skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
last_line = last_line + line_height
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata and EOF_mediainfo and #lines == 0 and job.skip > 0 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local mime = job.mime:match(".*/(.*)$")
|
||||||
|
local is_svg = mime == "svg+xml"
|
||||||
|
local is_magick = const.magick_image_mimes[mime]
|
||||||
|
local no_skip_job = { skip = 0, file = job.file, args = job.args, area = job.area }
|
||||||
|
local cache_img_url = ya.file_cache(no_skip_job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if not cache_img_url_cha or cache_img_url_cha.len <= 0 then
|
||||||
|
local cache_img_status, image_preload_err
|
||||||
|
if not is_valid_utf8_path then
|
||||||
|
-- NOTE: Case not valid utf8 path, use trick to generate preview image
|
||||||
|
if is_svg then
|
||||||
|
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
|
||||||
|
if fs.cha(cache_img_url_tmp) then
|
||||||
|
fs.remove("file", cache_img_url_tmp)
|
||||||
|
end
|
||||||
|
local tmp_file_path, _ = type(fs.unique) == "function" and fs.unique("file", cache_img_url_tmp)
|
||||||
|
or fs.unique_name(cache_img_url_tmp)
|
||||||
|
-- svg under invalid utf8 path
|
||||||
|
cache_img_status, image_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-background",
|
||||||
|
"none",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
"-auto-orient",
|
||||||
|
"-strip",
|
||||||
|
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
||||||
|
"-quality",
|
||||||
|
rt.preview.image_quality,
|
||||||
|
string.format("PNG32:%s", tostring(tmp_file_path)),
|
||||||
|
})
|
||||||
|
:status()
|
||||||
|
if cache_img_status then
|
||||||
|
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- NOTE: Case valid utf8 path, use image, svg, or magick module
|
||||||
|
local image_module = is_svg and "svg" or (is_magick and "magick" or "image")
|
||||||
|
cache_img_status, image_preload_err = require(image_module):preload(no_skip_job)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not cache_img_status and image_preload_err then
|
||||||
|
ya.dbg("mediainfo", image_preload_err)
|
||||||
|
err_msg = err_msg .. (image_preload_err and (tostring(image_preload_err)) or "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,288 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache({
|
||||||
|
skip = 0,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
local opt = { ansi = true, tab_size = rt.preview.tab_size, wrap = rt.preview.wrap, width = max_width }
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = label .. ": " .. value
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local wrapped = ui.lines(line, opt)
|
||||||
|
local line_height = #wrapped
|
||||||
|
local from = 1
|
||||||
|
local to = math.min(line_height, mediainfo_job_skip + limit - last_line)
|
||||||
|
|
||||||
|
local total_rendered_text_len = 1
|
||||||
|
local total_label_rendered_len = 1
|
||||||
|
local label_total_len = label and utf8.len(label .. ": ") or 0
|
||||||
|
for j = from, to do
|
||||||
|
local current_line_components = {}
|
||||||
|
local wrapped_line_len = wrapped[j]:width() or 0
|
||||||
|
local wrapped_raw =
|
||||||
|
utils.utf8_sub(line, total_rendered_text_len, total_rendered_text_len + wrapped_line_len)
|
||||||
|
wrapped_line_len = utf8.len(wrapped_raw)
|
||||||
|
total_rendered_text_len = total_rendered_text_len + wrapped_line_len
|
||||||
|
|
||||||
|
if last_line + 1 > mediainfo_job_skip then
|
||||||
|
local label_raw = label_total_len - total_label_rendered_len <= 0 and ""
|
||||||
|
or utils.utf8_sub(wrapped_raw, 1, label_total_len - total_label_rendered_len)
|
||||||
|
local label_raw_len = utf8.len(label_raw)
|
||||||
|
if label_raw_len > 0 then
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(label_raw):style(ui.Style():fg("reset"):bold())
|
||||||
|
)
|
||||||
|
total_label_rendered_len = total_label_rendered_len + label_raw_len
|
||||||
|
wrapped_raw = wrapped_raw:gsub("^" .. utils.is_literal_string(label_raw), "", 1)
|
||||||
|
end
|
||||||
|
if total_label_rendered_len >= label_total_len then
|
||||||
|
local value_raw = wrapped_raw
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(value_raw or ""):style(
|
||||||
|
label and (th.spot.tbl_col or ui.Style():fg("blue"))
|
||||||
|
or (th.spot.title or ui.Style():fg("green"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
table.insert(lines, ui.Line(current_line_components))
|
||||||
|
-- last_line = last_line + 1
|
||||||
|
else
|
||||||
|
total_label_rendered_len = total_label_rendered_len + total_rendered_text_len
|
||||||
|
end
|
||||||
|
last_line = last_line + 1
|
||||||
|
if next_str == nil and not wrapped[j + 1] then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if last_line >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata and EOF_mediainfo and #lines == 0 and job.skip > 0 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Preload image
|
||||||
|
|
||||||
|
local mime = job.mime:match(".*/(.*)$")
|
||||||
|
local is_svg = mime == "svg+xml"
|
||||||
|
local is_magick = const.magick_image_mimes[mime]
|
||||||
|
local no_skip_job = { skip = 0, file = job.file, args = job.args, area = job.area }
|
||||||
|
local cache_img_url = ya.file_cache(no_skip_job)
|
||||||
|
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
|
||||||
|
|
||||||
|
-- NOTE: Only generate preview image when cache image is not exist
|
||||||
|
if not cache_img_url_cha or cache_img_url_cha.len <= 0 then
|
||||||
|
local cache_img_status, image_preload_err
|
||||||
|
if not is_valid_utf8_path then
|
||||||
|
-- NOTE: Case not valid utf8 path, use trick to generate preview image
|
||||||
|
if is_svg then
|
||||||
|
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
|
||||||
|
if fs.cha(cache_img_url_tmp) then
|
||||||
|
fs.remove("file", cache_img_url_tmp)
|
||||||
|
end
|
||||||
|
local tmp_file_path, _ = type(fs.unique) == "function" and fs.unique("file", cache_img_url_tmp)
|
||||||
|
or fs.unique_name(cache_img_url_tmp)
|
||||||
|
-- svg under invalid utf8 path
|
||||||
|
cache_img_status, image_preload_err = require("magick")
|
||||||
|
.with_limit()
|
||||||
|
:arg({
|
||||||
|
"-background",
|
||||||
|
"none",
|
||||||
|
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
|
||||||
|
"-auto-orient",
|
||||||
|
"-strip",
|
||||||
|
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
||||||
|
"-quality",
|
||||||
|
rt.preview.image_quality,
|
||||||
|
string.format("PNG32:%s", tostring(tmp_file_path)),
|
||||||
|
})
|
||||||
|
:status()
|
||||||
|
if cache_img_status then
|
||||||
|
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- NOTE: Case valid utf8 path, use image, svg, or magick module
|
||||||
|
local image_module = is_svg and "svg" or (is_magick and "magick" or "image")
|
||||||
|
cache_img_status, image_preload_err = require(image_module):preload(no_skip_job)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not cache_img_status and image_preload_err then
|
||||||
|
ya.dbg("mediainfo", image_preload_err)
|
||||||
|
err_msg = err_msg .. (image_preload_err and (tostring(image_preload_err)) or "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local using_new_height_api = ui.lines ~= nil
|
||||||
|
local const
|
||||||
|
local utils
|
||||||
|
local adobe
|
||||||
|
local audio
|
||||||
|
local image
|
||||||
|
local video
|
||||||
|
local none_media_preview
|
||||||
|
|
||||||
|
const = require(".const")
|
||||||
|
utils = require(".utils")
|
||||||
|
|
||||||
|
if using_new_height_api then
|
||||||
|
ya.dbg("mediainfo", "Using yazi version >= 26.5.6")
|
||||||
|
adobe = require(".adobe-stable")
|
||||||
|
audio = require(".audio-stable")
|
||||||
|
image = require(".image-stable")
|
||||||
|
video = require(".video-stable")
|
||||||
|
none_media_preview = require(".none-media-preview-stable")
|
||||||
|
else
|
||||||
|
ya.dbg("mediainfo", "Using yazi version <= 26.1.22")
|
||||||
|
adobe = require(".adobe-old")
|
||||||
|
audio = require(".audio-old")
|
||||||
|
image = require(".image-old")
|
||||||
|
video = require(".video-old")
|
||||||
|
none_media_preview = require(".none-media-preview-old")
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
-- debounce peek
|
||||||
|
local start = os.clock()
|
||||||
|
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
|
||||||
|
|
||||||
|
-- Need mime to decide which module to use
|
||||||
|
if not job.mime then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local no_metadata_user_cfg = utils.get_state(const.STATE_KEY.no_metadata)
|
||||||
|
if no_metadata_user_cfg ~= nil then
|
||||||
|
job.args.no_metadata = no_metadata_user_cfg
|
||||||
|
end
|
||||||
|
|
||||||
|
local no_preview_user_cfg = utils.get_state(const.STATE_KEY.no_preview)
|
||||||
|
if no_preview_user_cfg ~= nil then
|
||||||
|
job.args.no_preview = no_preview_user_cfg
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.set_states(const.STATE_KEY.cached_job_args, tostring(job.file.url), job.args)
|
||||||
|
if job.args.no_preview and job.args.no_metadata then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(job.area),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if job.args.no_preview then
|
||||||
|
return none_media_preview:peek(job)
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_video = string.find(job.mime, "^video/")
|
||||||
|
local is_audio = string.find(job.mime, "^audio/")
|
||||||
|
local is_image = string.find(job.mime, "^image/")
|
||||||
|
local is_adobe = const.seekable_mimes[job.mime]
|
||||||
|
|
||||||
|
if is_adobe then
|
||||||
|
return adobe:peek(job)
|
||||||
|
elseif is_image then
|
||||||
|
return image:peek(job)
|
||||||
|
elseif is_video then
|
||||||
|
return video:peek(job)
|
||||||
|
elseif is_audio then
|
||||||
|
return audio:peek(job)
|
||||||
|
else
|
||||||
|
return none_media_preview:peek(job)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:seek(job)
|
||||||
|
local h = cx.active.current.hovered
|
||||||
|
if h and h.url == job.file.url then
|
||||||
|
utils.set_state(const.STATE_KEY.units, job.units)
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, cx.active.preview.skip + job.units),
|
||||||
|
only_if = job.file.url,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function M:preload(job)
|
||||||
|
local cache_img_url = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
if not cache_img_url then
|
||||||
|
ya.dbg("mediainfo", "Can't access yazi cache folder")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if not job.mime then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local no_metadata_user_cfg = utils.get_state(const.STATE_KEY.no_metadata)
|
||||||
|
if no_metadata_user_cfg ~= nil then
|
||||||
|
job.args.no_metadata = no_metadata_user_cfg
|
||||||
|
end
|
||||||
|
|
||||||
|
local no_preview_user_cfg = utils.get_state(const.STATE_KEY.no_preview)
|
||||||
|
if no_preview_user_cfg ~= nil then
|
||||||
|
job.args.no_preview = no_preview_user_cfg
|
||||||
|
end
|
||||||
|
|
||||||
|
if job.args.no_preview and job.args.no_metadata then
|
||||||
|
return false, nil
|
||||||
|
end
|
||||||
|
if job.args.no_preview then
|
||||||
|
return none_media_preview:peek(job)
|
||||||
|
end
|
||||||
|
|
||||||
|
local is_video = string.find(job.mime, "^video/")
|
||||||
|
local is_audio = string.find(job.mime, "^audio/")
|
||||||
|
local is_image = string.find(job.mime, "^image/")
|
||||||
|
local is_adobe = const.seekable_mimes[job.mime]
|
||||||
|
|
||||||
|
if is_adobe then
|
||||||
|
return adobe:preload(job)
|
||||||
|
elseif is_image then
|
||||||
|
return image:preload(job)
|
||||||
|
elseif is_video then
|
||||||
|
return video:preload(job)
|
||||||
|
elseif is_audio then
|
||||||
|
return audio:preload(job)
|
||||||
|
else
|
||||||
|
return none_media_preview:peek(job)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:entry(job)
|
||||||
|
local action = job.args[1]
|
||||||
|
if action == const.ENTRY_ACTION.reset or job.args.reset then
|
||||||
|
utils.set_state(const.STATE_KEY.no_preview, nil)
|
||||||
|
utils.set_state(const.STATE_KEY.no_metadata, nil)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if action == const.ENTRY_ACTION.show_metadata or job.args.show_metadata then
|
||||||
|
utils.set_state(const.STATE_KEY.no_metadata, false)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if action == const.ENTRY_ACTION.show_preview or job.args.show_preview then
|
||||||
|
utils.set_state(const.STATE_KEY.no_preview, false)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if action == const.ENTRY_ACTION.hide_metadata or job.args.hide_metadata then
|
||||||
|
utils.set_state(const.STATE_KEY.no_metadata, true)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
if action == const.ENTRY_ACTION.hide_preview or job.args.hide_preview then
|
||||||
|
utils.set_state(const.STATE_KEY.no_preview, true)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
job.retry = job.retry or 0
|
||||||
|
if job.retry > 5 then
|
||||||
|
utils.error("Preview data is loading, try again later")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local current_file = utils.current_file()
|
||||||
|
if not current_file then
|
||||||
|
ya.sleep(0.1)
|
||||||
|
job.retry = job.retry + 1
|
||||||
|
return self:entry(job)
|
||||||
|
end
|
||||||
|
|
||||||
|
local job_args = utils.get_states(const.STATE_KEY.cached_job_args, current_file)
|
||||||
|
if not job_args then
|
||||||
|
ya.sleep(0.1)
|
||||||
|
job.retry = job.retry + 1
|
||||||
|
return self:entry(job)
|
||||||
|
end
|
||||||
|
|
||||||
|
if action == const.ENTRY_ACTION.toggle_metadata or job.args.toggle_metadata then
|
||||||
|
utils.set_state(const.STATE_KEY.no_metadata, not job_args.no_metadata)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
if action == const.ENTRY_ACTION.toggle_preview or job.args.toggle_preview then
|
||||||
|
utils.set_state(const.STATE_KEY.no_preview, not job_args.no_preview)
|
||||||
|
ya.emit("peek", {
|
||||||
|
force = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = ui.Line({
|
||||||
|
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
|
||||||
|
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local line_height = ui.height
|
||||||
|
and ui.height(str, { width = max_width, ansi = true, wrap = rt.preview.wrap })
|
||||||
|
or (math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1))
|
||||||
|
if next_str == nil and line_height == 1 then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if (last_line + line_height) > job.skip then
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
if (last_line + line_height) >= job.skip + limit then
|
||||||
|
last_line = job.skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
last_line = last_line + line_height
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if EOF_mediainfo and #lines == 0 and job.skip > 0 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
-- Handle preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(job.area),
|
||||||
|
ui.Text(lines):area(job.area):wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
local opt = { ansi = true, tab_size = rt.preview.tab_size, wrap = rt.preview.wrap, width = max_width }
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = label .. ": " .. value
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local wrapped = ui.lines(line, opt)
|
||||||
|
local line_height = #wrapped
|
||||||
|
local from = 1
|
||||||
|
local to = math.min(line_height, job.skip + limit - last_line)
|
||||||
|
|
||||||
|
local total_rendered_text_len = 1
|
||||||
|
local total_label_rendered_len = 1
|
||||||
|
local label_total_len = label and utf8.len(label .. ": ") or 0
|
||||||
|
for j = from, to do
|
||||||
|
local current_line_components = {}
|
||||||
|
local wrapped_line_len = wrapped[j]:width() or 0
|
||||||
|
local wrapped_raw =
|
||||||
|
utils.utf8_sub(line, total_rendered_text_len, total_rendered_text_len + wrapped_line_len)
|
||||||
|
wrapped_line_len = utf8.len(wrapped_raw)
|
||||||
|
total_rendered_text_len = total_rendered_text_len + wrapped_line_len
|
||||||
|
|
||||||
|
if last_line + 1 > job.skip then
|
||||||
|
local label_raw = label_total_len - total_label_rendered_len <= 0 and ""
|
||||||
|
or utils.utf8_sub(wrapped_raw, 1, label_total_len - total_label_rendered_len)
|
||||||
|
local label_raw_len = utf8.len(label_raw)
|
||||||
|
if label_raw_len > 0 then
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(label_raw):style(ui.Style():fg("reset"):bold())
|
||||||
|
)
|
||||||
|
total_label_rendered_len = total_label_rendered_len + label_raw_len
|
||||||
|
wrapped_raw = wrapped_raw:gsub("^" .. utils.is_literal_string(label_raw), "", 1)
|
||||||
|
end
|
||||||
|
if total_label_rendered_len >= label_total_len then
|
||||||
|
local value_raw = wrapped_raw
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(value_raw or ""):style(
|
||||||
|
label and (th.spot.tbl_col or ui.Style():fg("blue"))
|
||||||
|
or (th.spot.title or ui.Style():fg("green"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
table.insert(lines, ui.Line(current_line_components))
|
||||||
|
-- last_line = last_line + 1
|
||||||
|
else
|
||||||
|
total_label_rendered_len = total_label_rendered_len + total_rendered_text_len
|
||||||
|
end
|
||||||
|
last_line = last_line + 1
|
||||||
|
if next_str == nil and not wrapped[j + 1] then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if last_line >= job.skip + limit then
|
||||||
|
last_line = job.skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if EOF_mediainfo and #lines == 0 and job.skip > 0 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
-- Handle preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(job.area),
|
||||||
|
ui.Text(lines):area(job.area):wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local const = require(".const")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local MAX_ITEMS_IN_CACHE = 10
|
||||||
|
|
||||||
|
function M.is_valid_utf8(str)
|
||||||
|
return utf8.len(str) ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.utf8_sub(str, start_char, end_char)
|
||||||
|
local start_byte = utf8.offset(str, start_char) -- Expects start_char to be a character index
|
||||||
|
local end_byte = end_char and (utf8.offset(str, end_char + 1) or (#str + 1)) - 1 -- Expects end_char
|
||||||
|
if not start_byte then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
return str:sub(start_byte, end_byte)
|
||||||
|
end
|
||||||
|
function M.is_literal_string(str)
|
||||||
|
return str and str:gsub("([%^%$%(%)%%%.%[%]%*%+%-%?])", "%%%1")
|
||||||
|
end
|
||||||
|
function M.path_quote(path)
|
||||||
|
if not path or tostring(path) == "" then
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
local result = "'" .. string.gsub(tostring(path), "'", "'\\''") .. "'"
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
M.force_render = ya.sync(function(_, _)
|
||||||
|
(ui.render or ya.render)()
|
||||||
|
end)
|
||||||
|
|
||||||
|
M.set_state = ya.sync(function(state, key, value)
|
||||||
|
state[key] = value
|
||||||
|
end)
|
||||||
|
|
||||||
|
M.get_state = ya.sync(function(state, key)
|
||||||
|
return state[key]
|
||||||
|
end)
|
||||||
|
|
||||||
|
M.set_states = ya.sync(function(state, namespace, key, value, limit_cached_items)
|
||||||
|
if not limit_cached_items then
|
||||||
|
limit_cached_items = MAX_ITEMS_IN_CACHE
|
||||||
|
end
|
||||||
|
if not state[namespace] then
|
||||||
|
state[namespace] = {}
|
||||||
|
end
|
||||||
|
local storage = state[namespace]
|
||||||
|
if limit_cached_items and #storage > limit_cached_items then
|
||||||
|
table.remove(storage, 1)
|
||||||
|
end
|
||||||
|
storage[key] = value
|
||||||
|
end)
|
||||||
|
|
||||||
|
M.get_states = ya.sync(function(state, namespace, key)
|
||||||
|
local storage = state[namespace]
|
||||||
|
if not storage then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if storage then
|
||||||
|
return storage[key]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
function M.read_mediainfo_cached_file(file_path)
|
||||||
|
local cached = M.get_states(const.STATE_KEY.cached_mediainfo, file_path)
|
||||||
|
if cached then
|
||||||
|
return cached
|
||||||
|
end
|
||||||
|
-- Open the file in read mode
|
||||||
|
local file = io.open(file_path, "r")
|
||||||
|
|
||||||
|
if file then
|
||||||
|
-- Read the entire file content
|
||||||
|
local content = file:read("*all")
|
||||||
|
file:close()
|
||||||
|
M.set_states(const.STATE_KEY.cached_mediainfo, file_path, content)
|
||||||
|
return content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
M.current_file = ya.sync(function()
|
||||||
|
local h = cx.active.current.hovered
|
||||||
|
if not h then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return tostring(h.url)
|
||||||
|
end)
|
||||||
|
|
||||||
|
function M.error(s, ...)
|
||||||
|
ya.notify({ title = "mediainfo", content = string.format(s, ...), timeout = 3, level = "error" })
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.info(s, ...)
|
||||||
|
ya.notify({ title = "mediainfo", content = string.format(s, ...), timeout = 3, level = "info" })
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
--- @since 26.1.22
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache({
|
||||||
|
skip = job.skip > 90 and 90 or job.skip,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = ui.Line({
|
||||||
|
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
|
||||||
|
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local line_height = ui.height
|
||||||
|
and ui.height(str, { width = max_width, ansi = true, wrap = rt.preview.wrap })
|
||||||
|
or (math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1))
|
||||||
|
if next_str == nil and line_height == 1 then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if (last_line + line_height) > mediainfo_job_skip then
|
||||||
|
table.insert(lines, line)
|
||||||
|
end
|
||||||
|
if (last_line + line_height) >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
last_line = last_line + line_height
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
if job.skip > 90 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- NOTE: Recalculate mediainfo using cached latest valid skip value when reach the end of mediainfo output
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- NOTE: Workaround case video.lua doesn't doesn't generate preview image because of `skip` overflow video duration
|
||||||
|
if not rendered_img_rect then
|
||||||
|
local prev_image_height = utils.get_state(const.STATE_KEY.prev_image_height)
|
||||||
|
image_height = prev_image_height and prev_image_height[tostring(cache_img_url_no_skip)] or 0
|
||||||
|
else
|
||||||
|
utils.set_state(const.STATE_KEY.prev_image_height, { [tostring(cache_img_url_no_skip)] = image_height })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
|
||||||
|
-- NOTE: Preload image from video
|
||||||
|
|
||||||
|
local cache_img_status, video_preload_err = require("video"):preload({
|
||||||
|
skip = job.skip > 90 and 90 or job.skip,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
|
||||||
|
if not cache_img_status and video_preload_err then
|
||||||
|
ya.dbg("mediainfo", video_preload_err)
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`.\n Do you have `%s` installed?\n", "ffmpeg", "ffmpeg")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local const = require(".const")
|
||||||
|
local utils = require(".utils")
|
||||||
|
|
||||||
|
function M:peek(job)
|
||||||
|
local preload_status, preload_err = self:preload(job)
|
||||||
|
-- Stop if preload failed
|
||||||
|
if not preload_status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cache_img_url = ya.file_cache({
|
||||||
|
skip = job.skip > 90 and 90 or job.skip,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
|
||||||
|
|
||||||
|
local no_metadata = job.args.no_metadata
|
||||||
|
local mediainfo_job_skip = job.skip
|
||||||
|
::recalc_mediainfo_job_skip::
|
||||||
|
local mediainfo_height = 0
|
||||||
|
local lines = {}
|
||||||
|
local limit = job.area.h
|
||||||
|
local last_line = 0
|
||||||
|
local EOF_mediainfo = true
|
||||||
|
local is_wrap = rt.preview.wrap == "yes" or rt.preview.wrap == ui.Wrap.YES
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. const.suffix
|
||||||
|
local output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
if output then
|
||||||
|
local max_width = math.max(1, job.area.w)
|
||||||
|
if output:match("^Error:") then
|
||||||
|
job.args.force_reload_mediainfo = true
|
||||||
|
preload_status, preload_err = self:preload(job)
|
||||||
|
if not preload_status or preload_err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
output = utils.read_mediainfo_cached_file(cache_mediainfo_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
output = output:gsub("\n+$", "")
|
||||||
|
|
||||||
|
local iter = output:gmatch("[^\n]*")
|
||||||
|
local str = iter()
|
||||||
|
local opt = { ansi = true, tab_size = rt.preview.tab_size, wrap = rt.preview.wrap, width = max_width }
|
||||||
|
while str ~= nil do
|
||||||
|
local next_str = iter()
|
||||||
|
local label, value = str:match("(.*[^ ]) +: (.*)")
|
||||||
|
|
||||||
|
local line
|
||||||
|
if label then
|
||||||
|
if not const.skip_labels[label] then
|
||||||
|
line = label .. ": " .. value
|
||||||
|
end
|
||||||
|
elseif str ~= "General" then
|
||||||
|
line = str
|
||||||
|
end
|
||||||
|
|
||||||
|
if line then
|
||||||
|
local wrapped = ui.lines(line, opt)
|
||||||
|
local line_height = #wrapped
|
||||||
|
local from = 1
|
||||||
|
local to = math.min(line_height, mediainfo_job_skip + limit - last_line)
|
||||||
|
|
||||||
|
local total_rendered_text_len = 1
|
||||||
|
local total_label_rendered_len = 1
|
||||||
|
local label_total_len = label and utf8.len(label .. ": ") or 0
|
||||||
|
for j = from, to do
|
||||||
|
local current_line_components = {}
|
||||||
|
local wrapped_line_len = wrapped[j]:width() or 0
|
||||||
|
local wrapped_raw =
|
||||||
|
utils.utf8_sub(line, total_rendered_text_len, total_rendered_text_len + wrapped_line_len)
|
||||||
|
wrapped_line_len = utf8.len(wrapped_raw)
|
||||||
|
total_rendered_text_len = total_rendered_text_len + wrapped_line_len
|
||||||
|
|
||||||
|
if last_line + 1 > mediainfo_job_skip then
|
||||||
|
local label_raw = label_total_len - total_label_rendered_len <= 0 and ""
|
||||||
|
or utils.utf8_sub(wrapped_raw, 1, label_total_len - total_label_rendered_len)
|
||||||
|
local label_raw_len = utf8.len(label_raw)
|
||||||
|
if label_raw_len > 0 then
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(label_raw):style(ui.Style():fg("reset"):bold())
|
||||||
|
)
|
||||||
|
total_label_rendered_len = total_label_rendered_len + label_raw_len
|
||||||
|
wrapped_raw = wrapped_raw:gsub("^" .. utils.is_literal_string(label_raw), "", 1)
|
||||||
|
end
|
||||||
|
if total_label_rendered_len >= label_total_len then
|
||||||
|
local value_raw = wrapped_raw
|
||||||
|
table.insert(
|
||||||
|
current_line_components,
|
||||||
|
ui.Span(value_raw or ""):style(
|
||||||
|
label and (th.spot.tbl_col or ui.Style():fg("blue"))
|
||||||
|
or (th.spot.title or ui.Style():fg("green"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
table.insert(lines, ui.Line(current_line_components))
|
||||||
|
-- last_line = last_line + 1
|
||||||
|
else
|
||||||
|
total_label_rendered_len = total_label_rendered_len + total_rendered_text_len
|
||||||
|
end
|
||||||
|
last_line = last_line + 1
|
||||||
|
if next_str == nil and not wrapped[j + 1] then
|
||||||
|
EOF_mediainfo = true
|
||||||
|
end
|
||||||
|
if last_line >= mediainfo_job_skip + limit then
|
||||||
|
last_line = mediainfo_job_skip + limit
|
||||||
|
EOF_mediainfo = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = next_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mediainfo_height = math.min(limit, last_line)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not no_metadata then
|
||||||
|
if EOF_mediainfo and #lines == 0 and mediainfo_job_skip > 0 then
|
||||||
|
if job.skip > 90 then
|
||||||
|
ya.emit("peek", {
|
||||||
|
math.max(0, (job.skip - (utils.get_state(const.STATE_KEY.units) or 0))),
|
||||||
|
only_if = job.file.url,
|
||||||
|
upper_bound = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- NOTE: Recalculate mediainfo using cached latest valid skip value when reach the end of mediainfo output
|
||||||
|
local last_valid_mediainfo_skip = utils.get_state(const.STATE_KEY.last_valid_mediainfo_skip)
|
||||||
|
mediainfo_job_skip = last_valid_mediainfo_skip
|
||||||
|
and last_valid_mediainfo_skip[tostring(cache_img_url_no_skip)]
|
||||||
|
or math.max(0, mediainfo_job_skip - (utils.get_state(const.STATE_KEY.units) or 0))
|
||||||
|
|
||||||
|
goto recalc_mediainfo_job_skip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
utils.set_state(
|
||||||
|
const.STATE_KEY.last_valid_mediainfo_skip,
|
||||||
|
{ [tostring(cache_img_url_no_skip)] = mediainfo_job_skip }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
if utils.get_state(const.STATE_KEY.prev_metadata_area) then
|
||||||
|
local old_metadata_area = utils.get_state(const.STATE_KEY.prev_metadata_area)
|
||||||
|
if
|
||||||
|
old_metadata_area.win_x == job.area.x
|
||||||
|
and old_metadata_area.win_y == job.area.y
|
||||||
|
and old_metadata_area.win_w == job.area.w
|
||||||
|
and old_metadata_area.win_h == job.area.h
|
||||||
|
then
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Clear(ui.Rect({
|
||||||
|
x = old_metadata_area.x,
|
||||||
|
y = old_metadata_area.y,
|
||||||
|
w = old_metadata_area.w,
|
||||||
|
h = old_metadata_area.h,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
utils.force_render()
|
||||||
|
local rendered_img_rect = cache_img_url
|
||||||
|
and fs.cha(cache_img_url)
|
||||||
|
and ya.image_show(
|
||||||
|
cache_img_url,
|
||||||
|
ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y,
|
||||||
|
w = job.area.w,
|
||||||
|
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
or nil
|
||||||
|
local image_height = rendered_img_rect and rendered_img_rect.h or 0
|
||||||
|
|
||||||
|
-- NOTE: Workaround case video.lua doesn't doesn't generate preview image because of `skip` overflow video duration
|
||||||
|
if not rendered_img_rect then
|
||||||
|
local prev_image_height = utils.get_state(const.STATE_KEY.prev_image_height)
|
||||||
|
image_height = prev_image_height and prev_image_height[tostring(cache_img_url_no_skip)] or 0
|
||||||
|
else
|
||||||
|
utils.set_state(const.STATE_KEY.prev_image_height, { [tostring(cache_img_url_no_skip)] = image_height })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Handle image preload error
|
||||||
|
if preload_err then
|
||||||
|
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
|
||||||
|
end
|
||||||
|
|
||||||
|
ya.preview_widget(job, {
|
||||||
|
ui.Text(lines)
|
||||||
|
:area(ui.Rect({
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
}))
|
||||||
|
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- NOTE: Hacky way to prevent image overlap with old metadata area
|
||||||
|
utils.set_state(const.STATE_KEY.prev_metadata_area, not no_metadata and {
|
||||||
|
x = job.area.x,
|
||||||
|
y = job.area.y + image_height,
|
||||||
|
w = job.area.w,
|
||||||
|
h = job.area.h - image_height,
|
||||||
|
win_x = job.area.x,
|
||||||
|
win_y = job.area.y,
|
||||||
|
win_w = job.area.w,
|
||||||
|
win_h = job.area.h,
|
||||||
|
} or nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:preload(job)
|
||||||
|
local cmd = "mediainfo"
|
||||||
|
local err_msg = ""
|
||||||
|
|
||||||
|
-- NOTE: Preload image from video
|
||||||
|
|
||||||
|
local cache_img_status, video_preload_err = require("video"):preload({
|
||||||
|
skip = job.skip > 90 and 90 or job.skip,
|
||||||
|
args = job.args,
|
||||||
|
file = job.file,
|
||||||
|
area = job.area,
|
||||||
|
})
|
||||||
|
|
||||||
|
if not cache_img_status and video_preload_err then
|
||||||
|
ya.dbg("mediainfo", video_preload_err)
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`.\n Do you have `%s` installed?\n", "ffmpeg", "ffmpeg")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- NOTE: Get mediainfo and save to cache folder
|
||||||
|
local cache_mediainfo_url = Url(tostring(ya.file_cache({ file = job.file, skip = 0 })) .. const.suffix)
|
||||||
|
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
|
||||||
|
-- Case peek function called preload to refetch mediainfo
|
||||||
|
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
|
||||||
|
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local output, err
|
||||||
|
local is_valid_utf8_path = utils.is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
|
||||||
|
if is_valid_utf8_path then
|
||||||
|
output, err = Command(cmd)
|
||||||
|
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
|
||||||
|
:output()
|
||||||
|
else
|
||||||
|
cmd = "cd "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url.path or job.file.url).parent))
|
||||||
|
.. " && "
|
||||||
|
.. cmd
|
||||||
|
.. " "
|
||||||
|
.. utils.path_quote(tostring((job.file.path or job.file.cache or job.file.url).name))
|
||||||
|
output, err = Command(const.SHELL):arg({ "-c", cmd }):output()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
ya.dbg("mediainfo", tostring(err))
|
||||||
|
err_msg = err_msg .. string.format("Failed to start `%s`. \n Do you have `%s` installed?\n", cmd, cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
return fs.write(
|
||||||
|
cache_mediainfo_url,
|
||||||
|
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
--- @sync entry
|
||||||
|
local function entry(_, job)
|
||||||
|
local parent = cx.active.parent
|
||||||
|
if not parent then return end
|
||||||
|
|
||||||
|
local target = parent.files[parent.cursor + 1 + job.args[1]]
|
||||||
|
if target and target.cha.is_dir then
|
||||||
|
ya.emit("cd", { target.url })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return { entry = entry }
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published
|
||||||
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# restore.yazi
|
||||||
|
|
||||||
|
<!--toc:start-->
|
||||||
|
|
||||||
|
- [restore.yazi](#restoreyazi)
|
||||||
|
- [Requirements](#requirements)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Linux](#linux)
|
||||||
|
- [Usage](#usage)
|
||||||
|
<!--toc:end-->
|
||||||
|
|
||||||
|
[Yazi](https://github.com/sxyazi/yazi) plugin to restore/recover latest deleted files/folders.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [yazi >= v25.5.31](https://github.com/sxyazi/yazi)
|
||||||
|
- [trash-cli](https://github.com/andreafrancia/trash-cli)
|
||||||
|
- If you have `Can't Get Trash Directory` error and running `trash-list --volumes`
|
||||||
|
in terminal throw `AttributeError: 'PrintVolumesList' object has no attribute 'run_action'`.
|
||||||
|
Remove the old version of trash-cli and install newer version [How to install](https://github.com/andreafrancia/trash-cli?tab=readme-ov-file#the-easy-way).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ya pkg add boydaihungst/restore
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> This plugin restores files and folders based on their deletion date and time.
|
||||||
|
> However, since Yazi deletes files in batches of approximately 1000\~2000, not all files in a large selection will have the same deletion timestamp.
|
||||||
|
> For example, if you select and delete 10,000 files, each batch of 1000\~2000 may have a different deletion time. This can result in only a partial restoration of your files (in the worst case, only the last 1000\~2000 files deleted).
|
||||||
|
> To resolve this, you may need to run the "restore" command multiple times until all desired files are recovered. For instance, to restore 10,000 files, you might have to execute the command up to 10 times.
|
||||||
|
>
|
||||||
|
> - Won't work with remote servers in vfs.toml. Since it doesn't support trash: https://yazi-rs.github.io/docs/next/configuration/vfs
|
||||||
|
> - Other types of mount methods should work, but I haven't tested them.
|
||||||
|
|
||||||
|
1. Key binding
|
||||||
|
- Add this to your `keymap.toml`. Make it doesn't override other keymaps.
|
||||||
|
[Read more about keymap](https://yazi-rs.github.io/docs/configuration/keymap):
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[mgr]
|
||||||
|
prepend_keymap = [
|
||||||
|
{ on = "u", run = "plugin restore", desc = "Restore last deleted files/folders" },
|
||||||
|
# or use "d + u" like me
|
||||||
|
{ on = ["d", "u"], run = "plugin restore", desc = "Restore last deleted files/folders" },
|
||||||
|
|
||||||
|
# Select files/folders to restore. Input item index or range separated by comma:
|
||||||
|
# - Restore a trashed file:
|
||||||
|
# What file to restore [0..4]: 4
|
||||||
|
# - Restore multiple trashed files separated by comma, also support range:
|
||||||
|
# What file to restore [0..3]: 0-2, 3
|
||||||
|
|
||||||
|
# This will throw error when there is existed file/folder
|
||||||
|
{ on = [ "d", "U" ], run = "plugin restore -- --interactive", desc = "Restore deleted files/folders (Interactive)" },
|
||||||
|
# Or auto overwrite existed file/folder
|
||||||
|
{ on = [ "d", "U" ], run = "plugin restore -- --interactive --interactive-overwrite", desc = "Restore deleted files/folders (Interactive overwrite)" },
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Configuration (Optional)
|
||||||
|
- Default:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require("restore"):setup({
|
||||||
|
-- Set the position for confirm and overwrite prompts.
|
||||||
|
-- Don't forget to set height: `h = xx`
|
||||||
|
-- https://yazi-rs.github.io/docs/plugins/utils/#ya.input
|
||||||
|
position = { "center", w = 70, h = 40 }, -- Optional
|
||||||
|
|
||||||
|
-- Show confirm prompt before restore.
|
||||||
|
-- NOTE: even if set this to false, overwrite prompt still pop up
|
||||||
|
show_confirm = true, -- Optional
|
||||||
|
|
||||||
|
-- Suppress success notification when all files or folder are restored.
|
||||||
|
suppress_success_notification = true, -- Optional
|
||||||
|
|
||||||
|
-- colors for confirm and overwrite prompts
|
||||||
|
theme = { -- Optional
|
||||||
|
-- Default using style from your flavor or theme.lua -> [confirm] -> title.
|
||||||
|
-- If you edit flavor or theme.lua you can add more style than just color.
|
||||||
|
-- Example in theme.lua -> [confirm]: title = { fg = "blue", bg = "green" }
|
||||||
|
title = "blue", -- Optional. This value has higher priority than flavor/theme.lua
|
||||||
|
|
||||||
|
-- Default using style from your flavor or theme.lua -> [confirm] -> content
|
||||||
|
-- Sample logic as title above
|
||||||
|
header = "green", -- Optional. This value has higher priority than flavor/theme.lua
|
||||||
|
|
||||||
|
-- header color for overwrite prompt
|
||||||
|
-- Default using color "yellow"
|
||||||
|
header_warning = "yellow", -- Optional
|
||||||
|
-- Default using style from your flavor or theme.lua -> [confirm] -> list
|
||||||
|
-- Sample logic as title and header above
|
||||||
|
list_item = { odd = "blue", even = "blue" }, -- Optional. This value has higher priority than flavor/theme.lua
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
@@ -0,0 +1,375 @@
|
|||||||
|
--- @since 25.5.31
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local shell = os.getenv("SHELL") or ""
|
||||||
|
local PackageName = "Restore"
|
||||||
|
|
||||||
|
---@class TrashItem
|
||||||
|
---@field trash_index number
|
||||||
|
---@field trashed_date_time string
|
||||||
|
---@field trashed_path string
|
||||||
|
---@field type File_Type
|
||||||
|
|
||||||
|
---@class Theme
|
||||||
|
---@field title? any
|
||||||
|
---@field header? any
|
||||||
|
---@field header_warning? any
|
||||||
|
---@field list_item? {odd?: any, even?: any}
|
||||||
|
|
||||||
|
---@class SetupOptions
|
||||||
|
---@field position? AsPos
|
||||||
|
---@field show_confirm? boolean
|
||||||
|
---@field theme? Theme
|
||||||
|
---@field suppress_success_notification? boolean
|
||||||
|
|
||||||
|
local function success(s, ...)
|
||||||
|
ya.notify({ title = PackageName, content = string.format(s, ...), timeout = 5, level = "info" })
|
||||||
|
end
|
||||||
|
|
||||||
|
local function error(s, ...)
|
||||||
|
ya.notify({ title = PackageName, content = string.format(s, ...), timeout = 5, level = "error" })
|
||||||
|
end
|
||||||
|
|
||||||
|
local set_state = ya.sync(function(state, key, value)
|
||||||
|
if not state then
|
||||||
|
state = {}
|
||||||
|
end
|
||||||
|
state[key] = value
|
||||||
|
end)
|
||||||
|
|
||||||
|
local get_state = ya.sync(function(state, key)
|
||||||
|
return state and state[key]
|
||||||
|
end)
|
||||||
|
|
||||||
|
---@enum STATE
|
||||||
|
local STATE = {
|
||||||
|
POSITION = "position",
|
||||||
|
SHOW_CONFIRM = "show_confirm",
|
||||||
|
SUPPRESS_SUCCESS_NOTIFICATION = "suppress_success_notification",
|
||||||
|
THEME = "theme",
|
||||||
|
INITIALIZED = "initialized",
|
||||||
|
}
|
||||||
|
|
||||||
|
---@enum File_Type
|
||||||
|
local File_Type = {
|
||||||
|
File = "file",
|
||||||
|
Dir = "dir_all",
|
||||||
|
None_Exist = "unknown",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Get current working directory
|
||||||
|
---@return string
|
||||||
|
local get_cwd_raw = ya.sync(function()
|
||||||
|
return tostring(cx.active.current.cwd.path or cx.active.current.cwd)
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Quote path for shell command
|
||||||
|
---@param path string Absolute path
|
||||||
|
---@return string
|
||||||
|
local function path_quote(path)
|
||||||
|
local result = "'" .. string.gsub(path, "'", "'\\''") .. "'"
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check path is file or directory or none exist.
|
||||||
|
---@param path string Absolute path
|
||||||
|
---@return File_Type
|
||||||
|
local function get_file_type(path)
|
||||||
|
local cha, _ = fs.cha(Url(path), true)
|
||||||
|
if cha then
|
||||||
|
return cha.is_dir and File_Type.Dir or File_Type.File
|
||||||
|
end
|
||||||
|
return File_Type.None_Exist
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get trash volume of current working directory.
|
||||||
|
---@return string|nil
|
||||||
|
local function get_trash_volume()
|
||||||
|
local cwd_raw = get_cwd_raw()
|
||||||
|
local trash_volumes_stream, cmr_err =
|
||||||
|
Command("trash-list"):arg({ "--volumes" }):stdout(Command.PIPED):stderr(Command.PIPED):output()
|
||||||
|
|
||||||
|
---@type string|nil
|
||||||
|
local best_matched_vol_path
|
||||||
|
if trash_volumes_stream then
|
||||||
|
local previous_matched_vol_length = 0
|
||||||
|
for vol in trash_volumes_stream.stdout:gmatch("[^\r\n]+") do
|
||||||
|
local vol_length = utf8.len(vol) or 1
|
||||||
|
if cwd_raw:sub(1, vol_length) == vol and vol_length > previous_matched_vol_length then
|
||||||
|
-- NOTE: Don't break here, because we need to get the best match volume
|
||||||
|
best_matched_vol_path = vol
|
||||||
|
previous_matched_vol_length = vol_length
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not best_matched_vol_path then
|
||||||
|
error("Can't get trash directory")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error("Failed to start `trash-list` with error: `%s`. Do you have `trash-cli` installed?", cmr_err)
|
||||||
|
end
|
||||||
|
return best_matched_vol_path
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get list of files/folders trashed in reversed order
|
||||||
|
---@param curr_working_volume string current working volume
|
||||||
|
local function get_latest_trashed_items(curr_working_volume)
|
||||||
|
---@type TrashItem[], TrashItem[]
|
||||||
|
local reversed_restorable_items, reversed_existed_items = {}, {}
|
||||||
|
|
||||||
|
-- NOTE: use `tac` to reverse the list. So that we can pop items from the end faster
|
||||||
|
local reversed_trashed_list_stream, err_cmd = Command(shell)
|
||||||
|
:arg({ "-c", "printf '\n' | trash-restore " .. path_quote(curr_working_volume) .. " | tac" })
|
||||||
|
:stdout(Command.PIPED)
|
||||||
|
:stderr(Command.PIPED)
|
||||||
|
:spawn()
|
||||||
|
|
||||||
|
if reversed_trashed_list_stream then
|
||||||
|
local last_item_datetime = nil
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local line, event = reversed_trashed_list_stream:read_line()
|
||||||
|
if event ~= 0 then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
-- remove leading spaces
|
||||||
|
local trash_index, item_date, item_path = line:match("^%s*(%d+) (%S+ %S+) ([^\n]+)")
|
||||||
|
if item_date and item_path and trash_index ~= nil then
|
||||||
|
if last_item_datetime and last_item_datetime ~= item_date then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local trash_item_type = get_file_type(item_path)
|
||||||
|
local trash_item = {
|
||||||
|
trash_index = tonumber(trash_index),
|
||||||
|
trashed_date_time = item_date,
|
||||||
|
trashed_path = item_path,
|
||||||
|
type = trash_item_type,
|
||||||
|
}
|
||||||
|
table.insert(reversed_restorable_items, trash_item)
|
||||||
|
if trash_item_type ~= File_Type.None_Exist then
|
||||||
|
table.insert(reversed_existed_items, trash_item)
|
||||||
|
end
|
||||||
|
last_item_datetime = item_date
|
||||||
|
end
|
||||||
|
end
|
||||||
|
reversed_trashed_list_stream:start_kill()
|
||||||
|
|
||||||
|
if #reversed_restorable_items == 0 then
|
||||||
|
success("Nothing left to restore")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error("Failed to start `trash-restore` with error: `%s`. Do you have `trash-cli` installed?", err_cmd)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return reversed_restorable_items, reversed_existed_items
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Restore files/folders from trash list based on trash item start and end index
|
||||||
|
---@param curr_working_volume string current working volume
|
||||||
|
---@param start_index integer trash item start index
|
||||||
|
---@param end_index integer trash item end index
|
||||||
|
local function restore_files(curr_working_volume, start_index, end_index)
|
||||||
|
if type(start_index) ~= "number" or type(end_index) ~= "number" or start_index < 0 or end_index < 0 then
|
||||||
|
error("Failed to restore file(s): out of range")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local restored_status, _ = Command(shell)
|
||||||
|
:arg({
|
||||||
|
"-c",
|
||||||
|
"echo " .. ya.quote(start_index .. "-" .. end_index) .. " | trash-restore --overwrite " .. path_quote(
|
||||||
|
curr_working_volume
|
||||||
|
),
|
||||||
|
})
|
||||||
|
:stdout(Command.PIPED)
|
||||||
|
:stderr(Command.PIPED)
|
||||||
|
:output()
|
||||||
|
|
||||||
|
local file_to_restore_count = end_index - start_index + 1
|
||||||
|
if restored_status then
|
||||||
|
if not get_state(STATE.SUPPRESS_SUCCESS_NOTIFICATION) then
|
||||||
|
success(
|
||||||
|
"Restored " .. tostring(file_to_restore_count) .. " file" .. (file_to_restore_count > 1 and "s" or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error(
|
||||||
|
"Failed to restore "
|
||||||
|
.. tostring(file_to_restore_count)
|
||||||
|
.. " file"
|
||||||
|
.. (file_to_restore_count > 1 and "s" or "")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Convert trash list to UI component list
|
||||||
|
---@param reversed_trash_list TrashItem[]
|
||||||
|
---@return ui.List[]
|
||||||
|
local function get_components(reversed_trash_list)
|
||||||
|
---@type Theme
|
||||||
|
local theme = get_state(STATE.THEME)
|
||||||
|
local item_odd_style = theme.list_item and theme.list_item.odd and ui.Style():fg(theme.list_item.odd)
|
||||||
|
or th.confirm.list
|
||||||
|
local item_even_style = theme.list_item and theme.list_item.even and ui.Style():fg(theme.list_item.even)
|
||||||
|
or th.confirm.list
|
||||||
|
|
||||||
|
local trashed_items_components = {}
|
||||||
|
local display_index = 1
|
||||||
|
|
||||||
|
for idx = #reversed_trash_list, 1, -1 do
|
||||||
|
local item = reversed_trash_list[idx]
|
||||||
|
table.insert(
|
||||||
|
trashed_items_components,
|
||||||
|
ui.Line({
|
||||||
|
ui.Span(" "),
|
||||||
|
ui.Span(item.trashed_path):style((display_index % 2 == 1) and item_odd_style or item_even_style),
|
||||||
|
}):align(ui.Align.LEFT)
|
||||||
|
)
|
||||||
|
display_index = display_index + 1
|
||||||
|
end
|
||||||
|
return trashed_items_components
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Setup plugin, add it to yazi/init.lua file
|
||||||
|
---@param opts? SetupOptions
|
||||||
|
function M:setup(opts)
|
||||||
|
if opts and type(opts) ~= "table" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
set_state(
|
||||||
|
STATE.POSITION,
|
||||||
|
(opts and type(opts.position) == "table") and opts.position or { "center", w = 70, h = 40 }
|
||||||
|
)
|
||||||
|
set_state(STATE.SHOW_CONFIRM, opts == nil or opts.show_confirm ~= false)
|
||||||
|
set_state(STATE.THEME, (opts and type(opts.theme) == "table") and opts.theme or {})
|
||||||
|
set_state(STATE.SUPPRESS_SUCCESS_NOTIFICATION, opts and opts.suppress_success_notification)
|
||||||
|
set_state(STATE.INITIALIZED, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:entry(job)
|
||||||
|
if not get_state(STATE.INITIALIZED) then
|
||||||
|
M:setup()
|
||||||
|
end
|
||||||
|
local curr_working_volume = get_trash_volume()
|
||||||
|
if not curr_working_volume then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local interactive_mode = job.args.interactive
|
||||||
|
local interactive_overwrite = job.args.interactive_overwrite
|
||||||
|
if interactive_mode == true then
|
||||||
|
ya.emit("shell", {
|
||||||
|
"clear && trash-restore " .. (interactive_overwrite and "--overwrite" or "") .. " " .. path_quote(
|
||||||
|
curr_working_volume
|
||||||
|
),
|
||||||
|
block = true,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
--NOTE: No need to reverse the list here, waste of time and memory
|
||||||
|
local reversed_trashed_items, reversed_collided_items = get_latest_trashed_items(curr_working_volume)
|
||||||
|
if reversed_trashed_items == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local overwrite_confirmed = true
|
||||||
|
local show_confirm = get_state(STATE.SHOW_CONFIRM)
|
||||||
|
local pos = get_state(STATE.POSITION)
|
||||||
|
|
||||||
|
---@type Theme
|
||||||
|
local theme = get_state(STATE.THEME)
|
||||||
|
theme.title = theme.title and ui.Style():fg(theme.title):bold() or th.confirm.title
|
||||||
|
theme.header = theme.header and ui.Style():fg(theme.header) or th.confirm.body or th.confirm.content
|
||||||
|
theme.header_warning = ui.Style():fg(theme.header_warning or "yellow")
|
||||||
|
if show_confirm then
|
||||||
|
local continue_restore = ya.confirm({
|
||||||
|
title = ui.Line("Restore files/folders"):style(theme.title),
|
||||||
|
body = ui.Text({
|
||||||
|
ui.Line(""),
|
||||||
|
ui.Line(
|
||||||
|
#reversed_trashed_items
|
||||||
|
.. " file"
|
||||||
|
.. (#reversed_trashed_items <= 1 and " " or "s ")
|
||||||
|
.. "and folder"
|
||||||
|
.. (#reversed_trashed_items <= 1 and " " or "s ")
|
||||||
|
.. (#reversed_trashed_items <= 1 and "is " or "are ")
|
||||||
|
.. "going to be restored:"
|
||||||
|
):style(theme.header),
|
||||||
|
ui.Line(""),
|
||||||
|
table.unpack(get_components(reversed_trashed_items)),
|
||||||
|
})
|
||||||
|
:align(ui.Align.LEFT)
|
||||||
|
:wrap(ui.Wrap.YES),
|
||||||
|
-- TODO: remove this after next yazi released
|
||||||
|
content = ui.Text({
|
||||||
|
ui.Line(""),
|
||||||
|
ui.Line(
|
||||||
|
#reversed_trashed_items
|
||||||
|
.. " file"
|
||||||
|
.. (#reversed_trashed_items <= 1 and " " or "s ")
|
||||||
|
.. "and folder"
|
||||||
|
.. (#reversed_trashed_items <= 1 and " " or "s ")
|
||||||
|
.. (#reversed_trashed_items <= 1 and "is " or "are ")
|
||||||
|
.. "going to be restored:"
|
||||||
|
):style(theme.header),
|
||||||
|
ui.Line(""),
|
||||||
|
table.unpack(get_components(reversed_trashed_items)),
|
||||||
|
})
|
||||||
|
:align(ui.Align.LEFT)
|
||||||
|
:wrap(ui.Wrap.YES),
|
||||||
|
pos = pos,
|
||||||
|
})
|
||||||
|
-- stopping
|
||||||
|
if not continue_restore then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- show Confirm dialog with list of collided items
|
||||||
|
if reversed_collided_items and #reversed_collided_items > 0 then
|
||||||
|
overwrite_confirmed = ya.confirm({
|
||||||
|
title = ui.Line("Restore files/folders"):style(theme.title),
|
||||||
|
body = ui.Text({
|
||||||
|
ui.Line(""),
|
||||||
|
ui.Line(
|
||||||
|
#reversed_collided_items
|
||||||
|
.. " file"
|
||||||
|
.. (#reversed_collided_items <= 1 and " " or "s ")
|
||||||
|
.. "and folder"
|
||||||
|
.. (#reversed_collided_items <= 1 and " " or "s ")
|
||||||
|
.. (#reversed_collided_items <= 1 and "is " or "are ")
|
||||||
|
.. "existed, overwrite?"
|
||||||
|
):style(theme.header_warning),
|
||||||
|
ui.Line(""),
|
||||||
|
table.unpack(get_components(reversed_collided_items)),
|
||||||
|
})
|
||||||
|
:align(ui.Align.LEFT)
|
||||||
|
:wrap(ui.Wrap.YES),
|
||||||
|
-- TODO: remove this after next yazi released
|
||||||
|
content = ui.Text({
|
||||||
|
ui.Line(""),
|
||||||
|
ui.Line(
|
||||||
|
#reversed_collided_items
|
||||||
|
.. " file"
|
||||||
|
.. (#reversed_collided_items <= 1 and " " or "s ")
|
||||||
|
.. "and folder"
|
||||||
|
.. (#reversed_collided_items <= 1 and " " or "s ")
|
||||||
|
.. (#reversed_collided_items <= 1 and "is " or "are ")
|
||||||
|
.. "existed, overwrite?"
|
||||||
|
):style(theme.header_warning),
|
||||||
|
ui.Line(""),
|
||||||
|
table.unpack(get_components(reversed_collided_items)),
|
||||||
|
})
|
||||||
|
:align(ui.Align.LEFT)
|
||||||
|
:wrap(ui.Wrap.YES),
|
||||||
|
pos = pos,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
if overwrite_confirmed then
|
||||||
|
restore_files(
|
||||||
|
curr_working_volume,
|
||||||
|
reversed_trashed_items[#reversed_trashed_items].trash_index,
|
||||||
|
reversed_trashed_items[1].trash_index
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Konstantin Tskhovrebov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# split-tabs.yazi
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="media/screenshot.png" width="70%"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
A [Yazi](https://github.com/sxyazi/yazi) plugin that provides a dual-pane view by splitting the screen between two tabs.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Toggle dual-pane mode
|
||||||
|
- Switch focus between panes
|
||||||
|
- Toggle a full-width preview panel at the bottom
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
```sh
|
||||||
|
ya pkg add terrakok/split-tabs
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```sh
|
||||||
|
# Windows
|
||||||
|
git clone https://github.com/terrakok/split-tabs.yazi %AppData%\yazi\config\plugins\split-tabs.yazi
|
||||||
|
# Linux/macOS
|
||||||
|
git clone https://github.com/terrakok/split-tabs.yazi ~/.config/yazi/plugins/split-tabs.yazi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
Add this to your `keymap.toml`:
|
||||||
|
```
|
||||||
|
[mgr]
|
||||||
|
prepend_keymap = [
|
||||||
|
{ on = "\\", run = "plugin split-tabs spl_toggle", desc = "Split-tabs: toggle split tabs mode" },
|
||||||
|
{ on = "<Tab>", run = "plugin split-tabs spl_switch_tab", desc = "Split-tabs: switch to the other pane" },
|
||||||
|
{ on = "P", run = "plugin split-tabs spl_preview", desc = "Split-tabs: toggle preview pane" },
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support the Developer
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.buymeacoffee.com/terrakok" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-green.png" alt="Buy Me A Coffee" width="200"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
If you enjoy the project and want to support its development, consider buying me a coffee. Your support helps keep this project free and open-source!
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
--- @since 26.5.6
|
||||||
|
--- @sync entry
|
||||||
|
|
||||||
|
-- nil when inactive; holds all dual-pane state when active.
|
||||||
|
local dp = nil
|
||||||
|
local saved = {}
|
||||||
|
|
||||||
|
local function active_pane()
|
||||||
|
return cx.tabs.idx == dp.tabs[2] and 2 or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function other_pane()
|
||||||
|
return active_pane() == 1 and 2 or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Minimal component: renders static elements. Needs _id/_area for ui.redraw().
|
||||||
|
local Overlay = {}
|
||||||
|
function Overlay:new(id, area, elements)
|
||||||
|
return setmetatable({ _id = id, _area = area, _elements = elements or {} }, { __index = self })
|
||||||
|
end
|
||||||
|
|
||||||
|
function Overlay:reflow() return {} end
|
||||||
|
|
||||||
|
function Overlay:redraw() return self._elements end
|
||||||
|
|
||||||
|
-- Polyfill: Marker lacks reflow(), which crashes Tab:reflow() on resize.
|
||||||
|
if not Marker.reflow then
|
||||||
|
Marker.reflow = function() return {} end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wraps a Current to suppress cursor highlight via dp._no_cursor flag.
|
||||||
|
local Pane = {}
|
||||||
|
function Pane:new(area, tab, active)
|
||||||
|
return setmetatable(
|
||||||
|
{ _id = active and "current" or "my-current", _area = area, _active = active, _inner = Current:new(area, tab) },
|
||||||
|
{ __index = self }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Pane:reflow() return self._inner:reflow() end
|
||||||
|
|
||||||
|
function Pane:redraw()
|
||||||
|
dp._no_cursor = not self._active
|
||||||
|
local elements = self._inner:redraw()
|
||||||
|
dp._no_cursor = nil
|
||||||
|
return elements
|
||||||
|
end
|
||||||
|
|
||||||
|
local function apply_dual_tab_patch()
|
||||||
|
Tab.layout = function(self)
|
||||||
|
if #cx.tabs < 2 and not dp.creating then
|
||||||
|
dp.creating = true
|
||||||
|
ya.emit("tab_create", { cx.active.current.cwd })
|
||||||
|
dp.tabs = { 1, 2 }
|
||||||
|
elseif #cx.tabs >= 2 then
|
||||||
|
dp.creating = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if #cx.tabs > 2 then
|
||||||
|
for i = #cx.tabs, 1, -1 do
|
||||||
|
if i ~= dp.tabs[1] and i ~= dp.tabs[2] then
|
||||||
|
ya.emit("tab_close", { i - 1 }) -- 0-based
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
dp.pane = active_pane()
|
||||||
|
|
||||||
|
-- Preview on: split vertically first, then horizontally for panes.
|
||||||
|
local pane_area = self._area
|
||||||
|
if dp.preview then
|
||||||
|
local vsplit = ui.Layout()
|
||||||
|
:direction(ui.Layout.VERTICAL)
|
||||||
|
:constraints({
|
||||||
|
ui.Constraint.Fill(1),
|
||||||
|
ui.Constraint.Fill(1),
|
||||||
|
})
|
||||||
|
:split(self._area)
|
||||||
|
pane_area = vsplit[1]
|
||||||
|
dp.preview_area = vsplit[2]
|
||||||
|
else
|
||||||
|
dp.preview_area = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Active pane uses the "current" slot; inactive gets a zero-width slot.
|
||||||
|
self._chunks = ui.Layout()
|
||||||
|
:direction(ui.Layout.HORIZONTAL)
|
||||||
|
:constraints({
|
||||||
|
ui.Constraint.Fill(1),
|
||||||
|
ui.Constraint.Fill(1),
|
||||||
|
ui.Constraint.Length(0),
|
||||||
|
})
|
||||||
|
:split(pane_area)
|
||||||
|
end
|
||||||
|
|
||||||
|
Tab.build = function(self, ...)
|
||||||
|
saved.tab_build(self, ...)
|
||||||
|
|
||||||
|
local c = self._chunks
|
||||||
|
local tab1 = cx.tabs[dp.tabs[1]]
|
||||||
|
local tab2 = cx.tabs[dp.tabs[2]]
|
||||||
|
|
||||||
|
if not tab1 or not tab2 then
|
||||||
|
self._children = {}
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self._children = {
|
||||||
|
Pane:new(c[1]:pad(ui.Pad(0, 0, 0, 1)), tab1, dp.pane == 1),
|
||||||
|
Pane:new(c[2]:pad(ui.Pad.x(1)), tab2, dp.pane == 2),
|
||||||
|
|
||||||
|
Marker:new(c[1], tab1.current),
|
||||||
|
|
||||||
|
Rails:new(c, self._tab), -- draw a rail between "parent" and "current" panels
|
||||||
|
Marker:new(c[2], tab2.current),
|
||||||
|
}
|
||||||
|
|
||||||
|
if dp.preview and dp.preview_area then
|
||||||
|
-- Overlap preview 1 row up to share the pane's bottom border line.
|
||||||
|
local pa = dp.preview_area
|
||||||
|
local joined = ui.Rect { x = pa.x, y = pa.y - 1, w = pa.w, h = pa.h + 1 }
|
||||||
|
self._children[#self._children + 1] = Overlay:new("border", joined, {
|
||||||
|
ui.Border(ui.Edge.ALL):area(joined),
|
||||||
|
})
|
||||||
|
self._children[#self._children + 1] = Preview:new(joined:pad(ui.Pad(1, 1, 1, 1)), self._tab)
|
||||||
|
else
|
||||||
|
-- Zero-width "preview" rect prevents stale Rust-side preview rendering.
|
||||||
|
-- Height stays non-zero so Folder::make window size isn't clamped to 0.
|
||||||
|
self._children[#self._children + 1] = Overlay:new("preview",
|
||||||
|
ui.Rect { x = 0, y = 0, w = 0, h = self._area.h }, {})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function apply_header_patch()
|
||||||
|
Header.cwd = function(self)
|
||||||
|
local w = self._area.w
|
||||||
|
local mid = math.floor(w / 2) - 1
|
||||||
|
|
||||||
|
local tab1 = cx.tabs[dp.tabs[1]]
|
||||||
|
local tab2 = dp.tabs[2] and cx.tabs[dp.tabs[2]]
|
||||||
|
local pane = dp.pane or 1
|
||||||
|
|
||||||
|
if not tab1 then return "" end
|
||||||
|
|
||||||
|
if not tab2 then
|
||||||
|
local s = ya.readable_path(tostring(tab1.current.cwd))
|
||||||
|
return ui.Span(ui.truncate(s, { max = w, rtl = true })):style(th.tabs.active)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Left path: pad to exactly `mid` columns so the separator aligns with the pane split.
|
||||||
|
local p1 = ya.readable_path(tostring(tab1.current.cwd))
|
||||||
|
p1 = ui.truncate(p1, { max = mid, rtl = true })
|
||||||
|
local pad = mid - #p1
|
||||||
|
if pad > 0 then
|
||||||
|
p1 = p1 .. string.rep(" ", pad)
|
||||||
|
end
|
||||||
|
|
||||||
|
local right_avail = math.max(0, w - mid - 1 - (self._right_width or 0)) - 4
|
||||||
|
local p2 = ya.readable_path(tostring(tab2.current.cwd))
|
||||||
|
p2 = ui.truncate(p2, { max = right_avail, rtl = true })
|
||||||
|
|
||||||
|
local s_active = th.tabs.active:patch(ui.Style():bg("reset"))
|
||||||
|
local s_inactive = th.tabs.inactive:patch(ui.Style():bg("reset"))
|
||||||
|
|
||||||
|
return ui.Line {
|
||||||
|
ui.Span(p1):style(pane == 1 and s_active or s_inactive),
|
||||||
|
ui.Span(" "),
|
||||||
|
ui.Span(p2):style(pane == 2 and s_active or s_inactive),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restore_all()
|
||||||
|
Tab.layout = saved.tab_layout
|
||||||
|
Tab.build = saved.tab_build
|
||||||
|
Header.cwd = saved.header_cwd
|
||||||
|
Tabs.height = saved.tabs_height
|
||||||
|
Entity.style = saved.entity_style
|
||||||
|
end
|
||||||
|
|
||||||
|
local function activate()
|
||||||
|
if dp then return end
|
||||||
|
|
||||||
|
saved.tab_layout = Tab.layout
|
||||||
|
saved.tab_build = Tab.build
|
||||||
|
saved.header_cwd = Header.cwd
|
||||||
|
saved.tabs_height = Tabs.height
|
||||||
|
saved.entity_style = Entity.style
|
||||||
|
|
||||||
|
Entity.style = function(self)
|
||||||
|
if dp and dp._no_cursor then
|
||||||
|
return self._file:style() or ui.Style()
|
||||||
|
end
|
||||||
|
return saved.entity_style(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
Tabs.height = function() return 0 end
|
||||||
|
|
||||||
|
local n = #cx.tabs
|
||||||
|
local cur = cx.tabs.idx
|
||||||
|
local tab2_idx
|
||||||
|
|
||||||
|
if n >= 2 then
|
||||||
|
tab2_idx = (cur < n) and (cur + 1) or 1
|
||||||
|
else
|
||||||
|
tab2_idx = 2
|
||||||
|
ya.emit("tab_create", { cx.active.current.cwd })
|
||||||
|
end
|
||||||
|
|
||||||
|
dp = { pane = 1, view = "dual", tabs = { cur, tab2_idx }, creating = n < 2, preview = false }
|
||||||
|
|
||||||
|
apply_dual_tab_patch()
|
||||||
|
apply_header_patch()
|
||||||
|
ui.render()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function deactivate()
|
||||||
|
if not dp then return end
|
||||||
|
ya.emit("tab_close", { other_pane() - 1 })
|
||||||
|
restore_all()
|
||||||
|
dp = nil
|
||||||
|
saved = {}
|
||||||
|
ui.render()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function spl_toggle()
|
||||||
|
if dp then deactivate() else activate() end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function spl_preview()
|
||||||
|
if not dp then return end
|
||||||
|
dp.preview = not dp.preview
|
||||||
|
ui.render()
|
||||||
|
if dp.preview then
|
||||||
|
ya.emit("peek", { 0 })
|
||||||
|
else
|
||||||
|
-- Different skip value forces preview.reset() which clears protocol images.
|
||||||
|
ya.emit("peek", { 99999 })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function spl_switch_tab()
|
||||||
|
if not dp then return end
|
||||||
|
ya.emit("tab_switch", { dp.tabs[other_pane()] - 1 })
|
||||||
|
ui.render()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function entry(st, job)
|
||||||
|
job = type(job) == "string" and { args = { job } } or job
|
||||||
|
local act = job.args[1]
|
||||||
|
|
||||||
|
if act == "spl_toggle" then
|
||||||
|
spl_toggle()
|
||||||
|
elseif act == "spl_switch_tab" then
|
||||||
|
spl_switch_tab()
|
||||||
|
elseif act == "spl_preview" then
|
||||||
|
spl_preview()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return { entry = entry }
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[flavor]
|
||||||
|
dark = "kanagawa"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
[open]
|
||||||
|
prepend_rules = [
|
||||||
|
{ url = "*.html", use = [ "edit", "open" ] },
|
||||||
|
]
|
||||||
|
|
||||||
|
[plugin]
|
||||||
|
prepend_preloaders = [
|
||||||
|
{ mime = "{audio,video,image}/*", run = "mediainfo" },
|
||||||
|
{ mime = "application/subrip", run = "mediainfo" },
|
||||||
|
]
|
||||||
|
|
||||||
|
prepend_previewers = [
|
||||||
|
{ mime = "{audio,video,image}/*", run = "mediainfo" },
|
||||||
|
{ mime = "application/subrip", run = "mediainfo" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[preview]
|
||||||
|
max_width = 2000
|
||||||
|
max_height = 2000
|
||||||
|
image_filter = "lanczos3"
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
export PATH="/usr/local/bin:$HOME/bin:$HOME/.local/bin:$HOME/.local/go/bin:$HOME/.dotnet/tools:$HOME/.cargo/bin:$PATH"
|
||||||
|
export ZSH="$HOME/.config/zsh/.oh-my-zsh"
|
||||||
|
export ZDOTDIR="$HOME/.config/zsh"
|
||||||
|
export EDITOR="nvim"
|
||||||
|
export TERM="kitty"
|
||||||
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
export NVIM_APPNAME="nvim/benq"
|
||||||
|
export GOPATH="$HOME/.local/go"
|
||||||
|
export FZF_DEFAULT_OPTS="\
|
||||||
|
--border \
|
||||||
|
--preview-window right:60%:wrap \
|
||||||
|
--bind 'ctrl-u:preview-half-page-up' \
|
||||||
|
--bind 'ctrl-d:preview-half-page-down' \
|
||||||
|
--preview 'bat --color=always {}'
|
||||||
|
--bind '?:toggle-preview' \
|
||||||
|
--bind 'ctrl-/:change-preview-window(80%,hidden|)'"
|
||||||
@@ -15,14 +15,7 @@ autoload -Uz compinit
|
|||||||
compinit
|
compinit
|
||||||
|
|
||||||
# Exports
|
# Exports
|
||||||
export PATH="/usr/local/bin:$HOME/bin:$HOME/.local/bin:$HOME/.local/go/bin:$HOME/.dotnet/tools:$HOME/.cargo/bin:$PATH"
|
|
||||||
export ZSH="$HOME/.config/zsh/.oh-my-zsh"
|
|
||||||
export ZDOTDIR="$HOME/.config/zsh"
|
|
||||||
export EDITOR="nvim"
|
|
||||||
export TERM="kitty"
|
export TERM="kitty"
|
||||||
export XDG_CONFIG_HOME="$HOME/.config"
|
|
||||||
export NVIM_APPNAME="nvim/benq"
|
|
||||||
export GOPATH="$HOME/.local/go"
|
|
||||||
|
|
||||||
if [ -S "/run/user/$(id -u)/docker.sock" ]; then
|
if [ -S "/run/user/$(id -u)/docker.sock" ]; then
|
||||||
export DOCKER_HOST="unix:///run/user/$(id -u)/docker.sock"
|
export DOCKER_HOST="unix:///run/user/$(id -u)/docker.sock"
|
||||||
@@ -31,6 +24,11 @@ elif [ -S "/var/run/docker.sock" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
|
alias imgedit=gthumb
|
||||||
|
alias disk=ncdu
|
||||||
|
alias dl-yt="bash $HOME/.local/scripts/yt-dlp/download.sh"
|
||||||
|
alias compress-video="bash $HOME/.local/scripts/ffmpeg/compress-video.sh"
|
||||||
|
alias convert-gif="bash $HOME/.local/scripts/ffmpeg/convert-gif-to-mp4.sh"
|
||||||
|
|
||||||
# lazy
|
# lazy
|
||||||
lg() {
|
lg() {
|
||||||
@@ -94,3 +92,6 @@ source $ZSH/oh-my-zsh.sh
|
|||||||
|
|
||||||
# Add identities
|
# Add identities
|
||||||
ssh-add ~/.ssh/* 2>/dev/null
|
ssh-add ~/.ssh/* 2>/dev/null
|
||||||
|
|
||||||
|
# zoxide
|
||||||
|
eval "$(zoxide init zsh)"
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
config_version = 14
|
||||||
|
|
||||||
|
[accessibility]
|
||||||
|
ui_scale = 1.0
|
||||||
|
|
||||||
|
[audio]
|
||||||
|
enable_overdrive = true
|
||||||
|
|
||||||
|
[bar.main]
|
||||||
|
background_opacity = 0.99999997764825821
|
||||||
|
capsule_opacity = 0.99999997764825821
|
||||||
|
center = [ "workspaces" ]
|
||||||
|
color = "secondary"
|
||||||
|
end = [ "tray", "keyboard_layout", "group:g4", "group:g1", "notifications", "group:g5" ]
|
||||||
|
font_family = "Noto Sans"
|
||||||
|
icon_color = "primary"
|
||||||
|
margin_edge = 0
|
||||||
|
margin_ends = 1
|
||||||
|
panel_overlap = 0
|
||||||
|
radius_top_left = 0
|
||||||
|
radius_top_right = 0
|
||||||
|
start = [ "launcher", "group:g3", "group:g2", "ram", "group:g7", "group:g6", "sysmon_disk" ]
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g1"
|
||||||
|
members = [ "network", "bluetooth" ]
|
||||||
|
opacity = 0.89999997615814209
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g3"
|
||||||
|
members = [ "clock", "date" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g4"
|
||||||
|
members = [ "privacy", "volume", "input_volume" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g5"
|
||||||
|
members = [ "control-center" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g2"
|
||||||
|
members = [ "sysmon_cpu", "sysmon_cpu_temp" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g6"
|
||||||
|
members = [ "network_rx", "network_tx" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[[bar.main.capsule_group]]
|
||||||
|
enabled = true
|
||||||
|
fill = "surface_variant"
|
||||||
|
id = "g7"
|
||||||
|
members = [ "sysmon_gpu", "sysmon_gpu_temp" ]
|
||||||
|
opacity = 1.0
|
||||||
|
padding = 6.0
|
||||||
|
|
||||||
|
[desktop_widgets]
|
||||||
|
schema_version = 2
|
||||||
|
widget_order = []
|
||||||
|
|
||||||
|
[desktop_widgets.grid]
|
||||||
|
cell_size = 16
|
||||||
|
major_interval = 4
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
[dock]
|
||||||
|
background_opacity = 0.99999997764825821
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[idle]
|
||||||
|
behavior_order = [ "screen-off", "lock", "lock-and-suspend" ]
|
||||||
|
|
||||||
|
[idle.behavior.lock]
|
||||||
|
action = "lock"
|
||||||
|
enabled = true
|
||||||
|
timeout = 660.0
|
||||||
|
|
||||||
|
[idle.behavior.lock-and-suspend]
|
||||||
|
action = "lock_and_suspend"
|
||||||
|
enabled = true
|
||||||
|
timeout = 3600.0
|
||||||
|
|
||||||
|
[idle.behavior.screen-off]
|
||||||
|
action = "screen_off"
|
||||||
|
enabled = true
|
||||||
|
timeout = 600.0
|
||||||
|
|
||||||
|
[lockscreen]
|
||||||
|
transition = []
|
||||||
|
|
||||||
|
[lockscreen_widgets]
|
||||||
|
enabled = true
|
||||||
|
schema_version = 2
|
||||||
|
widget_order = [
|
||||||
|
"lockscreen-login-box@DP-3",
|
||||||
|
"lockscreen-login-box@DP-2",
|
||||||
|
"lockscreen-widget-0000000000000002",
|
||||||
|
"lockscreen-widget-0000000000000003"
|
||||||
|
]
|
||||||
|
|
||||||
|
[lockscreen_widgets.grid]
|
||||||
|
cell_size = 16
|
||||||
|
major_interval = 4
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-2"]
|
||||||
|
box_height = 196.0
|
||||||
|
box_width = 720.0
|
||||||
|
cx = 960.0
|
||||||
|
cy = 961.0
|
||||||
|
output = "DP-2"
|
||||||
|
placement_height = 1080.0
|
||||||
|
placement_width = 1920.0
|
||||||
|
rotation = 0.0
|
||||||
|
type = "login_box"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-2".settings]
|
||||||
|
background_color = "surface_variant"
|
||||||
|
background_opacity = 0.88
|
||||||
|
background_radius = 12.0
|
||||||
|
center_password_text = false
|
||||||
|
input_opacity = 1.0
|
||||||
|
input_radius = 6.0
|
||||||
|
layout = "regular"
|
||||||
|
show_caps_lock = true
|
||||||
|
show_keyboard_layout = true
|
||||||
|
show_login_button = true
|
||||||
|
show_media = false
|
||||||
|
show_session_buttons = true
|
||||||
|
show_unlock_hint = true
|
||||||
|
show_weather = true
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-3"]
|
||||||
|
box_height = 196.0
|
||||||
|
box_width = 720.0
|
||||||
|
cx = 1163.5
|
||||||
|
cy = 1120.5
|
||||||
|
output = "DP-3"
|
||||||
|
placement_height = 1309.0
|
||||||
|
placement_width = 2327.0
|
||||||
|
rotation = 0.0
|
||||||
|
type = "login_box"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget."lockscreen-login-box@DP-3".settings]
|
||||||
|
background_color = "surface_variant"
|
||||||
|
background_opacity = 0.88
|
||||||
|
background_radius = 12.0
|
||||||
|
center_password_text = false
|
||||||
|
input_opacity = 1.0
|
||||||
|
input_radius = 6.0
|
||||||
|
layout = "regular"
|
||||||
|
show_caps_lock = true
|
||||||
|
show_keyboard_layout = true
|
||||||
|
show_login_button = true
|
||||||
|
show_media = false
|
||||||
|
show_session_buttons = true
|
||||||
|
show_unlock_hint = true
|
||||||
|
show_weather = true
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget.lockscreen-widget-0000000000000002]
|
||||||
|
box_height = 176.0
|
||||||
|
box_width = 704.0
|
||||||
|
cx = 1163.5
|
||||||
|
cy = 854.5
|
||||||
|
output = "DP-3"
|
||||||
|
placement_height = 1309.0
|
||||||
|
placement_width = 2327.0
|
||||||
|
rotation = 0.0
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget.lockscreen-widget-0000000000000002.settings]
|
||||||
|
stat = "cpu_usage"
|
||||||
|
stat2 = "cpu_temp"
|
||||||
|
|
||||||
|
[lockscreen_widgets.widget.lockscreen-widget-0000000000000003]
|
||||||
|
box_height = 304.0
|
||||||
|
box_width = 688.0
|
||||||
|
cx = 1155.5
|
||||||
|
cy = 334.5
|
||||||
|
output = "DP-3"
|
||||||
|
placement_height = 1309.0
|
||||||
|
placement_width = 2327.0
|
||||||
|
rotation = 0.0
|
||||||
|
type = "clock"
|
||||||
|
|
||||||
|
[notification]
|
||||||
|
filter_order = [ "filter" ]
|
||||||
|
|
||||||
|
[notification.filter.filter]
|
||||||
|
allow_permanent = false
|
||||||
|
enabled = true
|
||||||
|
match = "satty"
|
||||||
|
override_duration = 500
|
||||||
|
play_sound = true
|
||||||
|
save_history = false
|
||||||
|
show_toast = true
|
||||||
|
|
||||||
|
[osd.kinds]
|
||||||
|
media = false
|
||||||
|
|
||||||
|
[shell]
|
||||||
|
show_location = false
|
||||||
|
|
||||||
|
[shell.panel]
|
||||||
|
open_near_click_control_center = true
|
||||||
|
session_placement = "attached"
|
||||||
|
|
||||||
|
[system.monitor]
|
||||||
|
gpu_poll_seconds = 5
|
||||||
|
|
||||||
|
[theme]
|
||||||
|
builtin = "Ayu"
|
||||||
|
community_palette = "Kanagawa Kasumi"
|
||||||
|
|
||||||
|
[theme.templates]
|
||||||
|
enable_builtin_templates = false
|
||||||
|
enable_community_templates = false
|
||||||
|
|
||||||
|
[wallpaper]
|
||||||
|
transition = []
|
||||||
|
transition_on_startup = true
|
||||||
|
|
||||||
|
[wallpaper.default]
|
||||||
|
path = "/home/benq/Pictures/Wallpapers/wink.png"
|
||||||
|
|
||||||
|
[wallpaper.last]
|
||||||
|
path = "/home/benq/Pictures/Wallpapers/wink.png"
|
||||||
|
|
||||||
|
[wallpaper.monitors.DP-2]
|
||||||
|
path = "/home/benq/Pictures/Wallpapers/wink.png"
|
||||||
|
|
||||||
|
[wallpaper.monitors.DP-3]
|
||||||
|
path = "/home/benq/Pictures/Wallpapers/wink.png"
|
||||||
|
|
||||||
|
[widget.clock]
|
||||||
|
color = "secondary"
|
||||||
|
format = "{:%H:%M:%S}"
|
||||||
|
|
||||||
|
[widget.date]
|
||||||
|
color = "primary"
|
||||||
|
|
||||||
|
[widget.media]
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[widget.network]
|
||||||
|
show_vpn_label = true
|
||||||
|
|
||||||
|
[widget.sysmon]
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[widget.sysmon_cpu]
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[widget.sysmon_cpu_temp]
|
||||||
|
stat = "cpu_temp"
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[widget.sysmon_disk]
|
||||||
|
stat = "disk_free"
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[widget.sysmon_gpu]
|
||||||
|
glyph = "gpu-usage"
|
||||||
|
stat = "gpu_vram"
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[widget.sysmon_gpu_temp]
|
||||||
|
stat = "gpu_temp"
|
||||||
|
type = "sysmon"
|
||||||
|
|
||||||
|
[widget.workspaces]
|
||||||
|
enabled = true
|
||||||
|
labels_only_when_occupied = true
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
APP_NAME="discord-canary"
|
||||||
|
KEY="${1:-${KEY:-}}"
|
||||||
|
|
||||||
|
if [ -z "$KEY" ]; then
|
||||||
|
echo "usage: $0 <key> (e.g. m or d)" >&2
|
||||||
|
notify-send "Discord toggle" "Missing key (m/d)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PREV_FOCUS=$(niri msg -j focused-window | jq -r '.id // empty')
|
||||||
|
WINS=$(niri msg -j windows)
|
||||||
|
WSS=$(niri msg -j workspaces)
|
||||||
|
DISCORD_ID=$(printf '%s' "$WINS" | jq -r --arg a "$APP_NAME" \
|
||||||
|
'.[] | select(.app_id == $a) | .id' | head -n1)
|
||||||
|
|
||||||
|
if [ -z "$DISCORD_ID" ]; then
|
||||||
|
notify-send "Discord not found" "Could not find $APP_NAME window"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# monitor-level shown window
|
||||||
|
SHOWN_WIN=$(printf '%s' "$WINS" | jq -r --argjson did "$DISCORD_ID" --argjson wss "$WSS" '
|
||||||
|
(.[] | select(.id == $did) | .workspace_id) as $wsid
|
||||||
|
| ($wss[] | select(.id == $wsid) | .output) as $out
|
||||||
|
| ($wss[] | select(.output == $out and .is_active) | .active_window_id // empty)
|
||||||
|
')
|
||||||
|
|
||||||
|
# focus Discord only if needed
|
||||||
|
if [ "$PREV_FOCUS" != "$DISCORD_ID" ]; then
|
||||||
|
niri msg action focus-window --id "$DISCORD_ID"
|
||||||
|
sleep 0.05
|
||||||
|
fi
|
||||||
|
|
||||||
|
wtype -M ctrl -M shift -k "$KEY" -m shift -m ctrl
|
||||||
|
sleep 0.05
|
||||||
|
|
||||||
|
# restore what that monitor was showing
|
||||||
|
if [ -n "${SHOWN_WIN:-}" ] && [ "$SHOWN_WIN" != "$DISCORD_ID" ]; then
|
||||||
|
niri msg action focus-window --id "$SHOWN_WIN"
|
||||||
|
sleep 0.05
|
||||||
|
fi
|
||||||
|
|
||||||
|
# # restore original global focus
|
||||||
|
if [ -n "$PREV_FOCUS" ] && [ "$PREV_FOCUS" != "$DISCORD_ID" ] && [ "$PREV_FOCUS" != "${SHOWN_WIN:-}" ]; then
|
||||||
|
niri msg action focus-window --id "$PREV_FOCUS"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
SCREENSHOTS_DIR="${XDG_PICTURES_DIR:-$(xdg-user-dir PICTURES)}/Screenshots"
|
||||||
|
mkdir -p "${SCREENSHOTS_DIR}"
|
||||||
|
|
||||||
|
MODE="${1:-region}"
|
||||||
|
|
||||||
|
case "${MODE}" in
|
||||||
|
region)
|
||||||
|
still -p -c 'grim -g "$(slurp -d)" -t ppm -'
|
||||||
|
;;
|
||||||
|
monitor-focused)
|
||||||
|
still -p -c 'grim -t ppm -o "$(niri msg --json focused-output | jq --raw-output .name)" -'
|
||||||
|
;;
|
||||||
|
monitor-all)
|
||||||
|
still -p -c 'grim -t ppm -'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "'${MODE}' is not a supported, aborting!" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac | satty --filename - --output-filename "${SCREENSHOTS_DIR}/screenshot-%+.png"
|
||||||
@@ -0,0 +1,461 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
if ! command -v ffmpeg &> /dev/null; then
|
||||||
|
echo -e "${RED}Error: ffmpeg is not installed.${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
input="$1"
|
||||||
|
if [[ -z "$input" ]]; then
|
||||||
|
echo -e "${RED}Usage: $0 /path/to/video.mp4 [optional_output.mp4_or_.gif]${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f "$input" ]]; then
|
||||||
|
echo -e "${RED}Error: Input file not found: $input${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_gif=false
|
||||||
|
if [[ "$input" == *.gif ]]; then
|
||||||
|
is_gif=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$2" ]]; then
|
||||||
|
output_file="$2"
|
||||||
|
if $is_gif; then
|
||||||
|
if [[ "$output_file" != *.gif ]]; then output_file="${output_file}.gif"; fi
|
||||||
|
else
|
||||||
|
if [[ "$output_file" != *.mp4 ]]; then output_file="${output_file}.mp4"; fi
|
||||||
|
fi
|
||||||
|
auto_index=false
|
||||||
|
else
|
||||||
|
base=$(basename "$input" | sed 's/\.[^.]*$//')
|
||||||
|
if $is_gif; then
|
||||||
|
ext="gif"
|
||||||
|
else
|
||||||
|
ext="mp4"
|
||||||
|
fi
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.${ext}" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.${ext}"
|
||||||
|
auto_index=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $is_gif; then
|
||||||
|
fps=15
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
loop_infinite=true
|
||||||
|
dither="bayer"
|
||||||
|
bayer_scale=3
|
||||||
|
stats_mode="full"
|
||||||
|
else
|
||||||
|
codec="libx264"
|
||||||
|
crf=26
|
||||||
|
preset="medium"
|
||||||
|
audio_bitrate="96k"
|
||||||
|
fps=""
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
faststart=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
function show_current_settings() {
|
||||||
|
echo -e "${CYAN}Current Settings${RESET}"
|
||||||
|
if $is_gif; then
|
||||||
|
echo -e "Input type: ${GREEN}GIF (re-encoding)${RESET}"
|
||||||
|
echo -e "FPS: ${GREEN}${fps}${RESET}"
|
||||||
|
echo -e "Scale width: ${GREEN}${width:-keep original}${RESET}"
|
||||||
|
echo -e "Start time: ${GREEN}${start_time:-from beginning}${RESET}"
|
||||||
|
echo -e "Duration: ${GREEN}${dur:-to end}${RESET}"
|
||||||
|
echo -e "Loop: ${GREEN}$(if $loop_infinite; then echo 'infinite'; else echo 'once'; fi)${RESET}"
|
||||||
|
echo -e "Dither: ${GREEN}${dither}${RESET}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
echo -e "Bayer scale: ${GREEN}${bayer_scale}${RESET}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "Input type: ${GREEN}Video${RESET}"
|
||||||
|
echo -e "Codec: ${GREEN}${codec}${RESET}"
|
||||||
|
echo -e "CRF (quality): ${GREEN}${crf}${RESET} (lower = better quality, bigger file)"
|
||||||
|
echo -e "Preset (speed): ${GREEN}${preset}${RESET} (slow = better compression)"
|
||||||
|
echo -e "Audio bitrate: ${GREEN}${audio_bitrate}${RESET} (or 'copy' to keep original)"
|
||||||
|
echo -e "FPS: ${GREEN}${fps:-keep original}${RESET}"
|
||||||
|
echo -e "Scale width: ${GREEN}${width:-keep original}${RESET}"
|
||||||
|
echo -e "Start time: ${GREEN}${start_time:-from beginning}${RESET}"
|
||||||
|
echo -e "Duration: ${GREEN}${dur:-to end}${RESET}"
|
||||||
|
echo -e "Faststart: ${GREEN}$(if $faststart; then echo 'yes (-movflags +faststart)'; else echo 'no'; fi)${RESET}"
|
||||||
|
fi
|
||||||
|
echo -e "Output file: ${GREEN}${output_file}${RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_vf() {
|
||||||
|
vf=""
|
||||||
|
if [[ -n "$fps" ]]; then
|
||||||
|
vf="fps=${fps}"
|
||||||
|
fi
|
||||||
|
if [[ -n "$width" ]]; then
|
||||||
|
if [[ -n "$vf" ]]; then vf+=","; fi
|
||||||
|
vf+="scale=${width}:-1:flags=lanczos"
|
||||||
|
fi
|
||||||
|
echo "$vf"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_command_string() {
|
||||||
|
cmd="ffmpeg -y"
|
||||||
|
if [[ -n "$start_time" ]]; then
|
||||||
|
cmd+=" -ss ${start_time}"
|
||||||
|
fi
|
||||||
|
cmd+=" -i \"${input}\""
|
||||||
|
if [[ -n "$dur" ]]; then
|
||||||
|
cmd+=" -t ${dur}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $is_gif; then
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
cmd+=" -vf \"${vf},split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
cmd+=":bayer_scale=${bayer_scale}"
|
||||||
|
fi
|
||||||
|
cmd+="\""
|
||||||
|
else
|
||||||
|
cmd+=" -vf \"split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
cmd+=":bayer_scale=${bayer_scale}"
|
||||||
|
fi
|
||||||
|
cmd+="\""
|
||||||
|
fi
|
||||||
|
if $loop_infinite; then
|
||||||
|
cmd+=" -loop 0"
|
||||||
|
else
|
||||||
|
cmd+=" -loop 1"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
cmd+=" -vf \"$vf\""
|
||||||
|
fi
|
||||||
|
cmd+=" -c:v ${codec} -crf ${crf} -preset ${preset}"
|
||||||
|
if [[ "$audio_bitrate" == "copy" ]]; then
|
||||||
|
cmd+=" -c:a copy"
|
||||||
|
else
|
||||||
|
cmd+=" -c:a aac -b:a ${audio_bitrate}"
|
||||||
|
fi
|
||||||
|
if $faststart; then
|
||||||
|
cmd+=" -movflags +faststart"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
cmd+=" \"${output_file}\""
|
||||||
|
echo "$cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
function configure_settings() {
|
||||||
|
while true; do
|
||||||
|
echo -e "\n${YELLOW}Press Enter to keep default shown in [brackets]. Type new value to change.${RESET}"
|
||||||
|
echo -e "${CYAN}Configuration${RESET}"
|
||||||
|
|
||||||
|
if $is_gif; then
|
||||||
|
read -p "FPS [${fps}]: " val
|
||||||
|
if [[ -n "$val" ]]; then fps="$val"; fi
|
||||||
|
|
||||||
|
read -p "Scale width in px (e.g. 480 or 640, empty=keep): " val
|
||||||
|
if [[ -n "$val" ]]; then width="$val"; fi
|
||||||
|
|
||||||
|
read -p "Start time (e.g. 00:00:05 or 5, empty=from start): " val
|
||||||
|
start_time="$val"
|
||||||
|
|
||||||
|
read -p "Duration in sec or HH:MM:SS (empty=to end): " val
|
||||||
|
dur="$val"
|
||||||
|
|
||||||
|
read -p "Loop infinitely? (y/n) [y]: " val
|
||||||
|
if [[ "$val" == "n" || "$val" == "N" ]]; then loop_infinite=false; else loop_infinite=true; fi
|
||||||
|
|
||||||
|
read -p "Dither (bayer / floyd_steinberg / none) [bayer]: " val
|
||||||
|
if [[ -n "$val" ]]; then dither="$val"; fi
|
||||||
|
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
read -p "Bayer scale 1-5 [${bayer_scale}]: " val
|
||||||
|
if [[ -n "$val" ]]; then bayer_scale="$val"; fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
read -p "Codec (libx265 or libx264) [${codec}]: " val
|
||||||
|
if [[ -n "$val" ]]; then codec="$val"; fi
|
||||||
|
|
||||||
|
read -p "CRF quality [${crf}]: " val
|
||||||
|
if [[ -n "$val" ]]; then crf="$val"; fi
|
||||||
|
|
||||||
|
read -p "Preset (ultrafast|superfast|veryfast|fast|medium|slow|veryslow) [${preset}]: " val
|
||||||
|
if [[ -n "$val" ]]; then preset="$val"; fi
|
||||||
|
|
||||||
|
read -p "Audio bitrate in k (e.g. 96k or 128k, or 'copy') [${audio_bitrate}]: " val
|
||||||
|
if [[ -n "$val" ]]; then audio_bitrate="$val"; fi
|
||||||
|
|
||||||
|
read -p "Target FPS (empty=keep original, e.g. 30): " val
|
||||||
|
fps="$val"
|
||||||
|
|
||||||
|
read -p "Scale width in px (e.g. 1280, empty=keep original): " val
|
||||||
|
width="$val"
|
||||||
|
|
||||||
|
read -p "Start time (e.g. 00:00:05 or 5, empty=from start): " val
|
||||||
|
start_time="$val"
|
||||||
|
|
||||||
|
read -p "Duration in sec or HH:MM:SS (empty=to end): " val
|
||||||
|
dur="$val"
|
||||||
|
|
||||||
|
read -p "Enable faststart? (y/n) [y]: " val
|
||||||
|
if [[ "$val" == "n" || "$val" == "N" ]]; then
|
||||||
|
faststart=false
|
||||||
|
else
|
||||||
|
faststart=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
show_current_settings
|
||||||
|
echo -e "\n${YELLOW}Preview command:${RESET}"
|
||||||
|
build_command_string
|
||||||
|
|
||||||
|
echo -e "\n${CYAN}Options now:${RESET}"
|
||||||
|
echo "1) Execute with these settings"
|
||||||
|
echo "2) Restart configuration from defaults"
|
||||||
|
echo "3) Change one specific setting"
|
||||||
|
echo "4) Exit without compressing"
|
||||||
|
read -p "Your choice [1]: " choice
|
||||||
|
choice=${choice:-1}
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1) return 0 ;;
|
||||||
|
2)
|
||||||
|
if $is_gif; then
|
||||||
|
fps=15
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
loop_infinite=true
|
||||||
|
dither="bayer"
|
||||||
|
bayer_scale=3
|
||||||
|
else
|
||||||
|
codec="libx264"
|
||||||
|
crf=26
|
||||||
|
preset="medium"
|
||||||
|
audio_bitrate="96k"
|
||||||
|
fps=""
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
faststart=true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
echo -e "${CYAN}Which setting to change?${RESET}"
|
||||||
|
if $is_gif; then
|
||||||
|
echo "a) FPS b) Scale width c) Start time d) Duration e) Loop f) Dither g) Bayer scale"
|
||||||
|
else
|
||||||
|
echo "a) Codec b) CRF c) Preset d) Audio bitrate e) FPS f) Scale width"
|
||||||
|
echo "g) Start time h) Duration i) Faststart (movflags)"
|
||||||
|
fi
|
||||||
|
read -p "Letter: " letter
|
||||||
|
if $is_gif; then
|
||||||
|
case $letter in
|
||||||
|
a) read -p "New FPS: " val; [[ -n "$val" ]] && fps="$val" ;;
|
||||||
|
b) read -p "New width: " val; width="$val" ;;
|
||||||
|
c) read -p "New start time: " val; start_time="$val" ;;
|
||||||
|
d) read -p "New duration: " val; dur="$val" ;;
|
||||||
|
e) if $loop_infinite; then loop_infinite=false; else loop_infinite=true; fi ;;
|
||||||
|
f) read -p "New dither: " val; [[ -n "$val" ]] && dither="$val" ;;
|
||||||
|
g) if [[ "$dither" == "bayer" ]]; then read -p "New bayer scale: " val; [[ -n "$val" ]] && bayer_scale="$val"; fi ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case $letter in
|
||||||
|
a) read -p "New codec (libx265/libx264): " val; [[ -n "$val" ]] && codec="$val" ;;
|
||||||
|
b) read -p "New CRF: " val; [[ -n "$val" ]] && crf="$val" ;;
|
||||||
|
c) read -p "New preset: " val; [[ -n "$val" ]] && preset="$val" ;;
|
||||||
|
d) read -p "New audio bitrate or 'copy': " val; [[ -n "$val" ]] && audio_bitrate="$val" ;;
|
||||||
|
e) read -p "New FPS (empty=keep): " val; fps="$val" ;;
|
||||||
|
f) read -p "New width (empty=keep): " val; width="$val" ;;
|
||||||
|
g) read -p "New start time: " val; start_time="$val" ;;
|
||||||
|
h) read -p "New duration: " val; dur="$val" ;;
|
||||||
|
i) if $faststart; then faststart=false; else faststart=true; fi ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
4) echo -e "${YELLOW}Exiting.${RESET}"; exit 0 ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_settings
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}Starting compression...${RESET}"
|
||||||
|
echo -e "${YELLOW}Command: $(build_command_string)${RESET}\n"
|
||||||
|
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
if [[ -n "$start_time" ]]; then
|
||||||
|
cmd_array+=(-ss "$start_time")
|
||||||
|
fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
if [[ -n "$dur" ]]; then
|
||||||
|
cmd_array+=(-t "$dur")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $is_gif; then
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
full_vf="${vf},split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
full_vf+=":bayer_scale=${bayer_scale}"
|
||||||
|
fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
else
|
||||||
|
full_vf="split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
full_vf+=":bayer_scale=${bayer_scale}"
|
||||||
|
fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
fi
|
||||||
|
if $loop_infinite; then
|
||||||
|
cmd_array+=(-loop 0)
|
||||||
|
else
|
||||||
|
cmd_array+=(-loop 1)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
cmd_array+=(-vf "$vf")
|
||||||
|
fi
|
||||||
|
cmd_array+=(-c:v "$codec" -crf "$crf" -preset "$preset")
|
||||||
|
if [[ "$audio_bitrate" == "copy" ]]; then
|
||||||
|
cmd_array+=(-c:a copy)
|
||||||
|
else
|
||||||
|
cmd_array+=(-c:a aac -b:a "$audio_bitrate")
|
||||||
|
fi
|
||||||
|
if $faststart; then
|
||||||
|
cmd_array+=(-movflags +faststart)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}✓ Compression finished!${RESET}"
|
||||||
|
echo -e "File: ${GREEN}${output_file}${RESET}"
|
||||||
|
echo -e "Size: ${GREEN}${size}${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Error: Output file was not created.${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo -e "\n${CYAN}Select option:${RESET}"
|
||||||
|
echo "1) Change settings and create a NEW file (next available index)"
|
||||||
|
echo "2) Redo with current settings (will overwrite ${output_file})"
|
||||||
|
echo "q) Exit"
|
||||||
|
read -p "Choice: " post_choice
|
||||||
|
|
||||||
|
case $post_choice in
|
||||||
|
1)
|
||||||
|
if $auto_index; then
|
||||||
|
base=$(basename "$output_file" | sed "s/-[0-9]*\.${ext}$//")
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.${ext}" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.${ext}"
|
||||||
|
else
|
||||||
|
base=$(basename "$output_file" | sed "s/\.${ext}$//")
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.${ext}" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.${ext}"
|
||||||
|
fi
|
||||||
|
echo -e "New output file will be: ${YELLOW}${output_file}${RESET}"
|
||||||
|
configure_settings
|
||||||
|
echo -e "\n${GREEN}Starting new compression...${RESET}"
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
if [[ -n "$start_time" ]]; then cmd_array+=(-ss "$start_time"); fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
if [[ -n "$dur" ]]; then cmd_array+=(-t "$dur"); fi
|
||||||
|
if $is_gif; then
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
full_vf="${vf},split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then full_vf+=":bayer_scale=${bayer_scale}"; fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
else
|
||||||
|
full_vf="split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then full_vf+=":bayer_scale=${bayer_scale}"; fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
fi
|
||||||
|
if $loop_infinite; then cmd_array+=(-loop 0); else cmd_array+=(-loop 1); fi
|
||||||
|
else
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then cmd_array+=(-vf "$vf"); fi
|
||||||
|
cmd_array+=(-c:v "$codec" -crf "$crf" -preset "$preset")
|
||||||
|
if [[ "$audio_bitrate" == "copy" ]]; then cmd_array+=(-c:a copy); else cmd_array+=(-c:a aac -b:a "$audio_bitrate"); fi
|
||||||
|
if $faststart; then cmd_array+=(-movflags +faststart); fi
|
||||||
|
fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}New file created!${RESET} File: ${GREEN}${output_file}${RESET} Size: ${GREEN}${size}${RESET}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo -e "${YELLOW}Will overwrite ${output_file} on next run.${RESET}"
|
||||||
|
configure_settings
|
||||||
|
echo -e "\n${GREEN}Starting compression (overwrite mode)...${RESET}"
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
if [[ -n "$start_time" ]]; then cmd_array+=(-ss "$start_time"); fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
if [[ -n "$dur" ]]; then cmd_array+=(-t "$dur"); fi
|
||||||
|
if $is_gif; then
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then
|
||||||
|
full_vf="${vf},split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then full_vf+=":bayer_scale=${bayer_scale}"; fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
else
|
||||||
|
full_vf="split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then full_vf+=":bayer_scale=${bayer_scale}"; fi
|
||||||
|
cmd_array+=(-vf "$full_vf")
|
||||||
|
fi
|
||||||
|
if $loop_infinite; then cmd_array+=(-loop 0); else cmd_array+=(-loop 1); fi
|
||||||
|
else
|
||||||
|
vf="$(build_vf)"
|
||||||
|
if [[ -n "$vf" ]]; then cmd_array+=(-vf "$vf"); fi
|
||||||
|
cmd_array+=(-c:v "$codec" -crf "$crf" -preset "$preset")
|
||||||
|
if [[ "$audio_bitrate" == "copy" ]]; then cmd_array+=(-c:a copy); else cmd_array+=(-c:a aac -b:a "$audio_bitrate"); fi
|
||||||
|
if $faststart; then cmd_array+=(-movflags +faststart); fi
|
||||||
|
fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}Overwritten!${RESET} File: ${GREEN}${output_file}${RESET} Size: ${GREEN}${size}${RESET}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
echo -e "${GREEN}Done.${RESET}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "${RED}Invalid choice.${RESET}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
if ! command -v ffmpeg &> /dev/null; then
|
||||||
|
echo -e "${RED}Error: ffmpeg is not installed.${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
input="$1"
|
||||||
|
if [[ -z "$input" ]]; then
|
||||||
|
echo -e "${RED}Usage: $0 /path/to/video.mp4 [optional_output.gif]${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f "$input" ]]; then
|
||||||
|
echo -e "${RED}Error: Input file not found: $input${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$2" ]]; then
|
||||||
|
output_file="$2"
|
||||||
|
if [[ "$output_file" != *.gif ]]; then
|
||||||
|
output_file="${output_file}.gif"
|
||||||
|
fi
|
||||||
|
auto_index=false
|
||||||
|
else
|
||||||
|
base=$(basename "$input" | sed 's/\.[^.]*$//')
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.gif" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.gif"
|
||||||
|
auto_index=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
fps=25
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
loop_infinite=true
|
||||||
|
dither="bayer"
|
||||||
|
bayer_scale=3
|
||||||
|
stats_mode="full"
|
||||||
|
|
||||||
|
function show_current_settings() {
|
||||||
|
echo -e "${CYAN}Current Settings=${RESET}"
|
||||||
|
echo -e "FPS: ${GREEN}${fps}${RESET}"
|
||||||
|
echo -e "Scale width: ${GREEN}${width:-keep original}${RESET}"
|
||||||
|
echo -e "Start time: ${GREEN}${start_time:-from beginning}${RESET}"
|
||||||
|
echo -e "Duration: ${GREEN}${dur:-to end}${RESET}"
|
||||||
|
echo -e "Loop: ${GREEN}$(if $loop_infinite; then echo 'infinite (-loop 0)'; else echo 'once (-loop 1)'; fi)${RESET}"
|
||||||
|
echo -e "Dither: ${GREEN}${dither}${RESET}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
echo -e "Bayer scale: ${GREEN}${bayer_scale}${RESET}"
|
||||||
|
fi
|
||||||
|
echo -e "Output file: ${GREEN}${output_file}${RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_vf() {
|
||||||
|
vf="fps=${fps}"
|
||||||
|
if [[ -n "$width" ]]; then
|
||||||
|
vf+=",scale=${width}:-1:flags=lanczos"
|
||||||
|
fi
|
||||||
|
vf+=",split[s0][s1];[s0]palettegen=stats_mode=${stats_mode}[p];[s1][p]paletteuse=dither=${dither}"
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
vf+=":bayer_scale=${bayer_scale}"
|
||||||
|
fi
|
||||||
|
echo "$vf"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_command_string() {
|
||||||
|
cmd="ffmpeg -y"
|
||||||
|
if [[ -n "$start_time" ]]; then
|
||||||
|
cmd+=" -ss ${start_time}"
|
||||||
|
fi
|
||||||
|
cmd+=" -i \"${input}\""
|
||||||
|
if [[ -n "$dur" ]]; then
|
||||||
|
cmd+=" -t ${dur}"
|
||||||
|
fi
|
||||||
|
cmd+=" -vf \"$(build_vf)\""
|
||||||
|
if $loop_infinite; then
|
||||||
|
cmd+=" -loop 0"
|
||||||
|
else
|
||||||
|
cmd+=" -loop 1"
|
||||||
|
fi
|
||||||
|
cmd+=" \"${output_file}\""
|
||||||
|
echo "$cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
function configure_settings() {
|
||||||
|
while true; do
|
||||||
|
echo -e "\n${YELLOW}Press Enter to keep default shown in [brackets]. Type new value to change.${RESET}"
|
||||||
|
echo -e "${CYAN}Configuration:${RESET}"
|
||||||
|
|
||||||
|
read -p "FPS [${fps}]: " val
|
||||||
|
if [[ -n "$val" ]]; then fps="$val"; fi
|
||||||
|
|
||||||
|
read -p "Scale width in px (e.g. 640 or 800, empty=keep original): " val
|
||||||
|
if [[ -n "$val" ]]; then width="$val"; fi
|
||||||
|
|
||||||
|
read -p "Start time (e.g. 00:00:05 or 5, empty=from start): " val
|
||||||
|
start_time="$val"
|
||||||
|
|
||||||
|
read -p "Duration in sec or HH:MM:SS (empty=to end): " val
|
||||||
|
dur="$val"
|
||||||
|
|
||||||
|
read -p "Loop infinitely? (y/n) [y]: " val
|
||||||
|
if [[ "$val" == "n" || "$val" == "N" ]]; then
|
||||||
|
loop_infinite=false
|
||||||
|
else
|
||||||
|
loop_infinite=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "Dither method (bayer / floyd_steinberg / none) [bayer]: " val
|
||||||
|
if [[ -n "$val" ]]; then dither="$val"; fi
|
||||||
|
|
||||||
|
if [[ "$dither" == "bayer" ]]; then
|
||||||
|
read -p "Bayer scale 1-5 (higher=more dither pattern) [${bayer_scale}]: " val
|
||||||
|
if [[ -n "$val" ]]; then bayer_scale="$val"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
show_current_settings
|
||||||
|
echo -e "\n${YELLOW}Preview command:${RESET}"
|
||||||
|
build_command_string
|
||||||
|
|
||||||
|
echo -e "\n${CYAN}Options now:${RESET}"
|
||||||
|
echo "1) Execute with these settings"
|
||||||
|
echo "2) Restart configuration from defaults"
|
||||||
|
echo "3) Change one specific setting"
|
||||||
|
echo "4) Exit without converting"
|
||||||
|
read -p "Your choice [1]: " choice
|
||||||
|
choice=${choice:-1}
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1) return 0 ;;
|
||||||
|
2)
|
||||||
|
fps=25
|
||||||
|
width=""
|
||||||
|
start_time=""
|
||||||
|
dur=""
|
||||||
|
loop_infinite=true
|
||||||
|
dither="bayer"
|
||||||
|
bayer_scale=3
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
echo -e "${CYAN}Which setting to change?${RESET}"
|
||||||
|
echo "a) FPS"
|
||||||
|
echo "b) Scale width"
|
||||||
|
echo "c) Start time"
|
||||||
|
echo "d) Duration"
|
||||||
|
echo "e) Loop"
|
||||||
|
echo "f) Dither method"
|
||||||
|
echo "g) Bayer scale (if bayer)"
|
||||||
|
read -p "Letter: " letter
|
||||||
|
case $letter in
|
||||||
|
a) read -p "New FPS: " val; [[ -n "$val" ]] && fps="$val" ;;
|
||||||
|
b) read -p "New width (empty to keep original): " val; width="$val" ;;
|
||||||
|
c) read -p "New start time: " val; start_time="$val" ;;
|
||||||
|
d) read -p "New duration: " val; dur="$val" ;;
|
||||||
|
e) if $loop_infinite; then loop_infinite=false; else loop_infinite=true; fi ;;
|
||||||
|
f) read -p "New dither (bayer/floyd_steinberg/none): " val; [[ -n "$val" ]] && dither="$val" ;;
|
||||||
|
g) if [[ "$dither" == "bayer" ]]; then read -p "New bayer scale: " val; [[ -n "$val" ]] && bayer_scale="$val"; fi ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
4) echo -e "${YELLOW}Exiting.${RESET}"; exit 0 ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_settings
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}Starting conversion...${RESET}"
|
||||||
|
echo -e "${YELLOW}Command: $(build_command_string)${RESET}\n"
|
||||||
|
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
if [[ -n "$start_time" ]]; then
|
||||||
|
cmd_array+=(-ss "$start_time")
|
||||||
|
fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
if [[ -n "$dur" ]]; then
|
||||||
|
cmd_array+=(-t "$dur")
|
||||||
|
fi
|
||||||
|
vf="$(build_vf)"
|
||||||
|
cmd_array+=(-vf "$vf")
|
||||||
|
if $loop_infinite; then
|
||||||
|
cmd_array+=(-loop 0)
|
||||||
|
else
|
||||||
|
cmd_array+=(-loop 1)
|
||||||
|
fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}✓ Conversion finished!${RESET}"
|
||||||
|
echo -e "File: ${GREEN}${output_file}${RESET}"
|
||||||
|
echo -e "Size: ${GREEN}${size}${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Error: Output file was not created.${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo -e "\n${CYAN}Select option:${RESET}"
|
||||||
|
echo "1) Change settings and create a NEW file (next available index)"
|
||||||
|
echo "2) Redo with current settings (will overwrite ${output_file})"
|
||||||
|
echo "q) Exit"
|
||||||
|
read -p "Choice: " post_choice
|
||||||
|
|
||||||
|
case $post_choice in
|
||||||
|
1)
|
||||||
|
if $auto_index; then
|
||||||
|
base=$(basename "$output_file" | sed 's/-[0-9]*\.gif$//')
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.gif" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.gif"
|
||||||
|
else
|
||||||
|
base=$(basename "$output_file" | sed 's/\.gif$//')
|
||||||
|
i=0
|
||||||
|
while [[ -f "${base}-${i}.gif" ]]; do
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
output_file="${base}-${i}.gif"
|
||||||
|
fi
|
||||||
|
echo -e "New output file will be: ${YELLOW}${output_file}${RESET}"
|
||||||
|
configure_settings
|
||||||
|
echo -e "\n${GREEN}Starting new conversion...${RESET}"
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
if [[ -n "$start_time" ]]; then cmd_array+=(-ss "$start_time"); fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
if [[ -n "$dur" ]]; then cmd_array+=(-t "$dur"); fi
|
||||||
|
vf="$(build_vf)"
|
||||||
|
cmd_array+=(-vf "$vf")
|
||||||
|
if $loop_infinite; then cmd_array+=(-loop 0); else cmd_array+=(-loop 1); fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}New file created!${RESET} File: ${GREEN}${output_file}${RESET} Size: ${GREEN}${size}${RESET}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo -e "${YELLOW}Will overwrite ${output_file} on next run.${RESET}"
|
||||||
|
configure_settings
|
||||||
|
echo -e "\n${GREEN}Starting conversion (overwrite mode)...${RESET}"
|
||||||
|
cmd_array=(ffmpeg -y)
|
||||||
|
|
||||||
|
if [[ -n "$start_time" ]]; then cmd_array+=(-ss "$start_time"); fi
|
||||||
|
cmd_array+=(-i "$input")
|
||||||
|
|
||||||
|
if [[ -n "$dur" ]]; then cmd_array+=(-t "$dur"); fi
|
||||||
|
vf="$(build_vf)"
|
||||||
|
cmd_array+=(-vf "$vf")
|
||||||
|
|
||||||
|
if $loop_infinite; then cmd_array+=(-loop 0); else cmd_array+=(-loop 1); fi
|
||||||
|
cmd_array+=("$output_file")
|
||||||
|
"${cmd_array[@]}"
|
||||||
|
|
||||||
|
if [[ -f "$output_file" ]]; then
|
||||||
|
size=$(du -h "$output_file" | awk '{print $1}')
|
||||||
|
echo -e "\n${GREEN}Overwritten!${RESET} File: ${GREEN}${output_file}${RESET} Size: ${GREEN}${size}${RESET}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
echo -e "${GREEN}Done.${RESET}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "${RED}Invalid choice.${RESET}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
@@ -0,0 +1,381 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
RESET='\033[0m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
MAGENTA='\033[0;35m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
|
||||||
|
time_to_seconds() {
|
||||||
|
local t="$1"
|
||||||
|
if [[ "$t" == "inf" ]]; then
|
||||||
|
echo 999999999
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
local sign=1
|
||||||
|
if [[ "$t" == -* ]]; then
|
||||||
|
sign=-1
|
||||||
|
t="${t#-}"
|
||||||
|
fi
|
||||||
|
if [[ "$t" =~ ^[0-9]+$ ]]; then
|
||||||
|
echo $(( sign * t ))
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
IFS=: read -ra parts <<< "$t"
|
||||||
|
local secs=0
|
||||||
|
local n=${#parts[@]}
|
||||||
|
if [ $n -eq 3 ]; then
|
||||||
|
secs=$(( ${parts[0]}*3600 + ${parts[1]}*60 + ${parts[2]} ))
|
||||||
|
elif [ $n -eq 2 ]; then
|
||||||
|
secs=$(( ${parts[0]}*60 + ${parts[1]} ))
|
||||||
|
else
|
||||||
|
secs=0
|
||||||
|
fi
|
||||||
|
echo $(( sign * secs ))
|
||||||
|
}
|
||||||
|
|
||||||
|
is_valid_time_format() {
|
||||||
|
local t="$1"
|
||||||
|
if [[ "$t" == "inf" || "$t" =~ ^-?[0-9]+$ || "$t" =~ ^-?[0-9]+(:[0-9]+)+$ ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_merge_format() {
|
||||||
|
local fmt="$1"
|
||||||
|
local allowed="avi flv mkv mov mp4 webm"
|
||||||
|
for a in $allowed; do
|
||||||
|
if [[ "$fmt" == "$a" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
colored_read() {
|
||||||
|
local prompt="$1"
|
||||||
|
local default="$2"
|
||||||
|
local val
|
||||||
|
if [ -n "$default" ]; then
|
||||||
|
echo -e "${prompt} ${YELLOW}(current: $default)${RESET}" >&2
|
||||||
|
read -p "New value (empty = keep): " val
|
||||||
|
if [ -z "$val" ]; then
|
||||||
|
val="$default"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "$prompt" >&2
|
||||||
|
read -p "> " val
|
||||||
|
fi
|
||||||
|
echo "$val"
|
||||||
|
}
|
||||||
|
|
||||||
|
select_cookies() {
|
||||||
|
case "$cookies" in
|
||||||
|
1) cookies="firefox:~/.config/librewolf/librewolf" ;;
|
||||||
|
2) cookies="firefox" ;;
|
||||||
|
3) cookies="chrome" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo -e "\n${MAGENTA}Browser cookies:${RESET}"
|
||||||
|
echo " 1) Librewolf (firefox:~/.config/librewolf/librewolf)"
|
||||||
|
echo " 2) Firefox (firefox)"
|
||||||
|
echo " 3) Chrome (chrome)"
|
||||||
|
echo " (or type a full custom value directly, e.g. firefox:Profile 1)"
|
||||||
|
echo " (empty = none / keep current)"
|
||||||
|
|
||||||
|
local prompt="Select 1-3 or enter custom"
|
||||||
|
if [ -n "$cookies" ]; then
|
||||||
|
echo -e "${BLUE}${prompt}:${RESET} ${YELLOW}(current: $cookies)${RESET}" >&2
|
||||||
|
else
|
||||||
|
echo -e "${BLUE}${prompt}:${RESET}" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
local cinput
|
||||||
|
read -r cinput
|
||||||
|
|
||||||
|
if [ -n "$cinput" ]; then
|
||||||
|
case "$cinput" in
|
||||||
|
1) cookies="firefox:~/.config/librewolf/librewolf" ;;
|
||||||
|
2) cookies="firefox" ;;
|
||||||
|
3) cookies="chrome" ;;
|
||||||
|
0|none|clear)
|
||||||
|
cookies=""
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cookies="$cinput"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
collect_inputs() {
|
||||||
|
url=$(colored_read "${BLUE}Enter video URL:${RESET}" "$url")
|
||||||
|
|
||||||
|
select_cookies
|
||||||
|
|
||||||
|
echo -e "\n${MAGENTA}Clip / Download sections:${RESET}"
|
||||||
|
echo "Use *START-END (e.g. *0:21-1:27 or *83-296)"
|
||||||
|
echo "End can be 'inf' for to the end. Negative = from end of video."
|
||||||
|
echo "*from-url also supported to use times from video URL."
|
||||||
|
echo "Leave start/end empty to download full video."
|
||||||
|
start_time=$(colored_read "${BLUE}Start time (e.g. 0:21 or 83, empty=skip):${RESET}" "$start_time")
|
||||||
|
end_time=$(colored_read "${BLUE}End time (e.g. 1:27 or inf, empty=skip):${RESET}" "$end_time")
|
||||||
|
|
||||||
|
if [ -n "$start_time" ] || [ -n "$end_time" ]; then
|
||||||
|
if [ -n "$start_time" ] && ! is_valid_time_format "$start_time"; then
|
||||||
|
echo -e "${RED}Invalid start time format. Use number, MM:SS or HH:MM:SS${RESET}"
|
||||||
|
start_time=""
|
||||||
|
fi
|
||||||
|
if [ -n "$end_time" ] && ! is_valid_time_format "$end_time"; then
|
||||||
|
echo -e "${RED}Invalid end time format. Use number, MM:SS, HH:MM:SS or inf${RESET}"
|
||||||
|
end_time=""
|
||||||
|
fi
|
||||||
|
if [ -n "$start_time" ] && [ -n "$end_time" ]; then
|
||||||
|
ssec=$(time_to_seconds "$start_time")
|
||||||
|
esec=$(time_to_seconds "$end_time")
|
||||||
|
if [ "$ssec" -ge "$esec" ]; then
|
||||||
|
echo -e "${RED}Start time must be strictly before end time.${RESET}"
|
||||||
|
start_time=""
|
||||||
|
end_time=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${MAGENTA}Format selection:${RESET}"
|
||||||
|
echo "Common presets:"
|
||||||
|
echo "1) Best video+audio merged (bv+ba/b)"
|
||||||
|
echo "2) Best MP4 video + best m4a audio"
|
||||||
|
echo "3) Best video (any) + best audio (bv*+ba/b)"
|
||||||
|
echo "4) Best video only + best audio only (separate files, no merge)"
|
||||||
|
echo "5) Custom full -f string (advanced)"
|
||||||
|
echo "6) Audio only as MP3 (bestaudio/best + extract to mp3)"
|
||||||
|
format_choice=$(colored_read "${BLUE}Choose 1-6 or enter custom -f value directly:${RESET}" "$format_choice")
|
||||||
|
|
||||||
|
mp3_only=""
|
||||||
|
case "$format_choice" in
|
||||||
|
1) format_selector='bv+ba/b' ;;
|
||||||
|
2) format_selector='bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]' ;;
|
||||||
|
3) format_selector='bv*+ba/b' ;;
|
||||||
|
4) format_selector='bv,ba' ;;
|
||||||
|
5)
|
||||||
|
echo "Examples:"
|
||||||
|
echo ' bv+ba/b'
|
||||||
|
echo ' bestvideo[ext=mp4]+bestaudio[ext=m4a]/best'
|
||||||
|
echo ' bv[height<=720]+ba'
|
||||||
|
echo ' ba[ext=m4a]/b'
|
||||||
|
custom_f=$(colored_read "${BLUE}Enter full -f string:${RESET}" "")
|
||||||
|
format_selector="$custom_f"
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
format_selector='bestaudio/best'
|
||||||
|
mp3_only="yes"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ -n "$format_choice" ]; then
|
||||||
|
format_selector="$format_choice"
|
||||||
|
else
|
||||||
|
format_selector=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$mp3_only" = "yes" ]; then
|
||||||
|
echo -e "\n${YELLOW}MP3 audio only selected — merge format is not applicable.${RESET}"
|
||||||
|
merge_format=""
|
||||||
|
else
|
||||||
|
echo -e "\n${MAGENTA}Merge output format:${RESET}"
|
||||||
|
echo "Supported containers: avi, flv, mkv, mov, mp4, webm"
|
||||||
|
echo "Ignored if no merge is needed (single format or separate files)."
|
||||||
|
echo "Requires ffmpeg for merging."
|
||||||
|
merge_format=$(colored_read "${BLUE}Merge format (e.g. mp4 or mkv, empty=skip):${RESET}" "$merge_format")
|
||||||
|
|
||||||
|
if [ -n "$merge_format" ] && ! validate_merge_format "$merge_format"; then
|
||||||
|
echo -e "${RED}Invalid merge format. Allowed: avi flv mkv mov mp4 webm${RESET}"
|
||||||
|
merge_format=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${MAGENTA}Extra option:${RESET}"
|
||||||
|
force_key=$(colored_read "${BLUE}Add --force-keyframes-at-cuts for exact cuts? (y/n):${RESET}" "$force_key")
|
||||||
|
if [[ "$force_key" =~ ^[Yy] ]]; then
|
||||||
|
force_key="y"
|
||||||
|
force="--force-keyframes-at-cuts"
|
||||||
|
else
|
||||||
|
force_key="n"
|
||||||
|
force=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_command() {
|
||||||
|
cmd_args=()
|
||||||
|
[ -n "$cookies" ] && cmd_args+=("--cookies-from-browser" "$cookies")
|
||||||
|
|
||||||
|
if [ -n "$start_time" ] || [ -n "$end_time" ]; then
|
||||||
|
section="*${start_time}-${end_time}"
|
||||||
|
cmd_args+=("--download-sections" "$section")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$format_selector" ]; then
|
||||||
|
cmd_args+=("-f" "$format_selector")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$mp3_only" = "yes" ]; then
|
||||||
|
cmd_args+=(--extract-audio --audio-format mp3)
|
||||||
|
elif [ -n "$merge_format" ]; then
|
||||||
|
cmd_args+=("--merge-output-format" "$merge_format")
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -n "$force" ] && cmd_args+=("$force")
|
||||||
|
|
||||||
|
[ -n "$url" ] && cmd_args+=("$url")
|
||||||
|
}
|
||||||
|
|
||||||
|
review_and_confirm() {
|
||||||
|
while true; do
|
||||||
|
echo -e "\n${GREEN}${BOLD}Current Settings${RESET}"
|
||||||
|
echo -e "${BLUE}URL:${RESET} ${url:-<not set>}"
|
||||||
|
echo -e "${BLUE}Cookies:${RESET} ${cookies:-<none>}"
|
||||||
|
echo -e "${BLUE}Start time:${RESET} ${start_time:-<full video>}"
|
||||||
|
echo -e "${BLUE}End time:${RESET} ${end_time:-<full video>}"
|
||||||
|
if [ "$mp3_only" = "yes" ]; then
|
||||||
|
echo -e "${BLUE}Format:${RESET} MP3 audio only"
|
||||||
|
echo -e "${BLUE}Merge format:${RESET} N/A (audio only)"
|
||||||
|
else
|
||||||
|
echo -e "${BLUE}Format:${RESET} ${format_selector:-<default>}"
|
||||||
|
echo -e "${BLUE}Merge format:${RESET} ${merge_format:-<auto>}"
|
||||||
|
fi
|
||||||
|
echo -e "${BLUE}Force keyframes:${RESET} ${force_key:-n}"
|
||||||
|
|
||||||
|
echo -e "\n${YELLOW}Options:${RESET}"
|
||||||
|
echo "1) Edit URL"
|
||||||
|
echo "2) Edit cookies"
|
||||||
|
echo "3) Edit start/end times"
|
||||||
|
echo "4) Edit format"
|
||||||
|
echo "5) Edit merge format"
|
||||||
|
echo "6) Toggle force-keyframes"
|
||||||
|
echo "r) Re-run all prompts with current values pre-filled"
|
||||||
|
echo "run) Proceed to download (or just press Enter)"
|
||||||
|
echo "q) Quit without running"
|
||||||
|
read -p "Choose option: " review_opt
|
||||||
|
|
||||||
|
review_opt="${review_opt#"${review_opt%%[![:space:]]*}"}"
|
||||||
|
review_opt="${review_opt%"${review_opt##*[![:space:]]}"}"
|
||||||
|
|
||||||
|
case "$review_opt" in
|
||||||
|
1) url=$(colored_read "${BLUE}New URL:${RESET}" "$url") ;;
|
||||||
|
2)
|
||||||
|
select_cookies
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
start_time=$(colored_read "${BLUE}New start time (empty=keep):${RESET}" "$start_time")
|
||||||
|
end_time=$(colored_read "${BLUE}New end time (empty=keep):${RESET}" "$end_time")
|
||||||
|
if [ -n "$start_time" ] && ! is_valid_time_format "$start_time"; then start_time=""; fi
|
||||||
|
if [ -n "$end_time" ] && ! is_valid_time_format "$end_time"; then end_time=""; fi
|
||||||
|
if [ -n "$start_time" ] && [ -n "$end_time" ]; then
|
||||||
|
ssec=$(time_to_seconds "$start_time")
|
||||||
|
esec=$(time_to_seconds "$end_time")
|
||||||
|
if [ "$ssec" -ge "$esec" ]; then
|
||||||
|
echo -e "${RED}Start must be before end. Cleared.${RESET}"
|
||||||
|
start_time=""; end_time=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
echo "Format presets (same as before)..."
|
||||||
|
format_choice=$(colored_read "${BLUE}New format choice 1-6 or custom:${RESET}" "")
|
||||||
|
mp3_only=""
|
||||||
|
case "$format_choice" in
|
||||||
|
1) format_selector='bv+ba/b' ;;
|
||||||
|
2) format_selector='bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]' ;;
|
||||||
|
3) format_selector='bv*+ba/b' ;;
|
||||||
|
4) format_selector='bv,ba' ;;
|
||||||
|
5)
|
||||||
|
custom_f=$(colored_read "${BLUE}Enter full -f string:${RESET}" "")
|
||||||
|
format_selector="$custom_f"
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
format_selector='bestaudio/best'
|
||||||
|
mp3_only="yes"
|
||||||
|
;;
|
||||||
|
*) if [ -n "$format_choice" ]; then format_selector="$format_choice"; fi ;;
|
||||||
|
esac
|
||||||
|
if [ "$mp3_only" = "yes" ]; then
|
||||||
|
merge_format=""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
if [ "$mp3_only" = "yes" ]; then
|
||||||
|
echo -e "${YELLOW}Merge format not applicable for MP3 audio only.${RESET}"
|
||||||
|
else
|
||||||
|
merge_format=$(colored_read "${BLUE}New merge format (avi/flv/mkv/mov/mp4/webm):${RESET}" "$merge_format")
|
||||||
|
if [ -n "$merge_format" ] && ! validate_merge_format "$merge_format"; then
|
||||||
|
echo -e "${RED}Invalid. Cleared.${RESET}"
|
||||||
|
merge_format=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
if [[ "$force_key" =~ ^[Yy]$ ]]; then
|
||||||
|
force_key="n"; force=""
|
||||||
|
else
|
||||||
|
force_key="y"; force="--force-keyframes-at-cuts"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
echo -e "${YELLOW}Re-running all questions with current values...${RESET}"
|
||||||
|
collect_inputs
|
||||||
|
;;
|
||||||
|
run|"")
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
echo -e "${RED}Aborted.${RESET}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*) echo -e "${RED}Invalid choice.${RESET}" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
url=""
|
||||||
|
cookies=""
|
||||||
|
start_time=""
|
||||||
|
end_time=""
|
||||||
|
format_selector=""
|
||||||
|
mp3_only=""
|
||||||
|
merge_format=""
|
||||||
|
force=""
|
||||||
|
force_key="n"
|
||||||
|
|
||||||
|
collect_inputs
|
||||||
|
review_and_confirm
|
||||||
|
build_command
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}${BOLD}Final command:${RESET}"
|
||||||
|
echo -e "${CYAN}yt-dlp${RESET} \c"
|
||||||
|
printf '%q ' "${cmd_args[@]}"
|
||||||
|
echo -e "${RESET}\n"
|
||||||
|
|
||||||
|
if ! command -v yt-dlp >/dev/null 2>&1; then
|
||||||
|
echo -e "${RED}Error: yt-dlp not found in PATH.${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "Run now? (y/n): " confirm_run
|
||||||
|
confirm_run="${confirm_run//[[:space:]]/}"
|
||||||
|
if [[ "$confirm_run" =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${GREEN}Starting download...${RESET}"
|
||||||
|
yt-dlp "${cmd_args[@]}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Command prepared but not executed.${RESET}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
main
|
||||||
|
fi
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Discord
|
||||||
|
StartupWMClass=discord
|
||||||
|
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
|
||||||
|
GenericName=Internet Messenger
|
||||||
|
Exec=/usr/bin/discord --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto --url -- %u
|
||||||
|
Icon=discord
|
||||||
|
Type=Application
|
||||||
|
Categories=Network;InstantMessaging;
|
||||||
|
MimeType=x-scheme-handler/discord;
|
||||||
|
Path=/usr/bin
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=FlClashX
|
|
||||||
Exec=~/apps/FlClashX.AppImage
|
|
||||||
Categories=Utility
|
|
||||||
Terminal=false
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=osu!lazer
|
Name=osu!lazer
|
||||||
Exec=~/apps/osu/osu.AppImage %u
|
Exec=/home/benq/apps/osu/osu.AppImage %u
|
||||||
Icon=x-osu-lazer
|
Icon=osu-lazer
|
||||||
Categories=Game
|
Categories=Game
|
||||||
Terminal=false
|
Terminal=false
|
||||||
MimeType=application/x-osu-lazer;
|
MimeType=application/x-osu-lazer;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Winbox
|
||||||
|
Exec=env QT_QPA_PLATFORM=xcb sh -c '"$HOME/apps/WinBox/WinBox" "$@"' _ %U
|
||||||
|
Type=Application
|
||||||
|
Categories=Network;
|
||||||
|
Terminal=false
|
||||||
+2
-5
@@ -1,5 +1,2 @@
|
|||||||
export PATH="$HOME/.local/bin:$PATH"
|
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
||||||
export ZSH="$HOME/.config/zsh/.oh-my-zsh"
|
[[ -r $ZDOTDIR/.zshenv ]] && . $ZDOTDIR/.zshenv
|
||||||
export ZDOTDIR="$HOME/.config/zsh"
|
|
||||||
export EDITOR="nvim"
|
|
||||||
export TERM="kitty"
|
|
||||||
Reference in new issue
Block a user