Files
dotfiles/.config/hypr/helpers.lua
T
2026-09-02 14:30:16 +01:00

78 lines
1.6 KiB
Lua

DEFAULT_LAYOUT = 'master'
exec = hl.dsp.exec_cmd
shortcut = hl.dsp.send_shortcut
function bind(key, cmd, desc, opts)
opts = opts or {}
opts.desc = desc
hl.bind(key, cmd, opts)
end
function bindl(key, cmd, desc, opts)
opts = opts or {}
opts.locked = true
bind(key, cmd, desc, opts)
end
function bindlr(key, cmd, desc, opts)
opts = opts or {}
opts.repeating = true
bindl(key, cmd, desc, opts)
end
function notify(text, duration)
hl.notification.create { text = text, duration = duration or 2000 }
end
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
function toggle_laptop_monitor()
hl.monitor {
output = 'desc:BOE NE160QDM-NZ6',
disabled = is_lid_closed(),
}
end
function get_current_layout()
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 'master'
end
return workspace.tiled_layout
end
function get_active_workspace()
local workspace = hl.get_active_workspace()
if hl.get_active_special_workspace() then
workspace = hl.get_active_special_workspace()
end
return workspace
end
function is_laptop_screen_focused()
local monitor = hl.get_active_monitor()
return monitor and monitor.description == 'BOE NE160QDM-NZ6'
end