From ed77c543ddbe672d1f9f3987ac74d17c0d1bf1fd Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 17 Jan 2025 20:05:31 +0800 Subject: [PATCH] fix: Linux compatibility --- mount.yazi/main.lua | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mount.yazi/main.lua b/mount.yazi/main.lua index de0ae47..12235d6 100644 --- a/mount.yazi/main.lua +++ b/mount.yazi/main.lua @@ -43,7 +43,7 @@ local M = { { on = "", run = "right" }, { on = "m", run = "mount" }, - { on = "M", run = "umount" }, + { on = "M", run = "unmount" }, { on = "e", run = "eject" }, }, } @@ -126,8 +126,8 @@ function M:entry(job) break elseif run == "mount" then self.operate("mount") - elseif run == "umount" then - self.operate("umount") + elseif run == "unmount" then + self.operate("unmount") elseif run == "eject" then self.operate("eject") end @@ -145,7 +145,7 @@ function M:redraw() if p.sub == "" then rows[#rows + 1] = ui.Row { p.main } else - rows[#rows + 1] = ui.Row { p.sub, p.label, p.dist or "", p.fstype } + rows[#rows + 1] = ui.Row { p.sub, p.label or "", p.dist or "", p.fstype or "" } end end @@ -172,17 +172,19 @@ end function M.obtain() local tbl = {} - local last = { false, nil } + local last for _, p in ipairs(fs.partitions()) do - local main, sub = p.src:match("^(/dev/disk%d+)(.*)$") - if sub == "" then - p.main, p.sub, last = main, sub, { true, p } - elseif not p.fstype then + local main, sub + if ya.target_os() == "macos" then + main, sub = p.src:match("^(/dev/disk%d+)(.+)$") else - if last[1] then - tbl[#tbl + 1], last[1] = last[2], false + main, sub = p.src:match("^(/dev/[a-z]+[a-z])(%d+)$") + end + if sub then + if last ~= main then + last, tbl[#tbl + 1] = main, { src = main, main = main, sub = "" } end - p.main, p.sub, tbl[#tbl + 1] = last[2].main, " " .. sub, p + p.main, p.sub, tbl[#tbl + 1] = main, " " .. sub, p end end table.sort(tbl, function(a, b) @@ -200,7 +202,7 @@ function M.operate(type) if not active then return elseif active.sub == "" then - return -- TODO: mount/umount main disk + return -- TODO: mount/unmount main disk end local output, err