summaryrefslogtreecommitdiff
path: root/mpv/scripts/file-browser/modules/addons/home-label.lua
diff options
context:
space:
mode:
authorryukamish <[email protected]>2026-04-11 16:06:45 +0530
committerryukamish <[email protected]>2026-04-11 16:06:45 +0530
commit607891801fbf2051a0c9062d15a445dd238c1e1b (patch)
tree33b8cfba2355b498addea05e385b06d46cced30f /mpv/scripts/file-browser/modules/addons/home-label.lua
parent6fbde2906e3bb2d4d1df23f6374d8a6a0aef870f (diff)
add: mako and mpv configs
Diffstat (limited to 'mpv/scripts/file-browser/modules/addons/home-label.lua')
-rw-r--r--mpv/scripts/file-browser/modules/addons/home-label.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/mpv/scripts/file-browser/modules/addons/home-label.lua b/mpv/scripts/file-browser/modules/addons/home-label.lua
new file mode 100644
index 0000000..5e6cf8e
--- /dev/null
+++ b/mpv/scripts/file-browser/modules/addons/home-label.lua
@@ -0,0 +1,31 @@
+--[[
+ An addon for mpv-file-browser which displays ~/ for the home directory instead of the full path
+]]--
+
+local mp = require "mp"
+local fb = require "file-browser"
+
+local home = fb.fix_path(mp.command_native({"expand-path", "~/"}) --[[@as string]], true)
+
+---@type ParserConfig
+local home_label = {
+ priority = 100,
+ api_version = "1.0.0"
+}
+
+function home_label:can_parse(directory)
+ if not fb.get_opt('home_label') then return false end
+ return directory:sub(1, home:len()) == home
+end
+
+---@async
+function home_label:parse(directory)
+ local list, opts = self:defer(directory)
+ if not opts then opts = {} end
+ if (not opts.directory or opts.directory == directory) and not opts.directory_label then
+ opts.directory_label = "~/"..(directory:sub(home:len()+1) or "")
+ end
+ return list, opts
+end
+
+return home_label \ No newline at end of file