diff options
Diffstat (limited to 'scroll')
| -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 | 
