diff --git a/hyprland.lua b/hyprland.lua index 37096fa..ddf92b2 100644 --- a/hyprland.lua +++ b/hyprland.lua @@ -125,18 +125,8 @@ local mainMod = "SUPER" -- Sets "Windows" key as main modifier -- Example binds, see https://wiki.hypr.land/Configuring/Basics/Binds/ for more -- Move focus with mainMod + arrow keys -hl.bind(mainMod .. " + h", hl.dsp.focus({ direction = "left" })) -hl.bind(mainMod .. " + l", hl.dsp.focus({ direction = "right" })) -hl.bind(mainMod .. " + k", hl.dsp.focus({ direction = "up" })) -hl.bind(mainMod .. " + j", hl.dsp.focus({ direction = "down" })) - -- Switch workspaces with mainMod + [0-9] -- Move active window to a workspace with mainMod + SHIFT + [0-9] -for i = 1, 10 do - local key = i % 10 -- 10 maps to key 0 - hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i })) - hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i })) -end -- Example special workspace (scratchpad) hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic")) diff --git a/modules/binds.lua b/modules/binds.lua index 862564b..09507ef 100644 --- a/modules/binds.lua +++ b/modules/binds.lua @@ -15,10 +15,10 @@ end -- Delete windows hl.bind(mainMod .. " + backspace", hl.dsp.window.close()) +-- If otter is open, focus it, if not make a new window hl.bind(mainMod .. "d", function() - hl.notification.create({ text = tostring(hl.get_windows({ class = "otter" })[1]), timeout = 3000, icon = "ok" }) if hl.get_windows({ class = "otter" })[1] ~= nil then - hl.dsp.focus({ window = { class = "otter" } }) + hl.dispatch(hl.dsp.focus({ window = "class:otter" })) else hl.exec_cmd("kitty --class otter --title otter-launcher -e sh -c 'sleep 0.05 && otter-launcher'") end @@ -51,4 +51,67 @@ for index, bind in ipairs(keyboardSplit) do hl.bind(mainMod .. "SHIFT + " .. bind, hl.dsp.window.move({ workspace = index, follow = false })) end +-- Music workspace +hl.bind(mainMod .. "m", hl.dsp.workspace.toggle_special("music")) + -- Move windows with hjkl +hl.bind(mainMod .. "SHIFT + h", hl.dsp.layout("swapcol l")) +hl.bind(mainMod .. "SHIFT + l", hl.dsp.layout("swapcol r")) +hl.bind(mainMod .. "k", hl.dsp.focus({ direction = "up" })) +hl.bind(mainMod .. "j", hl.dsp.focus({ direction = "down" })) + +-- Function to get window position relative to monitor +local function normalise_current_window_pos() + local active = hl.get_active_window() + if active then + local xpos = active.at.x + -- If on right monitor + if xpos > 1920 then + xpos = xpos - 1920 + return xpos + -- If on left monitor + elseif xpos < 1 then + xpos = xpos + 1920 + return xpos + else + return xpos + end + end +end + +hl.bind(mainMod .. "h", function() + local pos = normalise_current_window_pos() + if pos then + -- 9 derived from 5 gap plus 3 border (8), so first pixel of window is 9 + if pos == 9 then + -- If first window, then move to monitor to the left + hl.dispatch(hl.dsp.focus({ monitor = "-1" })) + end + end + hl.dispatch(hl.dsp.layout("move -col")) +end) + +hl.bind(mainMod .. "l", function() + -- Move before so you can detect if it is the last window + hl.dispatch(hl.dsp.layout("move +col")) + if not normalise_current_window_pos() then + -- Go back a window + hl.dispatch(hl.dsp.layout("move -col")) + -- Move to monitor to the right + hl.dispatch(hl.dsp.focus({ monitor = "+1" })) + end +end) + +-- Fullscreen with b +hl.bind(mainMod .. "b", hl.dsp.window.fullscreen({ action = "toggle" })) + +-- Special workspace +hl.bind(mainMod .. "minus", hl.dsp.workspace.toggle_special("scratch")) +hl.bind(mainMod .. "SHIFT + minus", hl.dsp.window.move({ workspace = "special:scratch", follow = false })) + +-- Float resize and move window with mouse +hl.bind(subMod .. "mouse:272", hl.dsp.window.drag(), { mouse = true, drag = true }) +hl.bind(subMod .. "mouse:272", hl.dsp.window.float(), { mouse = true, click = true }) +hl.bind(subMod .. "mouse:272", hl.dsp.layout("promote"), { mouse = true, release = true }) + +hl.bind(subMod .. "SHIFT + mouse:272", hl.dsp.window.resize(), { mouse = true }) diff --git a/modules/rules.lua b/modules/rules.lua new file mode 100644 index 0000000..d8c0114 --- /dev/null +++ b/modules/rules.lua @@ -0,0 +1,22 @@ +hl.window_rule({ + name = "otter-launcher", + match = { + class = "otter", + }, + float = true, + size = { 410, 220 }, + opaque = true, +}) + +hl.window_rule({ + name = "nodim-youtube", +}) + +hl.workspace_rule({ + workspace = "special:music", + gaps_out = { + left = 400, + right = 400, + bottom = 400, + }, +}) diff --git a/modules/settings/style.lua b/modules/settings/style.lua index 3a97fbc..55bac43 100644 --- a/modules/settings/style.lua +++ b/modules/settings/style.lua @@ -25,7 +25,7 @@ hl.config({ scrolling = { column_width = 0.8, follow_min_visible = 0.1, - focus_fit_method = 0, + focus_fit_method = 1, wrap_focus = false, wrap_swapcol = false, },