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