Update 2026-03-13

This commit is contained in:
2026-03-13 14:57:50 +02:00
parent b97f7aaf4a
commit 75f8df8582
35 changed files with 2158 additions and 1134 deletions

View File

@@ -129,11 +129,11 @@ function M:entry(job)
if run == "quit" then
break
elseif run == "mount" then
self.operate("mount")
require(".cross").operate("mount", active_partition())
elseif run == "unmount" then
self.operate("unmount")
require(".cross").operate("unmount", active_partition())
elseif run == "eject" then
self.operate("eject")
require(".cross").operate("eject", active_partition())
end
until not run
end
@@ -249,48 +249,6 @@ function M.fillin(tbl)
return tbl
end
function M.operate(type)
local active = active_partition()
if not active then
return
elseif not active.sub then
return -- TODO: mount/unmount main disk
end
local cmd
if ya.target_os() == "macos" then
cmd = Command("diskutil"):arg { type, active.src }
end
if ya.target_os() == "linux" then
if type == "eject" and active.src:match("^/dev/sr%d+") then
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
cmd = Command("eject"):arg { "--traytoggle", active.src }
elseif type == "eject" then
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
cmd = Command("udisksctl"):arg { "power-off", "-b", active.src }
else
cmd = Command("udisksctl"):arg { type, "-b", active.src }
end
end
if not cmd then
return M.fail("mount.yazi is not currently supported on your platform")
end
local output, err = cmd:output()
if not output then
if cmd.program then
M.fail("Failed to spawn `%s`: %s", cmd.program, err)
else
M.fail("Failed to spawn `udisksctl`: %s", err) -- TODO: remove
end
elseif not output.status.success then
M.fail("Failed to %s `%s`: %s", type, active.src, output.stderr)
end
end
function M.fail(...) ya.notify { title = "Mount", content = string.format(...), timeout = 10, level = "error" } end
function M:click() end
function M:scroll() end