local awful = require("awful")
local naughty = require("naughty")
local session_type = os.getenv("XDG_SESSION_TYPE");

if session_type == nil or session_type == "" then
    session_type = "x11"
end

function decode_clipboard_x11()
    naughty.notify({ text = "Decoding PGP message" })
    awful.spawn.with_shell("xclip -selection clipboard -out | sed 's/^ *//g' | gpg2 -d | gvim -")
end

function decode_clipboard_wayland()
    -- TODO: Implement this when needed. wl-clipboard can be used here
end

function decode_clipboard()
    if session_type == "x11" then
        decode_clipboard_x11()
    else
        decode_clipboard_wayland()
    end
end
