Set up for laptop docking
This commit is contained in:
+42
-10
@@ -1,15 +1,47 @@
|
|||||||
-- See https://wiki.hyprland.org/Configuring/Monitors/
|
-- See https://wiki.hyprland.org/Configuring/Monitors/
|
||||||
-- List current monitors and resolutions possible: hyprctl monitors
|
-- List current monitors and resolutions possible: hyprctl monitors
|
||||||
|
|
||||||
hl.monitor({
|
hl.monitor {
|
||||||
output = "desc:Samsung Electric Company LU28R55 HNMN500475",
|
output = 'desc:Samsung Electric Company LU28R55 HNMN500475',
|
||||||
mode = "3840x2160",
|
mode = '3840x2160',
|
||||||
position = "auto-left",
|
position = '0x0',
|
||||||
scale = 1.5,
|
scale = 1.5,
|
||||||
})
|
}
|
||||||
hl.monitor({
|
hl.monitor {
|
||||||
output = "desc:Samsung Electric Company LU28R55 HNMN500462",
|
output = 'desc:Samsung Electric Company LU28R55 HNMN500462',
|
||||||
mode = "3840x2160",
|
mode = '3840x2160',
|
||||||
position = "auto-right",
|
position = '2560x0',
|
||||||
scale = 1.5,
|
scale = 1.5,
|
||||||
})
|
}
|
||||||
|
hl.monitor {
|
||||||
|
output = 'desc:BOE NE160QDM-NZ6',
|
||||||
|
mode = '2560x1600',
|
||||||
|
position = '5120x720',
|
||||||
|
scale = 'auto',
|
||||||
|
}
|
||||||
|
|
||||||
|
hl.monitor { output = '', mode = 'preferred', position = 'auto', scale = 1 }
|
||||||
|
|
||||||
|
local function is_lid_closed()
|
||||||
|
local file = io.open('/proc/acpi/button/lid/LID0/state', 'r')
|
||||||
|
|
||||||
|
if not file then
|
||||||
|
file = io.open('/proc/acpi/button/lid/LID/state', 'r')
|
||||||
|
end
|
||||||
|
|
||||||
|
if file then
|
||||||
|
local state = file:read '*a'
|
||||||
|
file:close()
|
||||||
|
return string.find(state, 'closed') ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_lid_closed() then
|
||||||
|
hl.monitor {
|
||||||
|
output = 'desc:BOE NE160QDM-NZ6',
|
||||||
|
disabled = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
+43
-23
@@ -1,9 +1,9 @@
|
|||||||
local workspace_map = {
|
local workspace_map = {
|
||||||
"Home",
|
'Home',
|
||||||
"Dev",
|
'Dev',
|
||||||
"Art",
|
'Art',
|
||||||
"Gaming",
|
'Gaming',
|
||||||
"Writing",
|
'Writing',
|
||||||
}
|
}
|
||||||
|
|
||||||
local function setup_monitors()
|
local function setup_monitors()
|
||||||
@@ -16,44 +16,64 @@ local function setup_monitors()
|
|||||||
local monitor = monitors[j]
|
local monitor = monitors[j]
|
||||||
-- local workspace_id = "name:" .. workspace_map[i] .. "_" .. j
|
-- local workspace_id = "name:" .. workspace_map[i] .. "_" .. j
|
||||||
local workspace_id = (i - 1) * monitor_count + j
|
local workspace_id = (i - 1) * monitor_count + j
|
||||||
local workspace_name = workspace_map[i] .. "_" .. j
|
local workspace_name = workspace_map[i] .. '_' .. j
|
||||||
hl.workspace_rule({
|
hl.workspace_rule {
|
||||||
-- workspace = (i - 1) * monitor_count + j,
|
-- workspace = (i - 1) * monitor_count + j,
|
||||||
-- default_name = workspace_name,
|
-- default_name = workspace_name,
|
||||||
workspace = "name:" .. workspace_name,
|
workspace = 'name:' .. workspace_name,
|
||||||
monitor = monitor.name,
|
monitor = monitor.name,
|
||||||
default = i == 1,
|
default = i == 1,
|
||||||
})
|
}
|
||||||
|
|
||||||
hl.bind(
|
hl.bind(
|
||||||
"SUPER + code:1" .. (i - 1),
|
'SUPER + code:1' .. (i - 1),
|
||||||
hl.dsp.focus({ workspace = "name:" .. workspace_name }),
|
hl.dsp.focus { workspace = 'name:' .. workspace_name },
|
||||||
{ description = "Switch to workspace " .. workspace_map[i] }
|
{ description = 'Switch to workspace ' .. workspace_map[i] }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
hl.bind("SUPER + SHIFT + code:1" .. (i - 1), function()
|
hl.bind('SUPER + SHIFT + code:1' .. (i - 1), function()
|
||||||
local active_window = hl.get_active_window()
|
local active_window = hl.get_active_window()
|
||||||
local active_workspace = active_window.workspace
|
local active_workspace = active_window.workspace
|
||||||
local active_workspace_name = active_workspace.name
|
local active_workspace_name = active_workspace.name
|
||||||
local monitor_suffix = active_workspace_name:match("_(%d+)$") or "1"
|
local monitor_suffix = active_workspace_name:match '_(%d+)$' or '1'
|
||||||
local new_workspace = "name:" .. workspace_map[i] .. "_" .. monitor_suffix
|
local new_workspace = 'name:' .. workspace_map[i] .. '_' .. monitor_suffix
|
||||||
-- local new_workspace = (i - 1) * monitor_count + active_workspace.id
|
-- local new_workspace = (i - 1) * monitor_count + active_workspace.id
|
||||||
hl.dispatch(hl.dsp.window.move({ workspace = new_workspace, window = active_window, follow = false }))
|
hl.dispatch(hl.dsp.window.move { workspace = new_workspace, window = active_window, follow = false })
|
||||||
end, { description = "Move window to workspace " .. workspace_map[i] })
|
end, { description = 'Move window to workspace ' .. workspace_map[i] })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- A hack to move to the Home workspace when Hyprland first loads
|
-- A hack to move to the Home workspace when Hyprland first loads
|
||||||
for j = monitor_count, 1, -1 do
|
for j = monitor_count, 1, -1 do
|
||||||
if hl.get_workspaces()[j].id > 0 and monitor_count == 2 then
|
if hl.get_workspaces()[j].id > 0 and monitor_count == 2 then
|
||||||
hl.dispatch(hl.dsp.focus({ workspace = "name:Home_" .. j }))
|
hl.dispatch(hl.dsp.focus { workspace = 'name:Home_' .. j })
|
||||||
end
|
end
|
||||||
for k, window in pairs(hl.get_windows({ workspace = j })) do
|
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 }))
|
hl.dispatch(hl.dsp.window.move { window = window, workspace = 'name:Home_1', follow = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
hl.on("monitor.added", setup_monitors)
|
hl.on('monitor.added', setup_monitors)
|
||||||
hl.on("monitor.removed", setup_monitors)
|
hl.on('monitor.removed', setup_monitors)
|
||||||
hl.on("config.reloaded", setup_monitors)
|
hl.on('config.reloaded', setup_monitors)
|
||||||
|
|
||||||
|
hl.bind('switch:off:Lid Switch', setup_monitors)
|
||||||
|
hl.bind('switch:on:Lid Switch', setup_monitors)
|
||||||
|
|
||||||
|
hl.bind('switch:off:Lid Switch', function()
|
||||||
|
hl.monitor {
|
||||||
|
output = 'desc:BOE NE160QDM-NZ6',
|
||||||
|
disabled = false,
|
||||||
|
}
|
||||||
|
setup_monitors()
|
||||||
|
end)
|
||||||
|
|
||||||
|
hl.bind('switch:on:Lid Switch', function()
|
||||||
|
hl.monitor {
|
||||||
|
output = 'desc:BOE NE160QDM-NZ6',
|
||||||
|
disabled = true,
|
||||||
|
}
|
||||||
|
setup_monitors()
|
||||||
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user