diff options
author | ZachIR <zachir@librem.one> | 2025-07-26 13:39:28 -0500 |
---|---|---|
committer | ZachIR <zachir@librem.one> | 2025-07-26 13:39:28 -0500 |
commit | be4dc4fce70d7aeb4ddc986320468a834808adf8 (patch) | |
tree | d649da5237bc42362efe6e1d037ae8a9e1e5a4cf /scroll/scripts/scratchpad.lua | |
parent | 3769b80f680ff0b9a5b9cae219d2dff5e5d49c28 (diff) |
Update scratchpad.lua to work with non-terminal apps
Diffstat (limited to 'scroll/scripts/scratchpad.lua')
-rw-r--r-- | scroll/scripts/scratchpad.lua | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/scroll/scripts/scratchpad.lua b/scroll/scripts/scratchpad.lua index 7e078d6..6972843 100644 --- a/scroll/scripts/scratchpad.lua +++ b/scroll/scripts/scratchpad.lua @@ -1,15 +1,26 @@ local args, _ = ... local id = "" -local spawn = "" +local terminal = false +local command = nil for i, arg in ipairs(args) do if i <= 1 then - id = arg - else - spawn = spawn .. " " .. arg + id = arg + elseif i == 2 then + if (arg == "kitty") then + terminal = true + else + command = arg + --terminal = true + end + elseif (terminal == true) then + command = arg + break end end +--scroll.command(nil, "exec notify-send \"Spawn command\" \"" .. command .. "\"") + local function exists(id) local is_in_array = false local cons = scroll.scratchpad_get_containers() @@ -31,11 +42,23 @@ local function is_focused(id) return app_id == id end +local function spawn(term, comm) + if (term) then + if (comm) then + scroll.command(nil, "exec kitty --class " .. id .. " -e " .. comm) + else + scroll.command(nil, "exec kitty --class " .. id) + end + else + scroll.command(nil, "exec " .. comm) + end +end + if (not exists(id)) then - scroll.command(nil, "exec kitty --class " .. id .. spawn) + spawn(terminal, command) end if (is_focused(id)) then - scroll.command(nill, "scratchpad show") + scroll.command(nil, "scratchpad show") else scroll.command(nil, "[app_id=\"" .. id .. "\"] scratchpad show") end |