This commit is contained in:
2025-11-03 11:57:22 +01:00
parent 9991032486
commit 8d141579c3
2 changed files with 40 additions and 49 deletions

View File

@@ -0,0 +1,3 @@
# Easy encryption with gpg for files
WARNING: This is not indented for public usage yet because it has some hardcoded things

View File

@@ -15,33 +15,21 @@ 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 Encrypt", content = "No file selected", level = "warn", timeout = 5 }
end end
-- Ask for GPG recipient
local recipient, event = ya.input {
title = "GPG Recipient:",
pos = { "top-center", y = 3, w = 50 },
}
if event ~= 1 or recipient == "" then
return
end
ya.notify{title = "NOTI", content = "okay", level = "info"}
for _, file_path in ipairs(urls) do for _, file_path in ipairs(urls) do
local gpg_file = file_path .. ".gpg" local gpg_file = file_path .. ".gpg"
local status, err = Command("gpg") ya.notify{title = "NOTI", content = file_path, level = "info"}
:arg("--yes") local status, err = Command("gpg"):arg("--yes"):arg("--batch"):arg("--recipient"):arg("jonashahn1@gmx.net")
:arg("--batch") :arg(gpg_file):arg("--encrypt"):arg(file_path):spawn():wait()
:arg("--recipient")
:arg(recipient)
:arg("--output")
:arg(gpg_file)
:arg("--encrypt")
:arg(file_path)
:spawn()
:wait()
if not status or not status.success then if not status or not status.success then
ya.notify { ya.notify {