From 208a0ff78229e85a4a6ae448aac3c54686ca0585 Mon Sep 17 00:00:00 2001 From: ZachIR Date: Sat, 26 Jul 2025 13:00:36 -0500 Subject: Add bare bones of window swallowing to scroll --- scroll/scripts/swallow.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scroll/scripts/swallow.lua (limited to 'scroll/scripts') diff --git a/scroll/scripts/swallow.lua b/scroll/scripts/swallow.lua new file mode 100644 index 0000000..5760886 --- /dev/null +++ b/scroll/scripts/swallow.lua @@ -0,0 +1,32 @@ +local function candidate(view) + local app_id = scroll.view_get_app_id(view) + if app_id == "mpv" then + local pview = scroll.view_get_parent_view(view) + if pview ~= nil and pview ~= view then + local papp_id = scroll.view_get_app_id(pview) + if papp_id == "kitty" then + return scroll.view_get_container(pview) + end + end + end + return nil +end + +local function on_create(view, _) + local parent = candidate(view) + if parent ~= nil then + scroll.command(parent, "move scratchpad") + end +end + +local function on_destroy(view, _) + local parent = candidate(view) + if parent ~= nil then + scroll.command(nil, "scratchpad show; floating toggle") + end +end + +scroll.add_callback("view_map", on_create, nil) +scroll.add_callback("view_unmap", on_destroy, nil) + + -- cgit v1.2.3 From b35c7ad4db8e604f109f4857a4ed5a1c236caf30 Mon Sep 17 00:00:00 2001 From: ZachIR Date: Sat, 26 Jul 2025 13:00:57 -0500 Subject: Add most scratchpads to scroll --- scroll/config | 32 ++++++++++++++++++++++++++++++++ scroll/scripts/scratchpad.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 scroll/scripts/scratchpad.lua (limited to 'scroll/scripts') diff --git a/scroll/config b/scroll/config index 3c8b0c3..2b18e24 100644 --- a/scroll/config +++ b/scroll/config @@ -499,6 +499,38 @@ bindgesture swipe:4:up scale_workspace overview # Enable window swallowing (of mpv specifically) lua $home/.config/scroll/scripts/swallow.lua +# Scratchpads +for_window [app_id="sphtop"] move scratchpad +for_window [app_id="sphtop"] scratchpad show +bindsym $mod+Ctrl+z lua $home/.config/scroll/scripts/scratchpad.lua sphtop htop +for_window [app_id="spterm"] move scratchpad +for_window [app_id="spterm"] scratchpad show +bindsym $mod+Ctrl+x lua $home/.config/scroll/scripts/scratchpad.lua spterm +for_window [app_id="sppmxr"] move scratchpad +for_window [app_id="sppmxr"] scratchpad show +bindsym $mod+Ctrl+c lua $home/.config/scroll/scripts/scratchpad.lua sppmxr pulsemixer +for_window [app_id="spblue"] move scratchpad +for_window [app_id="spblue"] scratchpad show +bindsym $mod+Ctrl+v lua $home/.config/scroll/scripts/scratchpad.lua spblue bluetoothctl +for_window [app_id="spncmp"] move scratchpad +for_window [app_id="spncmp"] scratchpad show +bindsym $mod+Ctrl+b lua $home/.config/scroll/scripts/scratchpad.lua spncmp ncmpcpp +for_window [app_id="spmutt"] move scratchpad +for_window [app_id="spmutt"] scratchpad show +bindsym $mod+Ctrl+a lua $home/.config/scroll/scripts/scratchpad.lua spmutt neomutt +for_window [app_id="spprof"] move scratchpad +for_window [app_id="spprof"] scratchpad show +bindsym $mod+Ctrl+s lua $home/.config/scroll/scripts/scratchpad.lua spprof profanity +for_window [app_id="spirss"] move scratchpad +for_window [app_id="spirss"] scratchpad show +bindsym $mod+Ctrl+d lua $home/.config/scroll/scripts/scratchpad.lua spirss irssi +for_window [app_id="sptodo"] move scratchpad +for_window [app_id="sptodo"] scratchpad show +bindsym $mod+Ctrl+f lua $home/.config/scroll/scripts/scratchpad.lua sptodo todo +for_window [app_id="sptrmc"] move scratchpad +for_window [app_id="sptrmc"] scratchpad show +bindsym $mod+Ctrl+g lua $home/.config/scroll/scripts/scratchpad.lua sptrmc tremc + # # Workspace rules: # diff --git a/scroll/scripts/scratchpad.lua b/scroll/scripts/scratchpad.lua new file mode 100644 index 0000000..7e078d6 --- /dev/null +++ b/scroll/scripts/scratchpad.lua @@ -0,0 +1,41 @@ +local args, _ = ... +local id = "" +local spawn = "" + +for i, arg in ipairs(args) do + if i <= 1 then + id = arg + else + spawn = spawn .. " " .. arg + end +end + +local function exists(id) + local is_in_array = false + local cons = scroll.scratchpad_get_containers() + for _, con in ipairs(cons) do + local views = scroll.container_get_views(con) + for _, view in ipairs(views) do + local app_id = scroll.view_get_app_id(view) + if (app_id == id) then + is_in_array = true + end + end + end + return is_in_array +end + +local function is_focused(id) + local view = scroll.focused_view() + local app_id = scroll.view_get_app_id(view) + return app_id == id +end + +if (not exists(id)) then + scroll.command(nil, "exec kitty --class " .. id .. spawn) +end +if (is_focused(id)) then + scroll.command(nill, "scratchpad show") +else + scroll.command(nil, "[app_id=\"" .. id .. "\"] scratchpad show") +end -- cgit v1.2.3 From be4dc4fce70d7aeb4ddc986320468a834808adf8 Mon Sep 17 00:00:00 2001 From: ZachIR Date: Sat, 26 Jul 2025 13:39:28 -0500 Subject: Update scratchpad.lua to work with non-terminal apps --- scroll/scripts/scratchpad.lua | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'scroll/scripts') 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 -- cgit v1.2.3 From 4a433d5e3c2f9f1898e8c9652473e0b4de77f57f Mon Sep 17 00:00:00 2001 From: zachir Date: Sat, 26 Jul 2025 14:49:49 -0500 Subject: Add maximize lua script for scroll --- scroll/config | 3 +++ scroll/scripts/maximize.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 scroll/scripts/maximize.lua (limited to 'scroll/scripts') diff --git a/scroll/config b/scroll/config index c695d28..6655223 100644 --- a/scroll/config +++ b/scroll/config @@ -244,6 +244,9 @@ animations { bindsym $mod+Shift+f fullscreen_application toggle bindsym $mod+Ctrl+Alt+f fullscreen_application reset + # Maximize, not fullscreen + bindsym $mod+m lua $scripts/maximize.lua toggle + # Toggle the current focus between tiling and floating mode bindsym $mod+y focus mode_toggle # Toggle layout type (h<->v) diff --git a/scroll/scripts/maximize.lua b/scroll/scripts/maximize.lua new file mode 100644 index 0000000..f0df156 --- /dev/null +++ b/scroll/scripts/maximize.lua @@ -0,0 +1,42 @@ +local args, state = ... + +-- Set up views table +local views = scroll.state_get_value(state, "views") +if views == nil then + scroll.state_set_value(state, "views", {}) + views = scroll.state_get_value(state, "views") +end + +local function find_view(view) + for _, v in ipairs(views) do + if v["object"] == view then + return v + end + end + return nil +end + +if args[1] == 'toggle' then + local focused_view = scroll.focused_view() + local view = find_view(focused_view) + if view == nil then + view = { + object = focused_view, + maximized = false, + wf = 0, + hf = 0 + } + table.insert(views, view) + end + view["maximized"] = not view["maximized"] + if view["maximized"] then + local container = scroll.view_get_container(focused_view) + view["wf"] = scroll.container_get_width_fraction(container) + view["hf"] = scroll.container_get_height_fraction(container) + scroll.command(nil, "set_size h 1.0") + scroll.command(nil, "set_size v 1.0") + else + scroll.command(nil, "set_size h " .. view["wf"]) + scroll.command(nil, "set_size v " .. view["hf"]) + end +end -- cgit v1.2.3 From 15c221f1edd7b623edf4bcfb79ee2e993ca7d04c Mon Sep 17 00:00:00 2001 From: zachir Date: Mon, 28 Jul 2025 13:14:20 -0500 Subject: Remove debugging stuff from scratchpad.lua --- scroll/scripts/scratchpad.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'scroll/scripts') diff --git a/scroll/scripts/scratchpad.lua b/scroll/scripts/scratchpad.lua index 6972843..2235c33 100644 --- a/scroll/scripts/scratchpad.lua +++ b/scroll/scripts/scratchpad.lua @@ -11,7 +11,6 @@ for i, arg in ipairs(args) do terminal = true else command = arg - --terminal = true end elseif (terminal == true) then command = arg @@ -19,7 +18,6 @@ for i, arg in ipairs(args) do end end ---scroll.command(nil, "exec notify-send \"Spawn command\" \"" .. command .. "\"") local function exists(id) local is_in_array = false -- cgit v1.2.3 From 98d4473f1c9783c7bc8f01208f1996b2e40e53ce Mon Sep 17 00:00:00 2001 From: zachir Date: Mon, 28 Jul 2025 13:14:42 -0500 Subject: Add fallback to scrathpad.lua so command should always be defind --- scroll/scripts/scratchpad.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scroll/scripts') diff --git a/scroll/scripts/scratchpad.lua b/scroll/scripts/scratchpad.lua index 2235c33..e581cc1 100644 --- a/scroll/scripts/scratchpad.lua +++ b/scroll/scripts/scratchpad.lua @@ -6,6 +6,9 @@ local command = nil for i, arg in ipairs(args) do if i <= 1 then id = arg + if #args == 1 then + command = arg + end elseif i == 2 then if (arg == "kitty") then terminal = true @@ -18,6 +21,7 @@ for i, arg in ipairs(args) do end end +command = command or "kitty" local function exists(id) local is_in_array = false -- cgit v1.2.3 From 6e529ca13fd6c9f273cccce6d788c9940b473c6d Mon Sep 17 00:00:00 2001 From: ZachIR Date: Wed, 30 Jul 2025 02:42:52 -0500 Subject: Add maximize when only lua script for scroll --- scroll/config | 7 ++++++- scroll/scripts/maximize_when_only.lua | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 scroll/scripts/maximize_when_only.lua (limited to 'scroll/scripts') diff --git a/scroll/config b/scroll/config index 15c9f1d..889da2e 100644 --- a/scroll/config +++ b/scroll/config @@ -100,6 +100,8 @@ layout_heights [0.33333333 0.5 0.666666667 1.0] fullscreen_movefocus true +focus_follows_mouse yes + mouse_warping none # Animations @@ -511,7 +513,7 @@ bindsym $mod+Alt+comma exec dmount # Launch dmenuumount dmenu umount script bindsym $mod+Alt+period exec dmenuumount -focus_wrapping no +focus_wrapping yes bindgesture swipe:4:right workspace next bindgesture swipe:4:left workspace prev @@ -521,6 +523,9 @@ bindgesture swipe:4:up scale_workspace overview # Enable window swallowing (of mpv specifically) lua $scripts/swallow.lua +# Enable maximize when only +lua $scripts/maximize_when_only.lua + # Scratchpads for_window [app_id="sphtop"] move scratchpad for_window [app_id="sphtop"] scratchpad show diff --git a/scroll/scripts/maximize_when_only.lua b/scroll/scripts/maximize_when_only.lua new file mode 100644 index 0000000..a047180 --- /dev/null +++ b/scroll/scripts/maximize_when_only.lua @@ -0,0 +1,38 @@ +local args, state = ... + +local maximized_containers = scroll.state_get_value(state, "maximized_containers") or {} + +local debug_notify = function(msg) + scroll.command(nil, "exec notify-send " .. msg) +end + +local maximize_container = function(container, workspace) + local wf = scroll.container_get_width_fraction(container) + local hf = scroll.container_get_height_fraction(container) + maximized_containers[workspace] = { container = container, wf = wf, hf = hf, workspace = workspace } + scroll.state_set_value(state, "maximized_containers", maximized_containers) + scroll.command(container, "set_size h 1.0") + scroll.command(container, "set_size v 1.0") +end + +local maximize_when_only = function() + local focused_workspace = scroll.focused_workspace() + local containers = scroll.workspace_get_tiling(focused_workspace) + local focused_container = scroll.focused_container() + local maximized_container = maximized_containers[focused_workspace] + if #containers == 1 then + if not maximized_container or (maximized_container and maximized_container.container ~= focused_container) then + -- debug_notify("Maximizing") + maximize_container(focused_container, focused_workspace) + end + elseif #containers > 1 and maximized_container then + -- debug_notify("Shrinking") + scroll.command(maximized_container.container, "set_size h " .. maximized_container.wf) + scroll.command(maximized_container.container, "set_size v " .. maximized_container.hf) + maximized_containers[focused_workspace] = nil + scroll.state_set_value(state, "maximized_containers", maximized_containers) + end + scroll.command(focused_container, "nop") +end + +scroll.add_callback("view_focus", maximize_when_only, nil) -- cgit v1.2.3