From d231e9de9c3243ab18c81e1df381ee7103f68344 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 28 Nov 2024 11:25:04 +0200 Subject: [PATCH] Update: 2024-11-28 --- config/hypr/hyprland.conf | 2 + config/shell/aliasrc | 1 + config/shell/env | 4 + config/x11/opt-apps | 2 +- config/yazi/package.toml | 32 ++--- .../yazi/plugins/hide-preview.yazi/README.md | 2 + .../yazi/plugins/max-preview.yazi/README.md | 2 + .../DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY | 0 config/yazi/plugins/mediainfo.yazi/LICENSE | 19 +++ config/yazi/plugins/mediainfo.yazi/README.md | 22 ++++ config/yazi/plugins/mediainfo.yazi/init.lua | 111 ++++++++++++++++++ .../plugins/relative-motions.yazi/init.lua | 2 +- 12 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 config/yazi/plugins/mediainfo.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY create mode 100644 config/yazi/plugins/mediainfo.yazi/LICENSE create mode 100644 config/yazi/plugins/mediainfo.yazi/README.md create mode 100644 config/yazi/plugins/mediainfo.yazi/init.lua diff --git a/config/hypr/hyprland.conf b/config/hypr/hyprland.conf index 549f2e40..5918610b 100644 --- a/config/hypr/hyprland.conf +++ b/config/hypr/hyprland.conf @@ -16,6 +16,8 @@ monitor=DP-1,disable # See https://wiki.hyprland.org/Configuring/Keywords/ for more +env = HYPRLAND_INSTANCE_SIGNATURE,/tmp/hypr + # Execute your favorite apps at launch # exec-once = waybar & hyprpaper & firefox exec-once = pipewire & pipewire-pulse & wireplumber & eww daemon & eww open bar & nextcloud & /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & xrdb "$XDG_CONFIG_HOME/x11/xresources" & spotifyd --no-daemon & syncthing & transmission-daemon & dunst & dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP DISPLAY XAUTHORITY & hyprpaper diff --git a/config/shell/aliasrc b/config/shell/aliasrc index b9650778..e4f60c54 100644 --- a/config/shell/aliasrc +++ b/config/shell/aliasrc @@ -41,6 +41,7 @@ alias \ j="joshutoub" \ lf="lfub" \ lg="lazygit" \ + lzd="lazydocker" \ lock="swaylock" \ night="redshift -PO 4500" \ py="python" \ diff --git a/config/shell/env b/config/shell/env index dfbea133..ff8db2b1 100644 --- a/config/shell/env +++ b/config/shell/env @@ -38,6 +38,10 @@ export XDG_RUNTIME_DIR="$HOME/.cache/xdgr" export XDG_STATE_HOME="$HOME/.local/share" export HYPRSHOT_DIR="$HOME/Pictures/screenshots" +# export XDG_CURRENT_DESKTOP=Hyprland +# export XDG_SESSION_TYPE=wayland +# export XDG_SESSION_DESKTOP=Hyprland +# export HYPRLAND_INSTANCE_SIGNATURE=/tmp/hypr export ANDROID_HOME="$XDG_CONFIG_HOME/android" diff --git a/config/x11/opt-apps b/config/x11/opt-apps index 93404d01..3e4d8a57 100755 --- a/config/x11/opt-apps +++ b/config/x11/opt-apps @@ -1,6 +1,6 @@ #!/bin/sh -autostart="picom nextcloud discord transmission-daemon floorp discord syncthing mullvad-vpn spotify-launcher set-animated-bg" +autostart="picom nextcloud discord transmission-daemon floorp discord syncthing mullvad-vpn spotify-launcher" for program in $autostart; do pidof -sx "$program" || "$program" & diff --git a/config/yazi/package.toml b/config/yazi/package.toml index 22a98256..912a8b7c 100644 --- a/config/yazi/package.toml +++ b/config/yazi/package.toml @@ -1,21 +1,21 @@ [plugin] deps = [ - {use = "AnirudhG07/nbpreview", rev = "2d24602" }, - {use = "Reledia/glow", rev = "388e847" }, - {use = "Reledia/hexyl", rev = "ccc0a4a" }, - {use = "Reledia/miller", rev = "40e0265" }, - {use = "Sonico98/exifaudio", rev = "855ff05" }, - {use = "dedukun/relative-motions", rev = "1d6d686" }, - {use = "hankertrix/augment-command", rev = "fe145ac" }, - {use = "imsi32/yatline", rev = "e255f5c" }, - {use = "kirasok/torrent-preview", rev = "76970b6" }, - {use = "ndtoan96/ouch", rev = "db14883" }, - {use = "pirafrank/what-size", rev = "f08f7f2" }, - {use = "yazi-rs/plugins:chmod", rev = "776b160" }, - {use = "yazi-rs/plugins:full-border", rev = "776b160" }, - {use = "yazi-rs/plugins:git", rev = "776b160" }, - {use = "yazi-rs/plugins:hide-preview", rev = "776b160" }, - {use = "yazi-rs/plugins:max-preview", rev = "776b160" }, + {use = "AnirudhG07/nbpreview", rev = "2d24602"}, + {use = "Reledia/glow", rev = "388e847"}, + {use = "Reledia/hexyl", rev = "ccc0a4a"}, + {use = "Reledia/miller", rev = "40e0265"}, + {use = "Sonico98/exifaudio", rev = "855ff05"}, + {use = "dedukun/relative-motions", rev = "44c4c1c"}, + {use = "hankertrix/augment-command", rev = "fe145ac"}, + {use = "imsi32/yatline", rev = "e255f5c"}, + {use = "kirasok/torrent-preview", rev = "76970b6"}, + {use = "ndtoan96/ouch", rev = "db14883"}, + {use = "pirafrank/what-size", rev = "f08f7f2"}, + {use = "yazi-rs/plugins:chmod", rev = "d85bfd6"}, + {use = "yazi-rs/plugins:full-border", rev = "d85bfd6"}, + {use = "yazi-rs/plugins:git", rev = "d85bfd6"}, + {use = "yazi-rs/plugins:hide-preview", rev = "d85bfd6"}, + {use = "yazi-rs/plugins:max-preview", rev = "d85bfd6"}, ] [flavor] diff --git a/config/yazi/plugins/hide-preview.yazi/README.md b/config/yazi/plugins/hide-preview.yazi/README.md index 67fc777b..6fcd1517 100644 --- a/config/yazi/plugins/hide-preview.yazi/README.md +++ b/config/yazi/plugins/hide-preview.yazi/README.md @@ -18,6 +18,8 @@ Add this to your `~/.config/yazi/keymap.toml`: [[manager.prepend_keymap]] on = "T" run = "plugin --sync hide-preview" +# For upcoming Yazi 0.4 (nightly version): +# run = "plugin hide-preview" desc = "Hide or show preview" ``` diff --git a/config/yazi/plugins/max-preview.yazi/README.md b/config/yazi/plugins/max-preview.yazi/README.md index 439309ad..c5ef10bb 100644 --- a/config/yazi/plugins/max-preview.yazi/README.md +++ b/config/yazi/plugins/max-preview.yazi/README.md @@ -18,6 +18,8 @@ Add this to your `~/.config/yazi/keymap.toml`: [[manager.prepend_keymap]] on = "T" run = "plugin --sync max-preview" +# For upcoming Yazi 0.4 (nightly version): +# run = "plugin max-preview" desc = "Maximize or restore preview" ``` diff --git a/config/yazi/plugins/mediainfo.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY b/config/yazi/plugins/mediainfo.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY new file mode 100644 index 00000000..e69de29b diff --git a/config/yazi/plugins/mediainfo.yazi/LICENSE b/config/yazi/plugins/mediainfo.yazi/LICENSE new file mode 100644 index 00000000..0399f1c2 --- /dev/null +++ b/config/yazi/plugins/mediainfo.yazi/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2024 Lauri Niskanen + +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. diff --git a/config/yazi/plugins/mediainfo.yazi/README.md b/config/yazi/plugins/mediainfo.yazi/README.md new file mode 100644 index 00000000..4958f86f --- /dev/null +++ b/config/yazi/plugins/mediainfo.yazi/README.md @@ -0,0 +1,22 @@ +# mediainfo.yazi + +This is a Yazi plugin for previewing media files. The preview shows thumbnail +using `ffmpegthumbnailer` if available and media metadata using `mediainfo`. + +## Installation + +Install the plugin: + +``` +ya pack -a Ape/mediainfo +``` + +Create `~/.config/yazi/yazi.toml` and add: + +``` +[plugin] +prepend_previewers = [ + { mime = "{image,audio,video}/*", run = "mediainfo"}, + { mime = "application/x-subrip", run = "mediainfo"}, +] +``` diff --git a/config/yazi/plugins/mediainfo.yazi/init.lua b/config/yazi/plugins/mediainfo.yazi/init.lua new file mode 100644 index 00000000..aa74285c --- /dev/null +++ b/config/yazi/plugins/mediainfo.yazi/init.lua @@ -0,0 +1,111 @@ +local 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, +} + +local M = {} + +function M:peek() + local image_height = 0 + + if self:preload() == 1 then + local cache = ya.file_cache(self) + if cache and fs.cha(cache).length > 0 then + image_height = ya.image_show(cache, self.area).h + end + end + + local cmd = "mediainfo" + local output, code = Command(cmd) + :args({ tostring(self.file.url) }) + :stdout(Command.PIPED) + :output() + + local lines = {} + + if output then + local i = 0 + for str in output.stdout:gmatch("[^\n]*") do + local label, value = str:match("(.*[^ ]) +: (.*)") + local line + + if label then + if not skip_labels[label] then + line = ui.Line({ + ui.Span(label .. ": "):bold(), + ui.Span(value), + }) + end + elseif str ~= "General" then + line = ui.Line({ ui.Span(str):underline() }) + end + + if line then + if i >= self.skip then + table.insert(lines, line) + end + + local max_width = math.max(1, self.area.w - 3) + i = i + math.max(1, math.ceil(line:width() / max_width)) + end + end + else + local error = string.format("Spawn `%s` command returns %s", cmd, code) + table.insert(lines, ui.Line(error)) + end + + ya.preview_widgets(self, { + ui.Paragraph( + ui.Rect({ + x = self.area.x, + y = self.area.y + image_height, + w = self.area.w, + h = self.area.h - image_height, + }), + lines + ):wrap(ui.Paragraph.WRAP), + }) +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + math.max(0, cx.active.preview.skip + step), + only_if = self.file.url, + }) + end +end + +function M:preload() + local cache = ya.file_cache(self) + if not cache or fs.cha(cache) then + return 1 + end + + local cmd = "ffmpegthumbnailer" + local child, code = Command(cmd):args({ + "-q", "6", + "-c", "jpeg", + "-i", tostring(self.file.url), + "-o", tostring(cache), + "-t", "5", + "-s", tostring(PREVIEW.max_width), + }):spawn() + + if not child then + ya.err(string.format("spawn `%s` command returns %s", cmd, code)) + return 0 + end + + local status = child:wait() + return status and status.success and 1 or 2 +end + +return M diff --git a/config/yazi/plugins/relative-motions.yazi/init.lua b/config/yazi/plugins/relative-motions.yazi/init.lua index 4b06fb2d..ef14623e 100644 --- a/config/yazi/plugins/relative-motions.yazi/init.lua +++ b/config/yazi/plugins/relative-motions.yazi/init.lua @@ -214,7 +214,7 @@ return { local initial_value -- this is checking if the argument is a valid number - if args then + if #args > 0 then initial_value = tostring(tonumber(args[1])) if initial_value == "nil" then return