2024-01-14 06:15:14 +01:00
|
|
|
require("pinnacle").setup(function(Pinnacle)
|
|
|
|
local Input = Pinnacle.input
|
|
|
|
local Process = Pinnacle.process
|
|
|
|
local Output = Pinnacle.output
|
|
|
|
local Tag = Pinnacle.tag
|
|
|
|
local Window = Pinnacle.window
|
|
|
|
|
|
|
|
local key = Input.key
|
|
|
|
|
|
|
|
---@type Modifier
|
|
|
|
local mod_key = "ctrl"
|
|
|
|
|
|
|
|
local terminal = "alacritty"
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
--------------------
|
|
|
|
-- Mousebinds --
|
|
|
|
--------------------
|
|
|
|
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:mousebind({ mod_key }, "btn_left", "press", function()
|
|
|
|
Window:begin_move("btn_left")
|
2024-01-14 06:15:14 +01:00
|
|
|
end)
|
|
|
|
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:mousebind({ mod_key }, "btn_right", "press", function()
|
|
|
|
Window:begin_resize("btn_right")
|
2024-01-14 06:15:14 +01:00
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
--------------------
|
|
|
|
-- Keybinds --
|
|
|
|
--------------------
|
2024-01-14 06:15:14 +01:00
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + alt + q = Quit Pinnacle
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "alt" }, "q", function()
|
2024-01-14 06:15:14 +01:00
|
|
|
Pinnacle:quit()
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + alt + c = Close window
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "alt" }, "c", function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:close()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + alt + Return = Spawn `terminal`
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key }, key.Return, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
Process:spawn(terminal)
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + alt + space = Toggle floating
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "alt" }, key.space, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:toggle_floating()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + f = Toggle fullscreen
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key }, "f", function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:toggle_fullscreen()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + m = Toggle maximized
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key }, "m", function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:toggle_maximized()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
--------------------
|
|
|
|
-- Tags --
|
|
|
|
--------------------
|
|
|
|
|
2024-01-14 06:15:14 +01:00
|
|
|
local tag_names = { "1", "2", "3", "4", "5" }
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- `connect_for_all` is useful for performing setup on every monitor you have.
|
|
|
|
-- Here, we add tags with names 1-5 and set tag 1 as active.
|
2024-01-14 06:15:14 +01:00
|
|
|
Output:connect_for_all(function(op)
|
|
|
|
local tags = Tag:add(op, tag_names)
|
2024-01-13 04:48:07 +01:00
|
|
|
tags[1]:set_active(true)
|
|
|
|
end)
|
2024-01-14 06:15:14 +01:00
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- Spawning must happen after you add tags, as Pinnacle currently doesn't render windows without tags.
|
2024-01-16 21:23:18 +01:00
|
|
|
Process:spawn_once(terminal)
|
2024-01-14 06:15:14 +01:00
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- Create a layout cycler to cycle layouts on an output.
|
2024-01-14 06:15:14 +01:00
|
|
|
local layout_cycler = Tag:new_layout_cycler({
|
|
|
|
"master_stack",
|
|
|
|
"dwindle",
|
|
|
|
"spiral",
|
|
|
|
"corner_top_left",
|
|
|
|
"corner_top_right",
|
|
|
|
"corner_bottom_left",
|
|
|
|
"corner_bottom_right",
|
|
|
|
})
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + space = Cycle forward one layout on the focused output
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key }, key.space, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused_op = Output:get_focused()
|
|
|
|
if focused_op then
|
|
|
|
layout_cycler.next(focused_op)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2024-01-16 06:37:17 +01:00
|
|
|
-- mod_key + shift + space = Cycle backward one layout on the focused output
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "shift" }, key.space, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused_op = Output:get_focused()
|
|
|
|
if focused_op then
|
|
|
|
layout_cycler.prev(focused_op)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
for _, tag_name in ipairs(tag_names) do
|
|
|
|
-- nil-safety: tags are guaranteed to be on the outputs due to connect_for_all above
|
2024-01-16 06:37:17 +01:00
|
|
|
|
|
|
|
-- mod_key + 1-5 = Switch to tags 1-5
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key }, tag_name, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
Tag:get(tag_name):switch_to()
|
|
|
|
end)
|
2024-01-16 06:37:17 +01:00
|
|
|
|
|
|
|
-- mod_key + shift + 1-5 = Toggle tags 1-5
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "shift" }, tag_name, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
Tag:get(tag_name):toggle_active()
|
|
|
|
end)
|
2024-01-16 06:37:17 +01:00
|
|
|
|
|
|
|
-- mod_key + alt + 1-5 = Move window to tags 1-5
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "alt" }, tag_name, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:move_to_tag(Tag:get(tag_name) --[[@as TagHandle]])
|
|
|
|
end
|
|
|
|
end)
|
2024-01-16 06:37:17 +01:00
|
|
|
|
|
|
|
-- mod_key + shift + alt + 1-5 = Toggle tags 1-5 on window
|
2024-01-15 01:01:41 +01:00
|
|
|
Input:keybind({ mod_key, "shift", "alt" }, tag_name, function()
|
2024-01-14 06:15:14 +01:00
|
|
|
local focused = Window:get_focused()
|
|
|
|
if focused then
|
|
|
|
focused:toggle_tag(Tag:get(tag_name) --[[@as TagHandle]])
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
2024-01-13 04:48:07 +01:00
|
|
|
end)
|