-- Example binds, see https://wiki.hypr.land/Configuring/Basics/Binds/ for more
-- closeWindowBind:set_enabled(false)
local mainMod = "SUPER" -- Sets "Windows" key as main modifier
local prefix = "app2unit -S out -- "
local fileManager = "dolphin"

-- Zachjittery
hl.bind(mainMod .. " + CTRL + RETURN", hl.dsp.exec_cmd("zshell-cli shell call visibilities toggleLauncher ''"))
-- hl.bind(mainMod .. " + CTRL + RETURN", hl.dsp.global("zshell:toggle-launcher"))
hl.bind(mainMod .. " + RETURN", hl.dsp.exec_cmd(prefix .. "zterm"))

-- QML
hl.bind("CTRL + mouse:274", hl.dsp.exec_cmd("ideskpet toggle-region"))
hl.bind("SHIFT + mouse:274", hl.dsp.exec_cmd("ideskpet toggle-layer"))
hl.bind(mainMod .. " + Z", hl.dsp.exec_cmd("ideskpet cycle-zindex"))

-- Apps
hl.bind(mainMod .. " + C", hl.dsp.exec_cmd(prefix .. "Telegram"))
hl.bind(mainMod .. " + V", hl.dsp.exec_cmd(prefix .. "discord"))
hl.bind(mainMod .. " + B", hl.dsp.exec_cmd(prefix .. "librewolf"))
hl.bind(mainMod .. " + S", hl.dsp.exec_cmd(prefix .. "spotify-launcher"))
hl.bind(mainMod .. " + X", hl.dsp.exec_cmd("SDL_VIDEODRIVER='x11' " .. prefix .. "osu-lazer"))
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager))

-- Media
hl.bind(mainMod .. " + F1", hl.dsp.exec_cmd("playerctl play-pause"))
hl.bind(mainMod .. " + F2", hl.dsp.exec_cmd("playerctl previous"))
hl.bind(mainMod .. " + F3", hl.dsp.exec_cmd("playerctl next"))
hl.bind("PRINT", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"))
hl.bind("code:51", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"))
hl.bind("code:121", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"))
hl.bind("code:122", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02-"))
hl.bind("code:123", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02+ --limit 1.0"))

-- Basic Bitch Stuff
hl.bind(mainMod .. " + Q", hl.dsp.window.close())
hl.bind(mainMod .. " + CTRL + Q", hl.dsp.exec_cmd("systemctl poweroff"))
hl.bind(mainMod .. " + T", hl.dsp.window.float({ action = "toggle" }))
hl.bind(mainMod .. " + K", hl.dsp.layout("swapsplit"))
hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit"))
hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen())
hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + up", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" }))
hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.resize({ x = 100, y = 0, relative = true }))
hl.bind(mainMod .. " + SHIFT + left", hl.dsp.window.resize({ x = -100, y = 0, relative = true }))
hl.bind(mainMod .. " + SHIFT + down", hl.dsp.window.resize({ x = 0, y = 100, relative = true }))
hl.bind(mainMod .. " + SHIFT + up", hl.dsp.window.resize({ x = 0, y = -100, relative = true }))
hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })

-- Workspaces
-- hl.bind("code:113", hl.dsp.focus({ workspace = "m+1" }))
-- hl.bind("code:114", hl.dsp.focus({ workspace = "m-1" }))
hl.bind("ALT + TAB", hl.dsp.focus({ workspace = "m+1" }))
hl.bind(mainMod .. " + TAB", hl.dsp.focus({ workspace = "m-1" }))
hl.bind(mainMod .. " + CTRL + left", hl.dsp.window.swap({ direction = "left" }))
hl.bind(mainMod .. " + CTRL + right", hl.dsp.window.swap({ direction = "right" }))
hl.bind(mainMod .. " + CTRL + up", hl.dsp.window.swap({ direction = "up" }))
hl.bind(mainMod .. " + CTRL + down", hl.dsp.window.swap({ direction = "down" }))

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, follow = true }))
	hl.bind(mainMod .. " + CTRL + " .. key, hl.dsp.window.move({ workspace = i, follow = false }))
end
