nix-system/hyprland.nix

430 lines
14 KiB
Nix

{ config, lib, pkgs, pkgs-unstable, pkgs-24_05, variant, ... }: {
xdg = lib.attrsets.optionalAttrs (variant == "allegro") {
configFile."systemd/user/dbus-broker.service".source =
"${pkgs.dbus-broker}/share/systemd/user/dbus-broker.service";
configFile."systemd/user/at-spi-dbus-bus.service".source =
"${pkgs.at-spi2-core}/lib/systemd/user/at-spi-dbus-bus.service";
dataFile."dbus-1/services/org.a11y.Bus.service".source =
"${pkgs.at-spi2-core}/share/dbus-1/services/org.a11y.Bus.service";
dataFile."dbus-1/accessibility-services/org.a11y.atspi.Registry.service".source =
"${pkgs.at-spi2-core}/share/dbus-1/accessibility-services/org.a11y.atspi.Registry.service";
configFile."systemd/user/xdg-desktop-portal.service".source =
"${pkgs.xdg-desktop-portal}/lib/systemd/user/xdg-desktop-portal.service";
configFile."systemd/user/xdg-desktop-portal-gtk.service".source =
"${pkgs.xdg-desktop-portal-gtk}/lib/systemd/user/xdg-desktop-portal-gtk.service";
configFile."systemd/user/xdg-desktop-portal-hyprland.service".source =
"${pkgs.xdg-desktop-portal-hyprland}/lib/systemd/user/xdg-desktop-portal-hyprland.service";
dataFile."share/dbus-1/services/org.freedesktop.impl.portal.desktop.hyprland.service".source =
"${pkgs.xdg-desktop-portal-hyprland}share/dbus-1/services/org.freedesktop.impl.portal.desktop.hyprland.service";
dataFile."systemd/user/pipewire.service".source =
"${pkgs.pipewire}/share/systemd/user/pipewire.service";
dataFile."systemd/user/pipewire-pulse.service".source =
"${pkgs.pipewire}/share/systemd/user/pipewire-pulse.service";
dataFile."systemd/user/filter-chain.service".source =
"${pkgs.pipewire}/share/systemd/user/filter-chain.service";
dataFile."systemd/user/pipewire.socket".source =
"${pkgs.pipewire}/share/systemd/user/pipewire.socket";
dataFile."systemd/user/pipewire-pulse.socket".source =
"${pkgs.pipewire}/share/systemd/user/pipewire-pulse.socket";
portal = {
enable = true;
# xdgOpenUsePortal = true;
extraPortals =
[ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-hyprland ];
configPackages =
[ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-hyprland ];
# config.common.default = "*";
config = {
hyprland = { default = [ "gtk,hyprland" ]; };
common = { default = [ "gtk,hyprland" ]; };
};
};
};
home.sessionVariables = {
NIXOS_OZONE_WL = "1";
GDK_BACKEND = "wayland,x11";
QT_QPA_PLATFORM = "wayland;xcb";
CLUTTER_BACKEND = "wayland";
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "Hyprland";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
XCURSOR_SIZE = "24";
DXVK_FILTER_DEVICE_NAME = "NVIDIA";
SYSTEMD_PAGER = "";
};
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = true;
xwayland.enable = true;
settings = {
debug = {
disable_logs = false;
};
input = {
kb_layout = "fr";
kb_variant = "";
kb_model = "pc105";
kb_options = "ctrl:nocaps";
kb_rules = "";
touchpad = {
natural_scroll = "no";
};
sensitivity = 0.0;
numlock_by_default = true;
repeat_delay = 200;
repeat_rate = 50;
force_no_accel = true;
follow_mouse = 2;
};
general = {
gaps_in = 0;
gaps_out = 0;
border_size = 0;
"col.active_border" = "rgb(000000)";
"col.inactive_border" = "rgba(00000000)";
layout = "dwindle";
};
decoration = {
blur = {
enabled = false;
};
};
animations = {
enabled = true;
bezier = "myBezier, 0, 0, .58, 1";
animation = "global, 1, 1, myBezier";
};
dwindle = {
pseudotile = true;
preserve_split = true;
force_split = 2;
# no_gaps_when_only = true;
};
gestures = {
workspace_swipe = "off";
};
misc = {
disable_hyprland_logo = true;
enable_swallow = true;
mouse_move_enables_dpms = true;
key_press_enables_dpms = true;
swallow_regex = "^st-256color$";
# swallow_regex = "^(Alacritty)(.*)$";
# swallow_regex = "^(kitty)(.*)$";
};
windowrule = "float, floating";
layerrule = "blur, waybar";
"$mod" = "SUPER";
bind =
let floating_terminal = "$TERMINAL -c floating"; in
[
"$mod, q, killactive"
"$mod SHIFT, q, exec, kill -9 $(hyprctl activewindow | grep pid | grep -E -o '[0-9]+$')"
"$mod, a, togglefloating"
"$mod SHIFT, a, workspaceopt, allfloat"
"$mod, Tab, togglesplit"
"$mod, P, pseudo"
"$mod, f, fullscreen"
"$mod, Return, exec, $TERMINAL"
"$mod SHIFT, e, exec, rofimoji"
"$mod SHIFT, g, exec, rofimoji --files greek"
"$mod SHIFT, b, exec, rofimoji --files arrows block_elements"
"$mod, c, exec, rofi -show calc -modi calc -no-show-match -no-sort"
"$mod, e, exec, $TERMINAL -e lf"
"$mod SHIFT, Return, exec, $TERMINAL --working-directory \"$(window_dir)\""
"$mod, w, exec, $BROWSER"
"$mod SHIFT, w, exec, firefox --private-window"
"$mod SHIFT, s, exec, TMP=$(rofi -dmenu -p \"nix search\" -l 0) && $BROWSER \"https://search.nixos.org/packages?channel=unstable&query=$TMP\""
# "$mod SHIFT, e, exec, $(rofi -dmenu -p \"command\" -l 0)"
"$mod, m, exec, ${floating_terminal} -e pulsemixer"
"$mod, d, exec, ~/.bin/runmenu"
"$mod, x, exec, keepmenu"
"$mod, z, exec, tmux new -spopup_terminal -d; ${floating_terminal} -e tmux a -t popup_terminal"
"$mod, f11, exec, ocrzone"
"$mod, f12, exec, ${floating_terminal} -e nmtui"
"$mod, f2, exec, darkman toggle"
"$mod, f3, exec, hyprctl reload"
"$mod, f4, exec, rofi-udisk"
"$mod, f5, exec, mount-android"
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, pamixer -t --default-source"
",XF86AudioPlay, exec, playerctl play-pause"
",XF86AudioNext, exec, playerctl next"
",XF86AudioPrev, exec, playerctl previous"
",XF86MonBrightnessUp, exec, light -A 10"
",XF86MonBrightnessDown, exec, light -U 10"
"$mod,Print, exec, screenshot"
"$mod, agrave, submap, power"
"$mod, h, movefocus, l"
"$mod, l, movefocus, r"
"$mod, k, movefocus, u"
"$mod, j, movefocus, d"
"$mod, Left, movefocus, l"
"$mod, Right, movefocus, r"
"$mod, Up, movefocus, u"
"$mod, Down, movefocus, d"
"$mod SHIFT, h, movewindow, l"
"$mod SHIFT, l, movewindow, r"
"$mod SHIFT, k, movewindow, u"
"$mod SHIFT, j, movewindow, d"
# "$mod SHIFT, Left, movewindow, l"
# "$mod SHIFT, Right, movewindow, r"
# "$mod SHIFT, Up, movewindow, u"
# "$mod SHIFT, Down, movewindow, d"
"$mod, twosuperior, workspace, 1"
"$mod, ampersand, workspace, 2"
"$mod, eacute, workspace, 3"
"$mod, quotedbl, workspace, 4"
"$mod, apostrophe, workspace, 5"
"$mod, parenleft, workspace, 6"
"$mod, minus, workspace, 7"
"$mod, egrave, workspace, 8"
"$mod, underscore, workspace, 9"
"$mod, ccedilla, workspace, 10"
"$mod, rarenright, workspace, 11"
"$mod SHIFT, twosuperior, movetoworkspacesilent, 1"
"$mod SHIFT, ampersand, movetoworkspacesilent, 2"
"$mod SHIFT, eacute, movetoworkspacesilent, 3"
"$mod SHIFT, quotedbl, movetoworkspacesilent, 4"
"$mod SHIFT, apostrophe, movetoworkspacesilent, 5"
"$mod SHIFT, parenleft, movetoworkspacesilent, 6"
"$mod SHIFT, minus, movetoworkspacesilent, 7"
"$mod SHIFT, egrave, movetoworkspacesilent, 8"
"$mod SHIFT, underscore, movetoworkspacesilent, 9"
"$mod SHIFT, ccedilla, movetoworkspacesilent, 10"
"$mod SHIFT, rarenright, movetoworkspacesilent, 11"
"$mod ALT, twosuperior, focusworkspaceoncurrentmonitor, 1"
"$mod ALT, ampersand, focusworkspaceoncurrentmonitor, 2"
"$mod ALT, eacute, focusworkspaceoncurrentmonitor, 3"
"$mod ALT, quotedbl, focusworkspaceoncurrentmonitor, 4"
"$mod ALT, apostrophe, focusworkspaceoncurrentmonitor, 5"
"$mod ALT, parenleft, focusworkspaceoncurrentmonitor, 6"
"$mod ALT, minus, focusworkspaceoncurrentmonitor, 7"
"$mod ALT, egrave, focusworkspaceoncurrentmonitor, 8"
"$mod ALT, underscore, focusworkspaceoncurrentmonitor, 9"
"$mod ALT, ccedilla, focusworkspaceoncurrentmonitor, 10"
"$mod ALT, rarenright, focusworkspaceoncurrentmonitor, 11"
];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
binde = [
"$mod CTRL SHIFT, h, moveactive, -60 0"
"$mod CTRL SHIFT, l, moveactive, 60 0"
"$mod CTRL SHIFT, k, moveactive, 0 -60"
"$mod CTRL SHIFT, j, moveactive, 0 60"
"$mod CTRL, h, resizeactive, -60 0"
"$mod CTRL, l, resizeactive, 60 0"
"$mod CTRL, k, resizeactive, 0 -60"
"$mod CTRL, j, resizeactive, 0 60"
"$mod SHIFT, Left, moveactive, -60 0"
"$mod SHIFT, Right, moveactive, 60 0"
"$mod SHIFT, Up, moveactive, 0 -60"
"$mod SHIFT, Down, moveactive, 0 60"
"$mod CTRL, Left, resizeactive, -60 0"
"$mod CTRL, Right, resizeactive, 60 0"
"$mod CTRL, Up, resizeactive, 0 -60"
"$mod CTRL, Down, resizeactive, 0 60"
];
# plugin:hyprfocus {
# enabled = no;
#
# keyboard_focus_animation = shrink
# mouse_focus_animation = flash
#
# bezier = bezIn, 0.5,0.0,1.0,0.5
# bezier = bezOut, 0.0,0.5,0.5,1.0
#
# flash {
# flash_opacity = 0.7
#
# in_bezier = bezIn
# in_speed = 0.5
#
# out_bezier = bezOut
# out_speed = 3
# }
#
# shrink {
# shrink_percentage = 0.8
#
# in_bezier = bezIn
# in_speed = 0.5
#
# out_bezier = bezOut
# out_speed = 3
# }
# }
# "plugin:hyprfocus" = {
# enabled = true;
# keyboard_focus_animation = "flash";
# mouse_focus_animation = "nothing";
# bezier = "bezIn, 0.5,0.0,1.0,0.5";
# # bezier = "bezOut, 0.0,0.5,0.5,1.0";
# flash = {
# shrink_percentage = 0.8;
# in_bezier = "bezIn";
# in_speed = 0.5;
# out_bezier = "bezIn";
# out_speed = 3;
# };
# shrink = {
# shrink_percentage = 0.8;
# in_bezier = "bezIn";
# in_speed = 0.5;
# out_bezier = "bezIn";
# out_speed = 3;
# };
# };
};
extraConfig =
let
swaybgScript = (pkgs.writers.writeFish "display-background" ''
# find background image: only file in ~/.local/share/bg
set -l bg (find ~/.local/share/bg -type l)
${pkgs.swaybg}/bin/swaybg -m fill -i $bg
# set background
# ${pkgs.nix}/bin/nix-shell \
# -p pkgs.rubyPackages.gdk_pixbuf2 \
# --run "${pkgs.swaybg}/bin/swaybg -m fill -i $bg"
'');
monitors = if (variant == "default") then ''
monitor=,highrr,auto,1
''
else if variant == "moon" then ''
monitor=,preferred,auto,1
monitor=HDMI-1, 1920x1080, auto, 1, mirror, eDP-1
monitor=HDMI-A-1, 1920x1080, auto, 1, mirror, eDP-1
''
else if variant == "allegro" then ''
monitor= DP-4, 1920x1200, 3840x0, 1
monitor= DP-3, 1920x1200, 1920x0, 1
monitor=eDP-1, 1920x1080, 0x0, 1
monitor=HDMI-1, 1920x1080, auto, 1, mirror, eDP-1
monitor=HDMI-A-1, 1920x1080, auto, 1, mirror, eDP-1
''
else ''
'';
in
''
${monitors}
${ # system specific configs
if variant == "default" then ''
#env = GBM_BACKEND,nvidia-drm
#env = __GLX_VENDOR_LIBRARY_NAME,nvidia
# env = WLR_DRM_DEVICES,/dev/dri/card1
# env = AQ_WLR_DEVICES,/dev/dri/card1
# env = AQ_DRM_DEVICES,/dev/dri/card1
''
else if variant == "allegro" then ''
env = WLR_DRM_DEVICES,/dev/dri/card0
env = AQ_WLR_DEVICES,/dev/dri/card0
env = AQ_DRM_DEVICES,/dev/dri/card0
env = TERMINAL,st
env = NIXOS_OZONE_WL,1
env = GDK_BACKEND,wayland,x11
env = QT_QPA_PLATFORM,wayland;xcb
env = CLUTTER_BACKEND,wayland
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = WLR_NO_HARDWARE_CURSORS,1
env = XCURSOR_SIZE,24
'' else ''
''
}
env = HYPRCURSOR_THEME,Hackneyed
env = HYPRCURSOR_SIZE,24
windowrule=tile,Nsxiv
exec = pkill swaybg; ${swaybgScript}
exec = pkill waybar; ${pkgs.waybar}/bin/waybar
exec = pkill dunst; ${pkgs.dunst}/bin/dunst -print >> ~/.local/state/notifications-history
exec-once = hyprctl setcursor Hackneyed 24
exec = setxkbmap -layout fr
submap = power
bind = ,s, exec, systemctl suspend
bind = ,s, submap, reset
bind = SHIFT,S,exec, ${if variant == "allegro" then "/usr/sbin/shutdown" else "shutdown"} now
bind = ,S, submap, reset
bind = ,h, exec, systemctl hibernate
bind = ,h, submap, reset
bind = ,e, exit
bind = ,e, submap, reset
bind = ,r, exec, ${if variant == "allegro" then "/usr/sbin/reboot" else "reboot"}
bind = ,r, submap, reset
bind = ,l, exec, swaylock
bind = ,l, submap, reset
bind = ,d, exec, sleep .1 && hyprctl dispatch dpms
bind = ,d, submap, reset
bind = ,escape, submap, reset
submap = reset
'';
};
}