-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide recycle bin, or user defined folders #52
Comments
A simple addon like this should work: local fb_utils = require 'modules.utils'
local valid_dir = fb_utils.valid_dir
fb_utils.valid_dir = function(name)
if name == "$RECYCLE.BIN/" then return false end
return valid_dir(name)
end
return { version = "1.1.0" } Edit: updated with the version number for future compatibility Edit: updated 2024-01-08 to work with new file-browser internal changes (#100) |
Thanks, it works. Maybe also add a conf option |
I'd rather something like that be implemented as an addon. The whole reason I designed the addon system was to avoid feature creep bloating the main script. I might look into it when I have some free time, but if you really want it you're welcome to write the addon yourself. I recently updated the documentation with code examples, which might make it easier to understand. You're also welcome to ask any questions. |
To give a bit of an idea, something along these lines would probably work: local fb = require "file-browser"
local parser = {
priority = 10,
version = "1.1.0"
}
local function filter(path)
-- do filtering here
end
function parser:can_parse()
return true
end
function parser:parse(directory)
local list, opts = self:defer(directory)
if not list then return list, opts end
directory = opts.directory or directory
for i=#list, 1, -1 do
if filter( fb.get_full_path(list[i], directory) ) then
table.remove(list, i)
end
end
return list, opts
end
return parser Disclaimer: I wrote this very quickly from memory and have done no testing whatsoever |
I had some time so here is a full implementation of an addon that allows you to filter any arbitrary path by changing a config file: local fb = require "file-browser"
local opt = require "mp.options"
local o = {
--list of absolute paths separated by the root separators
paths = ""
}
--config file stored in ~~/script-opts/file-browser/filter.conf
opt.read_options(o, "file-browser/filter")
local parser = {
priority = 10,
version = "1.3.0"
}
local paths = {}
for str in fb.iterate_opt(o.paths) do
paths[str] = true
end
local function filter(path)
return paths[path]
end
function parser:can_parse()
return true
end
function parser:parse(directory)
local list, opts = self:defer(directory)
if not list then return list, opts end
directory = opts.directory or directory
for i=#list, 1, -1 do
if filter( fb.get_full_path(list[i], directory) ) then
table.remove(list, i)
end
end
return list, opts
end
return parser If you want to make it more user friendly then you'll have to do so yourself. |
I would like to request hiding the recycle bin:
E:\$RECYCLE.BIN
The text was updated successfully, but these errors were encountered: