Test from chmod plugin

This commit is contained in:
2025-11-03 12:05:46 +01:00
parent 9d2b727810
commit b26f1ba07e

View File

@@ -15,34 +15,18 @@ return {
entry = function() entry = function()
ya.emit("escape", { visual = true }) ya.emit("escape", { visual = true })
ya.notify{title = "NOTI", content = "okay", level = "info"}
local urls = selected_or_hovered() local urls = selected_or_hovered()
if #urls == 0 then if #urls == 0 then
return ya.notify { title = "GPG Encrypt", content = "No file selected", level = "warn", timeout = 5 } return ya.notify { title = "Gpg", content = "No file selected", level = "warn", timeout = 5 }
end end
local status, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg("jonashahn1@gmx.net"):arg(urls[1]):arg("--encrypt"):arg(urls[1] .. ".gpg"):spawn():wait()
if not status or not status.success then
ya.notify{title = "NOTI", content = "okay", level = "info"} ya.notify {
for _, file_path in ipairs(urls) do title = "Chmod",
local gpg_file = file_path .. ".gpg" content = string.format("Chmod on selected files failed, error: %s", status and status.code or err),
ya.notify{title = "NOTI", content = file_path, level = "info"} level = "error",
local status, err = Command("gpg"):arg("--yes"):arg("--batch"):arg("--recipient"):arg("jonashahn1@gmx.net") timeout = 5,
:arg(gpg_file):arg("--encrypt"):arg(file_path):spawn():wait() }
if not status or not status.success then
ya.notify {
title = "GPG Encrypt",
content = string.format("Encryption failed for %s: %s", file_path, status and status.code or err),
level = "error",
timeout = 5,
}
else
os.remove(file_path)
end
end end
ya.refresh()
ya.notify { title = "GPG Encrypt", content = "Encryption complete", level = "info", timeout = 3 }
end, end,
} }