Refactoring
This commit is contained in:
@@ -176,7 +176,6 @@ hl.window_rule {
|
||||
hl.window_rule {
|
||||
name = 'retroarch-fullscreen',
|
||||
fullscreen = true,
|
||||
workspace = 'name:Gaming_1',
|
||||
tag = '-default-opacity',
|
||||
opacity = '1 1',
|
||||
idle_inhibit = 'fullscreen',
|
||||
@@ -233,7 +232,6 @@ hl.window_rule {
|
||||
-- name = 'steam-float',
|
||||
-- float = true,
|
||||
-- no_initial_focus = true,
|
||||
-- workspace = 'name:Gaming_1',
|
||||
-- idle_inhibit = 'fullscreen',
|
||||
-- match = {
|
||||
-- class = 'steam',
|
||||
@@ -267,7 +265,6 @@ hl.window_rule {
|
||||
hl.window_rule {
|
||||
name = 'atlauncher-float',
|
||||
float = true,
|
||||
workspace = 'name:Gaming_1',
|
||||
center = true,
|
||||
size = { 1100, 700 },
|
||||
tag = '-default-opacity',
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
hl.on('hyprland.start', function()
|
||||
hl.exec_cmd 'uwsm-app -- hypridle'
|
||||
hl.exec_cmd 'uwsm-app -- mako'
|
||||
hl.exec_cmd 'uwsm-app -- fcitx5 --disable notificationitem'
|
||||
hl.exec_cmd 'uwsm-app -- Enpass -minimize'
|
||||
hl.exec_cmd 'uwsm-app -- steam'
|
||||
hl.exec_cmd 'nextcloud'
|
||||
hl.exec_cmd 'station-bg-random'
|
||||
hl.exec_cmd '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
|
||||
hl.exec_cmd 'dbus-update-activation-environment --systemd --all'
|
||||
exec 'uwsm-app -- hypridle'
|
||||
exec 'uwsm-app -- mako'
|
||||
exec 'uwsm-app -- fcitx5 --disable notificationitem'
|
||||
exec 'uwsm-app -- Enpass -minimize'
|
||||
exec 'uwsm-app -- steam'
|
||||
exec 'nextcloud'
|
||||
exec 'station-bg-random'
|
||||
exec '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
|
||||
exec 'dbus-update-activation-environment --systemd --all'
|
||||
end)
|
||||
|
||||
hl.on('config.reloaded', function()
|
||||
toggle_laptop_monitor()
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,34 +1,10 @@
|
||||
require 'helpers'
|
||||
-- ==========================
|
||||
-- Media
|
||||
-- ==========================
|
||||
-- Only display the OSD on the currently focused monitor
|
||||
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)
|
||||
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)
|
||||
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
|
||||
bind('SUPER + H', function()
|
||||
if get_current_layout() == 'monocle' then
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
require("autostart")
|
||||
require("workspaces")
|
||||
require("bindings")
|
||||
require("envs")
|
||||
require("looknfeel")
|
||||
require("input")
|
||||
require("windows")
|
||||
require("monitors")
|
||||
require 'helpers'
|
||||
require 'autostart'
|
||||
require 'workspaces'
|
||||
require 'bindings'
|
||||
require 'envs'
|
||||
require 'looknfeel'
|
||||
require 'input'
|
||||
require 'windows'
|
||||
require 'monitors'
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ hl.config {
|
||||
allow_tearing = false,
|
||||
|
||||
-- layout = scrolling, # Change to niri-like side-scrolling layout
|
||||
layout = 'dwindle',
|
||||
layout = 'master',
|
||||
},
|
||||
|
||||
-- https://wiki.hyprland.org/Configuring/Variables/#decoration
|
||||
|
||||
@@ -22,26 +22,3 @@ hl.monitor {
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
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
|
||||
|
||||
local monitor = hl.get_active_monitor()
|
||||
hl.on('monitor.focused', set_laptop_workspace_to_monocle)
|
||||
|
||||
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