hyprland: Refactor to accommodate more DEs

This commit is contained in:
SebastianStork 2026-03-05 20:57:20 +01:00
parent 927f056987
commit 048c7fb888
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
7 changed files with 72 additions and 63 deletions

View file

@ -0,0 +1,12 @@
{ config, lib, ... }:
{
options.custom.programs.hyprland.enable = lib.mkEnableOption "";
config = lib.mkIf config.custom.programs.hyprland.enable {
wayland.windowManager.hyprland = {
enable = true;
package = null;
portalPackage = null;
};
};
}

View file

@ -0,0 +1,92 @@
{ config, lib, ... }:
{
config = lib.mkIf config.custom.programs.hyprland.enable {
wayland.windowManager.hyprland.extraConfig = ''
# Bindflags:
# r = release
# e = repeat
# l = locked
# Essentials
bind = SUPER SHIFT, C, killactive,
bind = SUPER SHIFT, V, togglefloating,
bind = SUPER SHIFT, F, fullscreen, 0
# Launch programs
bind = SUPER, RETURN, exec, kitty
bind = SUPER, B, exec, firefox
bind = SUPER, C, exec, code
# Move focus
bind = SUPER, left, movefocus, l
bind = SUPER, right, movefocus, r
bind = SUPER, up, movefocus, u
bind = SUPER, down, movefocus, d
bind = SUPER, TAB, cyclenext,
# Move window
bind = SUPER SHIFT, left, movewindow, l
bind = SUPER SHIFT, right, movewindow, r
bind = SUPER SHIFT, up, movewindow, u
bind = SUPER SHIFT, down, movewindow, d
bindm = SUPER, mouse:272, movewindow
# Resize window
binde = SUPER CONTROL, left, resizeactive, -100 0
binde = SUPER CONTROL, right, resizeactive, 100 0
binde = SUPER CONTROL, up, resizeactive, 0 -100
binde = SUPER CONTROL, down, resizeactive, 0 100
bindm = SUPER, mouse:273, resizewindow
# Switch workspace
${lib.concatMapStringsSep "\n" (n: ''
bind = SUPER, ${toString n}, focusworkspaceoncurrentmonitor, ${toString n}
bind = SUPER SHIFT, ${toString n}, movetoworkspacesilent, ${toString n}
'') (lib.range 1 9)}
# Manage session
bindrl = SUPER CONTROL, Q, exit,
bindrl = SUPER CONTROL, P, exec, poweroff
bindrl = SUPER CONTROL, R, exec, reboot
bindrl = SUPER CONTROL, H, exec, systemctl hibernate
bindrl = SUPER CONTROL, S, exec, systemctl sleep
bindrl = SUPER CONTROL, B, exec, sleep 1 && hyprctl dispatch dpms off
# Control media
bindl = , XF86AudioPlay, exec, $play-pause
bindel = SHIFT, XF86AudioRaiseVolume, exec, $play-next
bindel = SHIFT, XF86AudioLowerVolume, exec, $play-previous
bindl = , XF86AudioMute, exec, $mute
bindel = , XF86AudioRaiseVolume, exec, $volume-up
bindel = , XF86AudioLowerVolume, exec, $volume-down
bindl = SHIFT, XF86AudioMute, exec, $mute-mic
bindl = SUPER ALT, RETURN, exec, $play-pause
bindel = SUPER ALT, right, exec, $play-next
bindel = SUPER ALT, left, exec, $play-previous
bindl = SUPER ALT, BACKSPACE, exec, $mute
bindel = SUPER ALT, up, exec, $volume-up
bindel = SUPER ALT, down, exec, $volume-down
bindl = SUPER ALT, M, exec, $mute-mic
${lib.optionalString config.custom.programs.brightnessctl.enable ''
# Adjust brightness
bindel = , XF86MonBrightnessUp, exec, brightnessctl --exponent set +2%
bindel = , XF86MonBrightnessDown, exec, brightnessctl --exponent set 2%-
''}
# Screenshot
bind = , Print, exec, grimblast --notify --freeze copysave output
bind = SHIFT, Print, exec, grimblast --notify --freeze copysave area
bind = CONTROL, Print, exec, grimblast --notify --freeze copysave active
# Special workspaces
bind = SUPER, Q, togglespecialworkspace, flake
bind = SUPER, S, togglespecialworkspace, music
bind = SUPER, D, togglespecialworkspace, chat
bind = SUPER, M, togglespecialworkspace, monitor
bind = SUPER, F, togglespecialworkspace, files
bind = SUPER, N, togglespecialworkspace, notes
'';
};
}

View file

@ -0,0 +1,103 @@
{ config, lib, ... }:
{
config = lib.mkIf config.custom.programs.hyprland.enable {
wayland.windowManager.hyprland.settings = {
input = {
kb_layout = "de";
kb_variant = "nodeadkeys";
accel_profile = "flat";
touchpad = {
natural_scroll = true;
middle_button_emulation = true;
};
};
device = [
{
name = "logitech-usb-receiver-mouse";
sensitivity = "0.2";
}
{
name = "pixa3854:00-093a:0274-touchpad";
accel_profile = "adaptive";
}
];
general = {
gaps_in = 4;
gaps_out = 8;
border_size = 2;
"col.active_border" =
{
dark = "rgb(ffffff)"; # White
light = "rgb(000000)"; # Black
}
.${config.custom.theme};
"col.inactive_border" =
{
dark = "rgba(ffffff00)"; # Transparent
light = "rgba(ffffff00)"; # Transparent
}
.${config.custom.theme};
layout = "master";
};
master.mfact = "0.5";
decoration = {
rounding = 6;
blur.enabled = false;
shadow.enabled = false;
};
animations.enabled = false;
misc = {
disable_hyprland_logo = true;
disable_splash_rendering = true;
force_default_wallpaper = 0;
key_press_enables_dpms = true;
};
binds.hide_special_on_workspace_change = true;
cursor.inactive_timeout = 10;
ecosystem = {
no_update_news = true;
no_donation_nag = true;
};
windowrule = [
# No borders on floating window when it's the only window
"bordersize 0, floating:1, onworkspace:w[1]"
# No borders on tiled window when it's the only tiled window
"bordersize 0, floating:0, onworkspace:w[t1]"
# No rounding on tiled window when it's the only tiled window on a normal workspace
"rounding 0, floating:0, onworkspace:w[t1]s[false]"
"idleinhibit fullscreen, class:.*"
# Fix flickering in JetBrains-IDEs
"noinitialfocus, class:(jetbrains-)(.*), floating:1"
];
workspace = [
# No outer gaps when only one tiled window on normal workspaces
"w[t1]s[false], gapsout:0"
# Large outer gaps on special workspaces
"s[true], gapsout:60"
"special:flake, on-created-empty:kitty --directory ~/Projects/nixos-config"
"special:music, on-created-empty:spotify"
"special:chat, on-created-empty:discord"
"special:monitor, on-created-empty:kitty btop"
"special:files, on-created-empty:nemo"
"special:notes, on-created-empty:obsidian"
];
exec-once = [ "[workspace special:monitor silent] kitty btop" ];
};
};
}