Refactoring
This commit is contained in:
+10
-47
@@ -7,6 +7,8 @@ local workspace_map = {
|
||||
}
|
||||
|
||||
local function setup_monitors()
|
||||
toggle_laptop_monitor()
|
||||
|
||||
local monitors = hl.get_monitors()
|
||||
local monitor_count = #monitors
|
||||
|
||||
@@ -42,67 +44,28 @@ local function setup_monitors()
|
||||
hl.dispatch(hl.dsp.window.move { workspace = new_workspace, window = active_window, follow = false })
|
||||
end, { description = 'Move window to workspace ' .. workspace_map[i] })
|
||||
end
|
||||
|
||||
-- A hack to move to the Home workspace when Hyprland first loads
|
||||
for j = monitor_count, 1, -1 do
|
||||
if hl.get_workspaces()[j].id > 0 and monitor_count == 2 then
|
||||
hl.dispatch(hl.dsp.focus { workspace = 'name:Home_' .. j })
|
||||
end
|
||||
for k, window in pairs(hl.get_windows { workspace = j }) do
|
||||
hl.dispatch(hl.dsp.window.move { window = window, workspace = 'name:Home_1', follow = true })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hl.on('monitor.added', setup_monitors)
|
||||
hl.on('monitor.removed', setup_monitors)
|
||||
hl.on('config.reloaded', setup_monitors)
|
||||
|
||||
hl.bind('switch:off:Lid Switch', function()
|
||||
hl.monitor {
|
||||
output = 'desc:BOE NE160QDM-NZ6',
|
||||
disabled = false,
|
||||
}
|
||||
setup_monitors()
|
||||
end)
|
||||
hl.bind('switch:off:Lid Switch', setup_monitors)
|
||||
hl.bind('switch:on:Lid Switch', setup_monitors)
|
||||
|
||||
hl.bind('switch:on:Lid Switch', function()
|
||||
hl.monitor {
|
||||
output = 'desc:BOE NE160QDM-NZ6',
|
||||
disabled = true,
|
||||
}
|
||||
setup_monitors()
|
||||
end)
|
||||
function set_laptop_workspace_to_monocle()
|
||||
local workspace = get_active_workspace()
|
||||
|
||||
hl.on('monitor.focused', function()
|
||||
local workspace = hl.get_active_workspace()
|
||||
if hl.get_active_special_workspace() then
|
||||
workspace = hl.get_active_special_workspace()
|
||||
end
|
||||
if not workspace then
|
||||
return
|
||||
end
|
||||
|
||||
local monitor = hl.get_active_monitor()
|
||||
|
||||
if monitor.description == 'BOE NE160QDM-NZ6' then
|
||||
if is_laptop_screen_focused() then
|
||||
hl.workspace_rule { workspace = 'name:' .. tostring(workspace.name), layout = 'monocle' }
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
hl.on('config.reloaded', function()
|
||||
local workspace = hl.get_active_workspace()
|
||||
if hl.get_active_special_workspace() then
|
||||
workspace = hl.get_active_special_workspace()
|
||||
end
|
||||
if not workspace then
|
||||
return
|
||||
end
|
||||
hl.on('monitor.focused', set_laptop_workspace_to_monocle)
|
||||
|
||||
local monitor = hl.get_active_monitor()
|
||||
|
||||
if monitor.description == 'BOE NE160QDM-NZ6' then
|
||||
hl.workspace_rule { workspace = 'name:' .. tostring(workspace.name), layout = 'monocle' }
|
||||
end
|
||||
end)
|
||||
hl.on('config.reloaded', set_laptop_workspace_to_monocle)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user