Refactoring

This commit is contained in:
2026-09-02 14:30:16 +01:00
parent 20b2a45e60
commit cefbbbc575
8 changed files with 112 additions and 128 deletions
-3
View File
@@ -176,7 +176,6 @@ hl.window_rule {
hl.window_rule { hl.window_rule {
name = 'retroarch-fullscreen', name = 'retroarch-fullscreen',
fullscreen = true, fullscreen = true,
workspace = 'name:Gaming_1',
tag = '-default-opacity', tag = '-default-opacity',
opacity = '1 1', opacity = '1 1',
idle_inhibit = 'fullscreen', idle_inhibit = 'fullscreen',
@@ -233,7 +232,6 @@ hl.window_rule {
-- name = 'steam-float', -- name = 'steam-float',
-- float = true, -- float = true,
-- no_initial_focus = true, -- no_initial_focus = true,
-- workspace = 'name:Gaming_1',
-- idle_inhibit = 'fullscreen', -- idle_inhibit = 'fullscreen',
-- match = { -- match = {
-- class = 'steam', -- class = 'steam',
@@ -267,7 +265,6 @@ hl.window_rule {
hl.window_rule { hl.window_rule {
name = 'atlauncher-float', name = 'atlauncher-float',
float = true, float = true,
workspace = 'name:Gaming_1',
center = true, center = true,
size = { 1100, 700 }, size = { 1100, 700 },
tag = '-default-opacity', tag = '-default-opacity',
+13 -9
View File
@@ -1,12 +1,16 @@
hl.on('hyprland.start', function() hl.on('hyprland.start', function()
hl.exec_cmd 'uwsm-app -- hypridle' exec 'uwsm-app -- hypridle'
hl.exec_cmd 'uwsm-app -- mako' exec 'uwsm-app -- mako'
hl.exec_cmd 'uwsm-app -- fcitx5 --disable notificationitem' exec 'uwsm-app -- fcitx5 --disable notificationitem'
hl.exec_cmd 'uwsm-app -- Enpass -minimize' exec 'uwsm-app -- Enpass -minimize'
hl.exec_cmd 'uwsm-app -- steam' exec 'uwsm-app -- steam'
hl.exec_cmd 'nextcloud' exec 'nextcloud'
hl.exec_cmd 'station-bg-random' exec 'station-bg-random'
hl.exec_cmd '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1' exec '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
hl.exec_cmd 'dbus-update-activation-environment --systemd --all' exec 'dbus-update-activation-environment --systemd --all'
end)
hl.on('config.reloaded', function()
toggle_laptop_monitor()
end) end)
+1 -37
View File
@@ -1,34 +1,10 @@
require 'helpers'
-- ========================== -- ==========================
-- Media -- Media
-- ========================== -- ==========================
-- Only display the OSD on the currently focused monitor -- Only display the OSD on the currently focused monitor
local osdclient = 'swayosd-client --monitor "$(hyprctl monitors -j | jq -r \'.[] | select(.focused == true).name\')"' local osdclient = 'swayosd-client --monitor "$(hyprctl monitors -j | jq -r \'.[] | select(.focused == true).name\')"'
local exec = hl.dsp.exec_cmd
local shortcut = hl.dsp.send_shortcut
local function bind(key, cmd, desc, opts)
opts = opts or {}
opts.desc = desc
hl.bind(key, cmd, opts)
end
local function bindl(key, cmd, desc, opts)
opts = opts or {}
opts.locked = true
bind(key, cmd, desc, opts)
end
local function bindlr(key, cmd, desc, opts)
opts = opts or {}
opts.repeating = true
bindl(key, cmd, desc, opts)
end
local function notify(text)
hl.notification.create { text = text, duration = 2000 }
end
-- Laptop multimedia keys for volume and LCD brightness (with OSD) -- Laptop multimedia keys for volume and LCD brightness (with OSD)
bindlr('XF86AudioRaiseVolume', exec(osdclient .. ' --output-volume raise'), 'Volume up') bindlr('XF86AudioRaiseVolume', exec(osdclient .. ' --output-volume raise'), 'Volume up')
bindlr('XF86AudioRaiseVolume', exec(osdclient .. ' --output-volume raise'), 'Volume up') bindlr('XF86AudioRaiseVolume', exec(osdclient .. ' --output-volume raise'), 'Volume up')
@@ -118,18 +94,6 @@ bind('SUPER + CTRL + L', function()
notify('󱂬 Workspace layout set to ' .. next_layout) notify('󱂬 Workspace layout set to ' .. next_layout)
end, 'Toggle workspace layout') end, 'Toggle workspace layout')
local get_current_layout = 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 'dwindle'
end
return workspace.tiled_layout
end
-- Move focus with SUPER + arrow keys -- Move focus with SUPER + arrow keys
bind('SUPER + H', function() bind('SUPER + H', function()
if get_current_layout() == 'monocle' then if get_current_layout() == 'monocle' then
+77
View File
@@ -0,0 +1,77 @@
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
+10 -8
View File
@@ -1,8 +1,10 @@
require("autostart") require 'helpers'
require("workspaces") require 'autostart'
require("bindings") require 'workspaces'
require("envs") require 'bindings'
require("looknfeel") require 'envs'
require("input") require 'looknfeel'
require("windows") require 'input'
require("monitors") require 'windows'
require 'monitors'
+1 -1
View File
@@ -26,7 +26,7 @@ hl.config {
allow_tearing = false, allow_tearing = false,
-- layout = scrolling, # Change to niri-like side-scrolling layout -- layout = scrolling, # Change to niri-like side-scrolling layout
layout = 'dwindle', layout = 'master',
}, },
-- https://wiki.hyprland.org/Configuring/Variables/#decoration -- https://wiki.hyprland.org/Configuring/Variables/#decoration
-23
View File
@@ -22,26 +22,3 @@ hl.monitor {
hl.monitor { output = '', mode = 'preferred', position = 'auto', scale = 1 } 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
function toggleLaptopMonitor()
hl.monitor {
output = 'desc:BOE NE160QDM-NZ6',
disabled = not is_lid_closed(),
}
end
+9 -46
View File
@@ -7,6 +7,8 @@ local workspace_map = {
} }
local function setup_monitors() local function setup_monitors()
toggle_laptop_monitor()
local monitors = hl.get_monitors() local monitors = hl.get_monitors()
local monitor_count = #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 }) 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
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 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', function() hl.bind('switch:off:Lid Switch', setup_monitors)
hl.monitor { hl.bind('switch:on:Lid Switch', setup_monitors)
output = 'desc:BOE NE160QDM-NZ6',
disabled = false,
}
setup_monitors()
end)
hl.bind('switch:on:Lid Switch', function() function set_laptop_workspace_to_monocle()
hl.monitor { local workspace = get_active_workspace()
output = 'desc:BOE NE160QDM-NZ6',
disabled = true,
}
setup_monitors()
end)
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 if not workspace then
return return
end end
local monitor = hl.get_active_monitor() if is_laptop_screen_focused() then
if monitor.description == 'BOE NE160QDM-NZ6' then
hl.workspace_rule { workspace = 'name:' .. tostring(workspace.name), layout = 'monocle' } 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 end
local monitor = hl.get_active_monitor() hl.on('monitor.focused', set_laptop_workspace_to_monocle)
if monitor.description == 'BOE NE160QDM-NZ6' then hl.on('config.reloaded', set_laptop_workspace_to_monocle)
hl.workspace_rule { workspace = 'name:' .. tostring(workspace.name), layout = 'monocle' }
end
end)