From efa318d4d1abdc45fb837592e979fb837c6eefde Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 5 Feb 2024 09:56:42 -0500 Subject: [PATCH] refactor(hypr): move more config into nix files --- devices/binto/config/hypr/main.conf | 31 --------------- devices/wim/config/hypr/main.conf | 56 --------------------------- modules/ags/config/services/tablet.ts | 1 + modules/ags/default.nix | 26 ++++++++++++- modules/hyprland/default.nix | 34 ++-------------- modules/hyprland/inputs.nix | 36 +++++++++++++++++ modules/hyprland/packages.nix | 21 ++++++++-- modules/hyprland/security.nix | 4 ++ modules/hyprland/style.nix | 33 ++++++++++++++++ 9 files changed, 121 insertions(+), 121 deletions(-) create mode 100644 modules/hyprland/inputs.nix create mode 100644 modules/hyprland/style.nix diff --git a/devices/binto/config/hypr/main.conf b/devices/binto/config/hypr/main.conf index 4973ae05..67ba4485 100644 --- a/devices/binto/config/hypr/main.conf +++ b/devices/binto/config/hypr/main.conf @@ -1,41 +1,10 @@ # Autostart programs -exec-once = ags -exec-once = sleep 6; nextcloud --background exec-once = sleep 10; tmux new-session -s gsr -d 'bash -c $HOME/.config/gsr.sh' # TODO: add gpu-save-replay bind ## fix fullscreen game resolution exec-once = xrandr --output DP-5 --primary -## Special window apps -exec-once = [workspace special:thunder silent] thunderbird -windowrule = workspace special:thunder silent,^(thunderbird)$ -bind = $mainMod, T, togglespecialworkspace, thunder - -exec-once = [workspace special:spot silent] spotify -windowrule = workspace special:spot silent,^(Spotify)$ -bind = $mainMod, S, togglespecialworkspace, spot - - -# Input settings -device:razer-razer-naga-pro { - sensitivity = -0.5 - accel_profile = "flat" -} - - -# Binds -bind = Alt Shift, Tab, cyclenext - -## Ags & co -bindn = , Escape, exec, ags run-js 'closeAll()' -bind = $mainMod SHIFT, E , exec, ags -t powermenu -bind = $mainMod , D , exec, ags -t applauncher - - -# Rules -windowrule = tile,^(firefox)$ - # Cosmetic general { diff --git a/devices/wim/config/hypr/main.conf b/devices/wim/config/hypr/main.conf index 2b812476..cd6781b3 100644 --- a/devices/wim/config/hypr/main.conf +++ b/devices/wim/config/hypr/main.conf @@ -1,39 +1,3 @@ -# Autostart programs -exec-once = sleep 3; nextcloud --background -exec-once = squeekboard -exec-once = ags -exec-once = sleep 3; ags -t applauncher - -## Special window apps -exec-once = [workspace special:thunder silent] thunderbird -windowrule = workspace special:thunder silent,^(thunderbird)$ -bind = $mainMod, T, togglespecialworkspace, thunder - -exec-once = [workspace special:spot silent] spotify -windowrule = workspace special:spot silent,^(Spotify)$ -bind = $mainMod, S, togglespecialworkspace, spot - - -# Input settings -device:razer-razer-naga-pro-1 { - sensitivity = -0.5 - accel_profile = "flat" -} - - -# Binds - -## Brightness control -binde =, XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05' -binde =, XF86MonBrightnessDown, exec, ags -r 'Brightness.screen -= 0.05' -bindr = CAPS, Caps_Lock, exec, ags -r 'Brightness.fetchCapsState()' - -## Ags & co -bindn = , Escape, exec, ags run-js 'closeAll()' -bind = $mainMod SHIFT, E , exec, ags -t powermenu -bind = $mainMod , D , exec, ags -t applauncher - - # Cosmetic general { gaps_in = 5 @@ -79,23 +43,3 @@ animations { animation = border, 1, 10, default animation = borderangle, 1, 8, default } - -# For GParted auth -windowrule = size 741 288,^(org.kde.ksshaskpass)$ -windowrule = move cursor -370 -144,^(org.kde.ksshaskpass)$ - -windowrule = float,^(org.gnome.Calculator)$ - -windowrule = size 1231 950,title:^(Open Folder)$ -windowrule = float,title:^(Open Folder)$ - -windowrule = size 1231 950,title:^(Open File)$ -windowrule = float,title:^(Open File)$ - -windowrule = float,^(com.nextcloud.desktopclient.nextcloud)$ -windowrule = move cursor -15 -10,^(com.nextcloud.desktopclient.nextcloud)$ -windowrule = size 400 581,^(com.nextcloud.desktopclient.nextcloud)$ - -windowrule = tile,^(photoshop.exe)$ - -windowrule = tile,^(libreoffice)$ diff --git a/modules/ags/config/services/tablet.ts b/modules/ags/config/services/tablet.ts index 497e7d19..a411ddd2 100644 --- a/modules/ags/config/services/tablet.ts +++ b/modules/ags/config/services/tablet.ts @@ -50,6 +50,7 @@ class Tablet extends Service { constructor() { super(); this.#listenOskState(); + execAsync('squeekboard').catch(print); } #blockInputs() { diff --git a/modules/ags/default.nix b/modules/ags/default.nix index 6082081d..17055d63 100644 --- a/modules/ags/default.nix +++ b/modules/ags/default.nix @@ -5,6 +5,7 @@ ... }: let inherit (config.vars) mainUser hostName; + isTouchscreen = config.hardware.sensor.iio.enable; in { services.upower.enable = true; @@ -18,7 +19,9 @@ in { ... }: let symlink = config.lib.file.mkOutOfStoreSymlink; - inherit (lib) optionals; + inherit (lib) optionalAttrs optionals; + + cfgHypr = config.wayland.windowManager.hyprland; in { programs.ags.enable = true; @@ -53,6 +56,27 @@ in { ydotool ])); }; + + wayland.windowManager.hyprland = { + settings = { + exec-once = [ + "ags" + "sleep 3; ags -r 'App.openWindow(\"applauncher\")'" + ]; + + bindn = [",Escape, exec, ags run-js 'closeAll()'"]; + bind = [ + "$mainMod SHIFT, E , exec, ags -t powermenu" + "$mainMod , D , exec, ags -t applauncher" + ]; + binde = [ + ## Brightness control + ", XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05'" + ", XF86MonBrightnessDown, exec, ags -r 'Brightness.screen -= 0.05'" + ]; + bindr = ["CAPS, Caps_Lock, exec, ags -r 'Brightness.fetchCapsState()'"]; + }; + }; }) ]; } diff --git a/modules/hyprland/default.nix b/modules/hyprland/default.nix index 6fdeddc5..9b3df095 100644 --- a/modules/hyprland/default.nix +++ b/modules/hyprland/default.nix @@ -6,7 +6,7 @@ ... }: let inherit (lib) concatStringsSep optionals; - inherit (config.vars) configDir mainUser mainMonitor; + inherit (config.vars) mainUser mainMonitor; isNvidia = config.hardware.nvidia.modesetting.enable; in { @@ -34,10 +34,10 @@ in { # HOME-MANAGER CONFIG home-manager.users.${mainUser} = { imports = [ - ../../home/theme.nix - ./hycov.nix ./hyprgrass.nix + ./inputs.nix + ./style.nix ]; wayland.windowManager.hyprland = { @@ -49,8 +49,7 @@ in { gset = pkgs.gsettings-desktop-schemas; in [ - "XCURSOR_SIZE, 24" - "XDG_DATA_DIRS, ${builtins.concatStringsSep ":" [ + "XDG_DATA_DIRS, ${concatStringsSep ":" [ "${gset}/share/gsettings-schemas/${gset.name}" "${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}" "$XDG_DATA_DIRS" @@ -88,27 +87,6 @@ in { ]) ]; - input = let - inherit (config.services.xserver) xkb; - in { - kb_layout = xkb.layout; - kb_variant = xkb.variant; - follow_mouse = true; - - touchpad = { - natural_scroll = true; - disable_while_typing = false; - }; - }; - - exec-once = - [ - "hyprctl setcursor Dracula-cursors 24" - "swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png" - ] - ++ optionals (! isNull mainMonitor) - ["hyprctl dispatch focusmonitor ${mainMonitor}"]; - "$mainMod" = "SUPER"; bind = [ @@ -173,8 +151,6 @@ in { smart_split = true; special_scale_factor = 0.8; }; - - source = ["${configDir}/hypr/main.conf"]; }; }; @@ -187,8 +163,6 @@ in { alsa-utils p7zip # for reshade - swww - qt5.qtwayland qt6.qtwayland libayatana-appindicator diff --git a/modules/hyprland/inputs.nix b/modules/hyprland/inputs.nix new file mode 100644 index 00000000..8476e125 --- /dev/null +++ b/modules/hyprland/inputs.nix @@ -0,0 +1,36 @@ +{ + lib, + osConfig, + ... +}: let + inherit (lib) optionals; + inherit (osConfig.services.xserver) xkb; + inherit (osConfig.vars) mainMonitor; + + razerConf = { + sensitivity = -0.5; + accel_profile = "flat"; + }; +in { + wayland.windowManager.hyprland = { + settings = { + input = { + kb_layout = xkb.layout; + kb_variant = xkb.variant; + follow_mouse = true; + + touchpad = { + natural_scroll = true; + disable_while_typing = false; + }; + }; + + "device:razer-razer-naga-pro" = razerConf; + "device:razer-razer-naga-pro-1" = razerConf; + + exec-once = + optionals (! isNull mainMonitor) + ["hyprctl dispatch focusmonitor ${mainMonitor}"]; + }; + }; +} diff --git a/modules/hyprland/packages.nix b/modules/hyprland/packages.nix index d5e1f8aa..71cbff12 100644 --- a/modules/hyprland/packages.nix +++ b/modules/hyprland/packages.nix @@ -7,9 +7,7 @@ in { imports = [../dolphin.nix]; - programs = { - kdeconnect.enable = true; - }; + programs.kdeconnect.enable = true; home-manager.users.${mainUser} = { imports = [ @@ -62,10 +60,24 @@ in { "kdeconnect-indicator" "wl-paste --watch cliphist store" + + "sleep 3; nextcloud --background" + + "[workspace special:thunder silent] thunderbird" + "[workspace special:spot silent] spotify" ]; windowrule = [ "noborder,^(wofi)$" + "tile,^(libreoffice)$" + "float,^(org.gnome.Calculator)$" + + "float,^(com.nextcloud.desktopclient.nextcloud)$" + "move cursor -15 -10,^(com.nextcloud.desktopclient.nextcloud)$" + "size 400 581,^(com.nextcloud.desktopclient.nextcloud)$" + + "workspace special:thunder silent,^(thunderbird)$" + "workspace special:spot silent,^(Spotify)$" ]; bind = [ @@ -76,6 +88,9 @@ in { ",Print, exec, grim -g \"$(slurp)\" - | swappy -f -" "$mainMod SHIFT, C, exec, wl-color-picker" + + "$mainMod, T, togglespecialworkspace, thunder" + "$mainMod, S, togglespecialworkspace, spot" ]; }; }; diff --git a/modules/hyprland/security.nix b/modules/hyprland/security.nix index 50d743f9..74df395d 100644 --- a/modules/hyprland/security.nix +++ b/modules/hyprland/security.nix @@ -41,6 +41,10 @@ in { "float,^(org.kde.polkit-kde-authentication-agent-1)$" "size 741 288,^(org.kde.polkit-kde-authentication-agent-1)$" "center,^(org.kde.polkit-kde-authentication-agent-1)$" + + # For GParted auth + "size 741 288,^(org.kde.ksshaskpass)$" + "move cursor -370 -144,^(org.kde.ksshaskpass)$" ]; bind = [ diff --git a/modules/hyprland/style.nix b/modules/hyprland/style.nix new file mode 100644 index 00000000..d462724f --- /dev/null +++ b/modules/hyprland/style.nix @@ -0,0 +1,33 @@ +{ + config, + pkgs, + ... +}: let + inherit (config.vars) configDir; +in { + imports = [../../home/theme.nix]; + + home.packages = with pkgs; [swww]; + + wayland.windowManager.hyprland = { + settings = { + env = ["XCURSOR_SIZE, 24"]; + + exec-once = [ + "hyprctl setcursor Dracula-cursors 24" + "swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png" + ]; + + windowrule = [ + "size 1231 950,title:^(Open Folder)$" + "float,title:^(Open Folder)$" + + "size 1231 950,title:^(Open File)$" + "float,title:^(Open File)$" + ]; + + # This file should only be used for theming + source = ["${configDir}/hypr/main.conf"]; + }; + }; +}