From 9b7e3507d8eb47bba9de8cdc6df51e492164160b Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 30 Sep 2026 17:03:12 +0100 Subject: [PATCH] Refactoring --- .config/hypr/apps.lua | 19 ------ .config/hypr/autostart.lua | 12 +++- .config/hypr/bindings.lua | 37 ----------- .config/hypr/helpers.lua | 6 +- .config/hypr/hyprland.lua | 1 + .config/hypr/looknfeel.lua | 122 ++++++++++++++++++++++++++++++------ .config/hypr/monitors.lua | 6 +- .config/hypr/scratchpad.lua | 60 ++++++++++++++++++ .config/hypr/workspaces.lua | 28 +++++---- 9 files changed, 198 insertions(+), 93 deletions(-) create mode 100644 .config/hypr/scratchpad.lua diff --git a/.config/hypr/apps.lua b/.config/hypr/apps.lua index 47e85dc..7c11c86 100644 --- a/.config/hypr/apps.lua +++ b/.config/hypr/apps.lua @@ -165,25 +165,6 @@ hl.window_rule { }, } --- Scratchpad apps -hl.window_rule { - workspace = 'special:music', - match = { - class = 'Spotify|psysonic', - }, -} -hl.window_rule { - workspace = 'special:comms', - match = { - class = '^(chrome-discord.com__channels_@me-Default|chrome-web.whatsapp.com__-Default|signal)$', - }, -} -hl.window_rule { - workspace = 'special:prod', - match = { - class = '^(superproductivity|org.station.notes)$', - }, -} -- Float Nextcloud hl.window_rule { float = true, diff --git a/.config/hypr/autostart.lua b/.config/hypr/autostart.lua index 859d1cf..74164f5 100644 --- a/.config/hypr/autostart.lua +++ b/.config/hypr/autostart.lua @@ -6,6 +6,12 @@ hl.on('hyprland.start', function() exec '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1' exec 'dbus-update-activation-environment --systemd --all' exec 'station-bg-set' + -- hl.dispatch( + -- dispatch_exec( + -- 'station-launch-tui btop', + -- { move = { workspace = 'special:monitor' } } + -- ) + -- ) local monitors = hl.get_monitors() @@ -17,6 +23,10 @@ end) hl.on('config.reloaded', function() toggle_laptop_monitor() - exec 'station-bg-set' + + -- exec( + -- 'station-launch-tui btop', + -- { move = { workspace = 'special:monitor' } } + -- ) end) diff --git a/.config/hypr/bindings.lua b/.config/hypr/bindings.lua index c956a89..c20bbe7 100644 --- a/.config/hypr/bindings.lua +++ b/.config/hypr/bindings.lua @@ -232,43 +232,6 @@ bind( 'Move window down' ) --- Control scratchpad -bind( - 'SUPER + S', - hl.dsp.workspace.toggle_special 'scratchpad', - 'Toggle scratchpad' -) -bind( - 'SUPER + ALT + S', - hl.dsp.window.move { workspace = 'special:scratchpad' }, - 'Move window to scratchpad' -) -bind('SUPER + N', function() - hl.dispatch(hl.dsp.workspace.toggle_special 'prod') - local windows = hl.get_windows { workspace = 'special:prod' } - if #windows == 0 then - exec 'station-launch-or-focus ^superProductivity$ "uwsm-app -- super-productivity"' - exec 'uwsm-app -- xdg-terminal-exec --app-id=org.station.notes nvim ~/Notes' - end -end, 'Toggle productivity workspace') -bind('SUPER + M', function() - hl.dispatch(hl.dsp.workspace.toggle_special 'music') - local windows = hl.get_windows { workspace = 'special:music' } - if #windows == 0 then - exec 'station-launch-or-focus spotify' - exec 'station-launch-or-focus psysonic' - end -end, 'Toggle music workspace') -bind('SUPER + D', function() - hl.dispatch(hl.dsp.workspace.toggle_special 'comms') - local windows = hl.get_windows { workspace = 'special:comms' } - if #windows == 0 then - exec 'station-launch-or-focus ^signal$ "uwsm-app -- signal-desktop"' - exec 'station-launch-or-focus ^chrome-web.whatsapp.com__-Default$ "station-launch-webapp https://web.whatsapp.com"' - exec 'station-launch-or-focus ^chrome-discord.com__channels_@me-Default$ "station-launch-webapp https://discord.com/channels/@me"' - end -end, 'Toggle comms workspace') - -- Cycle through applications on active workspace bind( 'SUPER + TAB', diff --git a/.config/hypr/helpers.lua b/.config/hypr/helpers.lua index 9b3f884..5bac229 100644 --- a/.config/hypr/helpers.lua +++ b/.config/hypr/helpers.lua @@ -1,5 +1,9 @@ DEFAULT_LAYOUT = 'master' +LAPTOP_MONITOR_NAME = 'BOE NE160QDM-NZ6' +LEFT_MONITOR_NAME = 'Samsung Electric Company LU28R55 HNMN500475' +RIGHT_MONITOR_NAME = 'Samsung Electric Company LU28R55 HNMN500462' + dispatch_exec = hl.dsp.exec_cmd exec = hl.exec_cmd shortcut = hl.dsp.send_shortcut @@ -73,6 +77,6 @@ end function is_laptop_screen_focused() local monitor = hl.get_active_monitor() - return monitor and monitor.description == 'BOE NE160QDM-NZ6' + return monitor and monitor.description == LAPTOP_MONITOR_NAME end diff --git a/.config/hypr/hyprland.lua b/.config/hypr/hyprland.lua index 92698b0..808648f 100644 --- a/.config/hypr/hyprland.lua +++ b/.config/hypr/hyprland.lua @@ -7,4 +7,5 @@ require 'looknfeel' require 'input' require 'windows' require 'monitors' +require 'scratchpad' diff --git a/.config/hypr/looknfeel.lua b/.config/hypr/looknfeel.lua index cf4f914..95d485f 100644 --- a/.config/hypr/looknfeel.lua +++ b/.config/hypr/looknfeel.lua @@ -25,8 +25,7 @@ hl.config { -- Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on allow_tearing = false, - -- layout = scrolling, # Change to niri-like side-scrolling layout - layout = 'master', + layout = DEFAULT_LAYOUT, }, -- https://wiki.hyprland.org/Configuring/Variables/#decoration @@ -119,6 +118,7 @@ hl.config { cursor = { hide_on_key_press = true, warp_on_change_workspace = 1, + no_hardware_cursors = 1, }, -- Auto toggle scratchpad on switching workspace from scratchpad @@ -138,31 +138,115 @@ hl.config { } -- Default curves and animations, see https://wiki.hypr.land/Configuring/Advanced-and-Cool/Animations/ -hl.curve('easeOutQuint', { type = 'bezier', points = { { 0.23, 1 }, { 0.32, 1 } } }) -hl.curve('easeInOutCubic', { type = 'bezier', points = { { 0.65, 0.05 }, { 0.36, 1 } } }) +hl.curve( + 'easeOutQuint', + { type = 'bezier', points = { { 0.23, 1 }, { 0.32, 1 } } } +) +hl.curve( + 'easeInOutCubic', + { type = 'bezier', points = { { 0.65, 0.05 }, { 0.36, 1 } } } +) hl.curve('linear', { type = 'bezier', points = { { 0, 0 }, { 1, 1 } } }) -hl.curve('almostLinear', { type = 'bezier', points = { { 0.5, 0.5 }, { 0.75, 1 } } }) +hl.curve( + 'almostLinear', + { type = 'bezier', points = { { 0.5, 0.5 }, { 0.75, 1 } } } +) hl.curve('quick', { type = 'bezier', points = { { 0.15, 0 }, { 0.1, 1 } } }) -- Default springs -hl.curve('easy', { type = 'spring', mass = 1, stiffness = 71.2633, dampening = 15.8273644 }) +hl.curve( + 'easy', + { type = 'spring', mass = 1, stiffness = 71.2633, dampening = 15.8273644 } +) hl.animation { leaf = 'global', enabled = true, speed = 10, bezier = 'default' } -hl.animation { leaf = 'border', enabled = true, speed = 5.39, bezier = 'easeOutQuint' } +hl.animation { + leaf = 'border', + enabled = true, + speed = 5.39, + bezier = 'easeOutQuint', +} hl.animation { leaf = 'windows', enabled = true, speed = 4.79, spring = 'easy' } -hl.animation { leaf = 'windowsIn', enabled = true, speed = 4.1, spring = 'easy', style = 'popin 87%' } -hl.animation { leaf = 'windowsOut', enabled = true, speed = 1.49, bezier = 'linear', style = 'popin 87%' } -hl.animation { leaf = 'fadeIn', enabled = true, speed = 1.73, bezier = 'almostLinear' } -hl.animation { leaf = 'fadeOut', enabled = true, speed = 1.46, bezier = 'almostLinear' } +hl.animation { + leaf = 'windowsIn', + enabled = true, + speed = 4.1, + spring = 'easy', + style = 'popin 87%', +} +hl.animation { + leaf = 'windowsOut', + enabled = true, + speed = 1.49, + bezier = 'linear', + style = 'popin 87%', +} +hl.animation { + leaf = 'fadeIn', + enabled = true, + speed = 1.73, + bezier = 'almostLinear', +} +hl.animation { + leaf = 'fadeOut', + enabled = true, + speed = 1.46, + bezier = 'almostLinear', +} hl.animation { leaf = 'fade', enabled = true, speed = 3.03, bezier = 'quick' } -hl.animation { leaf = 'layers', enabled = true, speed = 3.81, bezier = 'easeOutQuint' } -hl.animation { leaf = 'layersIn', enabled = true, speed = 4, bezier = 'easeOutQuint', style = 'fade' } -hl.animation { leaf = 'layersOut', enabled = true, speed = 1.5, bezier = 'linear', style = 'fade' } -hl.animation { leaf = 'fadeLayersIn', enabled = true, speed = 1.79, bezier = 'almostLinear' } -hl.animation { leaf = 'fadeLayersOut', enabled = true, speed = 1.39, bezier = 'almostLinear' } -hl.animation { leaf = 'workspaces', enabled = true, speed = 1.94, bezier = 'almostLinear', style = 'fade' } -hl.animation { leaf = 'workspacesIn', enabled = true, speed = 1.21, bezier = 'almostLinear', style = 'fade' } -hl.animation { leaf = 'workspacesOut', enabled = true, speed = 1.94, bezier = 'almostLinear', style = 'fade' } +hl.animation { + leaf = 'layers', + enabled = true, + speed = 3.81, + bezier = 'easeOutQuint', +} +hl.animation { + leaf = 'layersIn', + enabled = true, + speed = 4, + bezier = 'easeOutQuint', + style = 'fade', +} +hl.animation { + leaf = 'layersOut', + enabled = true, + speed = 1.5, + bezier = 'linear', + style = 'fade', +} +hl.animation { + leaf = 'fadeLayersIn', + enabled = true, + speed = 1.79, + bezier = 'almostLinear', +} +hl.animation { + leaf = 'fadeLayersOut', + enabled = true, + speed = 1.39, + bezier = 'almostLinear', +} +hl.animation { + leaf = 'workspaces', + enabled = true, + speed = 1.94, + bezier = 'almostLinear', + style = 'fade', +} +hl.animation { + leaf = 'workspacesIn', + enabled = true, + speed = 1.21, + bezier = 'almostLinear', + style = 'fade', +} +hl.animation { + leaf = 'workspacesOut', + enabled = true, + speed = 1.94, + bezier = 'almostLinear', + style = 'fade', +} hl.animation { leaf = 'zoomFactor', enabled = true, speed = 7, bezier = 'quick' } -- Style Gum confirm to match terminal theme diff --git a/.config/hypr/monitors.lua b/.config/hypr/monitors.lua index d85cb16..0ee20ad 100644 --- a/.config/hypr/monitors.lua +++ b/.config/hypr/monitors.lua @@ -2,19 +2,19 @@ -- List current monitors and resolutions possible: hyprctl monitors hl.monitor { - output = 'desc:Samsung Electric Company LU28R55 HNMN500475', + output = 'desc:' .. LEFT_MONITOR_NAME, mode = '3840x2160@30', position = '0x0', scale = 1.5, } hl.monitor { - output = 'desc:Samsung Electric Company LU28R55 HNMN500462', + output = 'desc:' .. RIGHT_MONITOR_NAME, mode = '3840x2160@30', position = '2560x0', scale = 1.5, } hl.monitor { - output = 'desc:BOE NE160QDM-NZ6', + output = 'desc:' .. LAPTOP_MONITOR_NAME, mode = '2560x1600', position = '5120x720', scale = 'auto', diff --git a/.config/hypr/scratchpad.lua b/.config/hypr/scratchpad.lua new file mode 100644 index 0000000..767a319 --- /dev/null +++ b/.config/hypr/scratchpad.lua @@ -0,0 +1,60 @@ +-- Scratchpad apps +hl.window_rule { + workspace = 'special:music', + match = { + class = 'Spotify|psysonic', + }, +} +hl.window_rule { + workspace = 'special:comms', + match = { + class = '^(chrome-discord.com__channels_@me-Default|chrome-web.whatsapp.com__-Default|signal)$', + }, +} +hl.window_rule { + workspace = 'special:prod', + match = { + class = '^(superproductivity|org.station.notes)$', + }, +} + +-- Control scratchpad +bind( + 'SUPER + S', + hl.dsp.workspace.toggle_special 'scratchpad', + 'Toggle scratchpad' +) +bind( + 'SUPER + ALT + S', + hl.dsp.window.move { workspace = 'special:scratchpad' }, + 'Move window to scratchpad' +) +bind('SUPER + N', function() + hl.dispatch(hl.dsp.workspace.toggle_special 'prod') + local windows = hl.get_windows { workspace = 'special:prod' } + if #windows == 0 then + exec 'station-launch-or-focus ^superProductivity$ "uwsm-app -- super-productivity"' + exec 'uwsm-app -- xdg-terminal-exec --app-id=org.station.notes nvim ~/Notes' + end +end, 'Toggle productivity workspace') +bind('SUPER + M', function() + hl.dispatch(hl.dsp.workspace.toggle_special 'music') + local windows = hl.get_windows { workspace = 'special:music' } + if #windows == 0 then + exec 'station-launch-or-focus spotify' + exec 'station-launch-or-focus psysonic' + end +end, 'Toggle music workspace') +bind('SUPER + D', function() + hl.dispatch(hl.dsp.workspace.toggle_special 'comms') + local windows = hl.get_windows { workspace = 'special:comms' } + if #windows == 0 then + exec 'station-launch-or-focus ^signal$ "uwsm-app -- signal-desktop"' + exec 'station-launch-or-focus ^chrome-web.whatsapp.com__-Default$ "station-launch-webapp https://web.whatsapp.com"' + exec 'station-launch-or-focus ^chrome-discord.com__channels_@me-Default$ "station-launch-webapp https://discord.com/channels/@me"' + end +end, 'Toggle comms workspace') +bind('SUPER + X', function() + hl.dispatch(hl.dsp.workspace.toggle_special 'monitor') +end, 'Toggle monitor workspace') + diff --git a/.config/hypr/workspaces.lua b/.config/hypr/workspaces.lua index 757810f..7b5920e 100644 --- a/.config/hypr/workspaces.lua +++ b/.config/hypr/workspaces.lua @@ -85,24 +85,26 @@ hl.on('config.reloaded', setup_monitors) hl.bind('switch:off:Lid Switch', setup_monitors) hl.bind('switch:on:Lid Switch', setup_monitors) -function set_laptop_workspace_to_monocle() - local workspace = get_active_workspace() +local function set_laptop_workspaces_to_monocle() + local workspaces = hl.get_workspaces() - if not workspace then - return - end - - if is_laptop_screen_focused() then - hl.workspace_rule { - workspace = 'name:' .. tostring(workspace.name), - layout = 'monocle', - } + for i = 1, #workspaces do + local workspace = workspaces[i] + if + workspace.monitor + and workspace.monitor.description == LAPTOP_MONITOR_NAME + then + hl.workspace_rule { + workspace = 'name:' .. tostring(workspace.name), + layout = 'monocle', + } + end end end -hl.on('monitor.focused', set_laptop_workspace_to_monocle) +hl.on('monitor.focused', set_laptop_workspaces_to_monocle) -hl.on('config.reloaded', set_laptop_workspace_to_monocle) +hl.on('config.reloaded', set_laptop_workspaces_to_monocle) hl.on('window.open', function() local windows = hl.get_windows()