-
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
Detect Directory Automatically ? #71
Comments
Normally you would need to do it manually or use the mpv-user-input dialogue box to open the drive directly. But here is an addon I quickly wrote that will add drives to the root automatically: --[[
Automatically populates the root with windows drives on startup.
Ctrl+r will add new drives mounted since startup.
Drives will only be added if they are not already present in the root.
]]
local mp = require 'mp'
local msg = require 'mp.msg'
local fb = require 'file-browser'
local function get_drives()
local result = mp.command_native({
name = 'subprocess',
playback_only = false,
capture_stdout = true,
args = {'wmic', 'logicaldisk', 'get', 'caption'}
})
if result.status ~= 0 then return msg.error('could not read windows root') end
local root = {}
for drive in result.stdout:gmatch("%a:") do
table.insert(root, drive..'/')
end
return root
end
local function in_root(drive, root)
for _, item in ipairs(root) do
if item.name == drive then return true end
end
return false
end
local function import_drives()
local drives = get_drives()
local root = fb.get_root()
for _, drive in ipairs(drives) do
if not in_root(drive, root) then
fb.insert_root_item({ name = drive })
end
end
end
local keybind = {
key = 'Ctrl+r',
name = 'import_root_drives',
command = import_drives,
parser = 'root',
passthrough = true
}
return {
version = '1.3.0',
setup = import_drives,
keybinds = { keybind }
}
Edit: add API version for the addon |
Thank you, will you be adding this officially to as addons ? |
No guarantees, but this seems useful enough that there is a good chance I will tidy it up and add it, yes. |
There is a small mistake. It should be:
|
Fixed, thanks. |
currently this has to be done
root=~/,C:/,D:/,E:/
, is there a way to automatically detect directory, like if a plug in a usb drive or external HDD later , will i have to add that drive letter file_browser.conf ?The text was updated successfully, but these errors were encountered: