mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update 2026-01-27
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
--- @since 25.5.31
|
||||
--- @since 25.12.29
|
||||
|
||||
local toggle_ui = ya.sync(function(self)
|
||||
if self.children then
|
||||
@@ -7,12 +7,7 @@ local toggle_ui = ya.sync(function(self)
|
||||
else
|
||||
self.children = Modal:children_add(self, 10)
|
||||
end
|
||||
-- TODO: remove this
|
||||
if ui.render then
|
||||
ui.render()
|
||||
else
|
||||
ya.render()
|
||||
end
|
||||
ui.render()
|
||||
end)
|
||||
|
||||
local subscribe = ya.sync(function(self)
|
||||
@@ -23,12 +18,7 @@ end)
|
||||
local update_partitions = ya.sync(function(self, partitions)
|
||||
self.partitions = partitions
|
||||
self.cursor = math.max(0, math.min(self.cursor or 0, #self.partitions - 1))
|
||||
-- TODO: remove this
|
||||
if ui.render then
|
||||
ui.render()
|
||||
else
|
||||
ya.render()
|
||||
end
|
||||
ui.render()
|
||||
end)
|
||||
|
||||
local active_partition = ya.sync(function(self) return self.partitions[self.cursor + 1] end)
|
||||
@@ -39,12 +29,7 @@ local update_cursor = ya.sync(function(self, cursor)
|
||||
else
|
||||
self.cursor = ya.clamp(0, self.cursor + cursor, #self.partitions - 1)
|
||||
end
|
||||
-- TODO: remove this
|
||||
if ui.render then
|
||||
ui.render()
|
||||
else
|
||||
ya.render()
|
||||
end
|
||||
ui.render()
|
||||
end)
|
||||
|
||||
local M = {
|
||||
@@ -272,24 +257,33 @@ function M.operate(type)
|
||||
return -- TODO: mount/unmount main disk
|
||||
end
|
||||
|
||||
local output, err
|
||||
local cmd
|
||||
if ya.target_os() == "macos" then
|
||||
output, err = Command("diskutil"):arg({ type, active.src }):output()
|
||||
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()
|
||||
output, err = Command("eject"):arg({ "--traytoggle", active.src }):output()
|
||||
cmd = Command("eject"):arg { "--traytoggle", active.src }
|
||||
elseif type == "eject" then
|
||||
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
|
||||
output, err = Command("udisksctl"):arg({ "power-off", "-b", active.src }):output()
|
||||
cmd = Command("udisksctl"):arg { "power-off", "-b", active.src }
|
||||
else
|
||||
output, err = Command("udisksctl"):arg({ type, "-b", active.src }):output()
|
||||
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
|
||||
M.fail("Failed to %s `%s`: %s", type, active.src, err)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user