From 28a148d50db7992e241784378845698652bb6d3f Mon Sep 17 00:00:00 2001 From: elythh Date: Mon, 18 Dec 2023 18:51:02 +0100 Subject: [PATCH] :pencil2: hyprland config --- home/gwen/conf/ui/hyprland/default.nix | 567 +++++++++++++------------ 1 file changed, 296 insertions(+), 271 deletions(-) diff --git a/home/gwen/conf/ui/hyprland/default.nix b/home/gwen/conf/ui/hyprland/default.nix index dbe3cbbc..6982ab93 100644 --- a/home/gwen/conf/ui/hyprland/default.nix +++ b/home/gwen/conf/ui/hyprland/default.nix @@ -1,279 +1,304 @@ -{ inputs, pkgs, nix-colors, ... }: -let - colors = config.colorscheme.colors; - hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland; - plugins = inputs.hyprland-plugins.packages.${pkgs.system}; - split-monitor-workspaces = inputs.split-monitor-workspaces; - launcher = pkgs.writeShellScriptBin "hypr" '' - #!/${pkgs.bash}/bin/bash +{ config, lib, pkgs, hyprland, hyprland-plugins, nix-colors, ... }: - export WLR_NO_HARDWARE_CURSORS=1 - export _JAVA_AWT_WM_NONREPARENTING=1 - - exec ${hyprland}/bin/Hyprland - ''; -in { - home.packages = [ launcher ]; - - eww-hyprland = { + systemd.user.targets.hyprland-session.Unit.Wants = [ "xdg-desktop-autostart.target" ]; + wayland.windowManager.hyprland = with config.colorscheme.colors; { enable = true; - package = inputs.eww.packages.${pkgs.system}.eww-wayland; - }; - - xdg.desktopEntries."org.gnome.Settings" = { - name = "Settings"; - comment = "Gnome Control Center"; - icon = "org.gnome.Settings"; - exec = "env XDG_CURRENT_DESKTOP=gnome ${pkgs.gnome.gnome-control-center}/bin/gnome-control-center"; - categories = [ "X-Preferences" ]; - terminal = false; - }; - - imports = [ - (import ../ags/default.nix { }) - (import ../../utils/swayidle/default.nix { inherit pkgs; }) - (import ../../utils/swaylock/default.nix { inherit colors pkgs; }) - ]; - - packages = with pkgs; [ - inputs.hyprland-contrib.packages.${pkgs.system}.grimblast - gnome.gnome-boxes - gnome.gnome-calculator - gnome.gnome-calendar - gnome.gnome-control-center - gnome.gnome-software - gnome.gnome-system-monitor - gnome.gnome-weather - sassc - swappy - swww - tessen - wf-recorder - wl-clipboard - wlogout - wlr-randr - xdg-desktop-portal-hyprland - ]; - - wayland.windowManager.hyprland = { - enable = true; - package = hyprland; + package = hyprland.packages.${pkgs.system}.hyprland; systemd.enable = true; - xwayland.enable = true; - plugins = [ - split-monitor-workspaces.packages.${pkgs.system}.split-monitor-workspaces - ]; - - settings = { - exec-once = [ - "ags -b hypr" - "hyprctl setcursor Qogir 24" - ]; - - monitor = [ - # Home - "eDP-1, 1920x1080, 2560x0, 1" - "DP-3, 2560x1440, 0x0, 1" - # Work - "eDP-1, 1920x1080, 960x1080, 1" - "DP-4, 1920x1080, 1920x0, 1" - "DP-8, 1920x1080, 0x0, 1" - ]; - - general = { - layout = "dwindle"; - resize_on_border = true; - "col.active_border" = "0x${colors.color3}ac"; - "col.inactive_border" = "0x${colors.bg2}33"; - }; - - misc = { - layers_hog_keyboard_focus = false; - disable_splash_rendering = true; - force_default_wallpaper = 0; - }; - - input = { - kb_layout = "us"; - kb_options = compose:caps; - repeat_rate = 50; - repeat_delay = 240; - touchpad = { - disable_while_typing = 1; - natural_scroll = 1; - clickfinger_behavior = 1; - middle_button_emulation = 0; - tap-to-click = 1; - }; - }; - - binds = { - allow_workspace_cycles = true; - }; + #plugins = [ hyprland-plugins.packages.${pkgs.system}.hyprbars ]; + extraConfig = '' + $mainMod = SUPER + # $scripts=$HOME/.config/hypr/scripts + monitor=,preferred,auto,1 + # monitor=HDMI-A-1, 1920x1080, 0x0, 1 + # monitor=eDP-1, 1920x1080, 1920x0, 1 + input { + kb_layout = us + kb_variant = + kb_model = + kb_options = caps:escape + kb_rules = + follow_mouse = 1 # 0|1|2|3 + float_switch_override_focus = 2 + numlock_by_default = true + touchpad { + natural_scroll = yes + } + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. + } + general { + gaps_in = 20 + gaps_out = 20 + border_size = 3 + col.active_border = rgb(${accent}) + col.inactive_border = rgba(595959aa) + layout = dwindle # master|dwindle + } + dwindle { + no_gaps_when_only = false + force_split = 0 + special_scale_factor = 0.8 + split_width_multiplier = 1.0 + use_active_for_splits = true + pseudotile = yes + preserve_split = yes + } + master { + new_is_master = true + special_scale_factor = 0.8 + new_is_master = true + no_gaps_when_only = false + } + # cursor_inactive_timeout = 0 + decoration { + active_opacity = 1 + inactive_opacity = 1 + fullscreen_opacity = 1.0 + rounding = 3 + drop_shadow = true + shadow_range = 4 + shadow_render_power = 3 + shadow_ignore_window = true + # col.shadow = + # col.shadow_inactive + # shadow_offset + dim_inactive = false + # dim_strength = #0.0 ~ 1.0 + blur { + enabled: false + size = 20 + passes = 4 + new_optimizations = true + } + } + animations { + enabled=1 + bezier = md3_standard, 0.2, 0, 0, 1 + bezier = md3_decel, 0.05, 0.7, 0.1, 1 + bezier = md3_accel, 0.3, 0, 0.8, 0.15 + bezier = overshot, 0.05, 0.9, 0.1, 1.1 + bezier = crazyshot, 0.1, 1.5, 0.76, 0.92 + bezier = hyprnostretch, 0.05, 0.9, 0.1, 1.0 + bezier = fluent_decel, 0.1, 1, 0, 1 + # Animation configs + animation = windows, 1, 2, md3_decel, popin 80% + animation = border, 1, 10, default + animation = fade, 1, 2, default + animation = workspaces, 1, 3, md3_decel + animation = specialWorkspace, 1, 3, md3_decel, slidevert + } + gestures { + workspace_swipe = true + workspace_swipe_fingers = 4 + workspace_swipe_distance = 250 + workspace_swipe_invert = true + workspace_swipe_min_speed_to_force = 15 + workspace_swipe_cancel_ratio = 0.5 + workspace_swipe_create_new = true + } + misc { + disable_autoreload = true + disable_hyprland_logo = true + always_follow_on_dnd = true + layers_hog_keyboard_focus = true + animate_manual_resizes = false + enable_swallow = true + swallow_regex = + focus_on_activate = true + } + device:epic mouse V1 { + sensitivity = -0.5 + } + bind = $mainMod, Return, exec, wezterm + bind = $mainMod, Q,exec,screenshotmenu + bind = $mainMod SHIFT, Return, exec, wezterm + bind = $mainMod SHIFT, C, killactive, + bind = $mainMod SHIFT, Q, exit, + bind = $mainMod SHIFT, Space, togglefloating, + bind = $mainMod,F,fullscreen + bind = $mainMod,Y,pin + bind = $mainMod, P, pseudo, # dwindle + bind = $mainMod, J, togglesplit, # dwindle + #-----------------------# + # Toggle grouped layout # + #-----------------------# + bind = $mainMod, K, togglegroup, + bind = $mainMod, Tab, changegroupactive, f + #------------# + # change gap # + #------------# + bind = $mainMod SHIFT, G,exec,hyprctl --batch "keyword general:gaps_out 5;keyword general:gaps_in 3" + bind = $mainMod , G,exec,hyprctl --batch "keyword general:gaps_out 0;keyword general:gaps_in 0" + #--------------------------------------# + # Move focus with mainMod + arrow keys # + #--------------------------------------# + bind = $mainMod, left, movefocus, l + bind = $mainMod, right, movefocus, r + bind = $mainMod, up, movefocus, u + bind = $mainMod, down, movefocus, d + #----------------------------------------# + # Switch workspaces with mainMod + [0-9] # + #----------------------------------------# + bind = $mainMod, 1, workspace, 1 + bind = $mainMod, 2, workspace, 2 + bind = $mainMod, 3, workspace, 3 + bind = $mainMod, 4, workspace, 4 + bind = $mainMod, 5, workspace, 5 + bind = $mainMod, 6, workspace, 6 + bind = $mainMod, 7, workspace, 7 + bind = $mainMod, 8, workspace, 8 + bind = $mainMod, 9, workspace, 9 + bind = $mainMod, 0, workspace, 10 + bind = $mainMod, L, workspace, +1 + bind = $mainMod, H, workspace, -1 + bind = $mainMod, period, workspace, e+1 + bind = $mainMod, comma, workspace,e-1 + bind = $mainMod, Q, workspace,QQ + bind = $mainMod, T, workspace,TG + bind = $mainMod, M, workspace,Music + #-------------------------------# + # special workspace(scratchpad) # + #-------------------------------# + bind = $mainMod, minus, movetoworkspace,special + bind = $mainMod, equal, togglespecialworkspace + #----------------------------------# + # move window in current workspace # + #----------------------------------# + bind = $mainMod SHIFT,left ,movewindow, l + bind = $mainMod SHIFT,right ,movewindow, r + bind = $mainMod SHIFT,up ,movewindow, u + bind = $mainMod SHIFT,down ,movewindow, d - dwindle = { - pseudotile = "yes"; - preserve_split = "yes"; - # no_gaps_when_only = "yes"; - }; + #---------------------------------------------------------------# + # Move active window to a workspace with mainMod + ctrl + [0-9] # + #---------------------------------------------------------------# + bind = $mainMod CTRL, 1, movetoworkspace, 1 + bind = $mainMod CTRL, 2, movetoworkspace, 2 + bind = $mainMod CTRL, 3, movetoworkspace, 3 + bind = $mainMod CTRL, 4, movetoworkspace, 4 + bind = $mainMod CTRL, 5, movetoworkspace, 5 + bind = $mainMod CTRL, 6, movetoworkspace, 6 + bind = $mainMod CTRL, 7, movetoworkspace, 7 + bind = $mainMod CTRL, 8, movetoworkspace, 8 + bind = $mainMod CTRL, 9, movetoworkspace, 9 + bind = $mainMod CTRL, 0, movetoworkspace, 10 + bind = $mainMod CTRL, left, movetoworkspace, -1 + bind = $mainMod CTRL, right, movetoworkspace, +1 + # same as above, but doesnt switch to the workspace + bind = $mainMod SHIFT, 1, movetoworkspacesilent, 1 + bind = $mainMod SHIFT, 2, movetoworkspacesilent, 2 + bind = $mainMod SHIFT, 3, movetoworkspacesilent, 3 + bind = $mainMod SHIFT, 4, movetoworkspacesilent, 4 + bind = $mainMod SHIFT, 5, movetoworkspacesilent, 5 + bind = $mainMod SHIFT, 6, movetoworkspacesilent, 6 + bind = $mainMod SHIFT, 7, movetoworkspacesilent, 7 + bind = $mainMod SHIFT, 8, movetoworkspacesilent, 8 + bind = $mainMod SHIFT, 9, movetoworkspacesilent, 9 + bind = $mainMod SHIFT, 0, movetoworkspacesilent, 10 + # Scroll through existing workspaces with mainMod + scroll + bind = $mainMod, mouse_down, workspace, e+1 + bind = $mainMod, mouse_up, workspace, e-1 + #-------------------------------------------# + # switch between current and last workspace # + #-------------------------------------------# + binds { + workspace_back_and_forth = 1 + allow_workspace_cycles = 1 + } + bind=$mainMod,slash,workspace,previous + #------------------------# + # quickly launch program # + #------------------------# + bind=$mainMod,A,exec, rofi -show drun + #-----------------------------------------# + # control volume,brightness,media players-# + #-----------------------------------------# + bind=,XF86AudioRaiseVolume,exec, pamixer -i 5 + bind=,XF86AudioLowerVolume,exec, pamixer -d 5 + bind=,XF86AudioMute,exec, pamixer -t + bind=,XF86AudioMicMute,exec, pamixer --default-source -t + bind=,XF86MonBrightnessDown,exec,brightnessctl set 5%- + bind=,XF86MonBrightnessUp,exec,brightnessctl set +5% + bind=,XF86AudioPlay,exec, mpc -q toggle + bind=,XF86AudioNext,exec, mpc -q next + bind=,XF86AudioPrev,exec, mpc -q prev + #---------------# + # waybar toggle # + # --------------# + bind=$mainMod,O,exec,killall -SIGUSR1 .waybar-wrapped + #---------------# + # resize window # + #---------------# + bind=ALT,R,submap,resize + submap=resize + binde=,right,resizeactive,15 0 + binde=,left,resizeactive,-15 0 + binde=,up,resizeactive,0 -15 + binde=,down,resizeactive,0 15 + binde=,l,resizeactive,15 0 + binde=,h,resizeactive,-15 0 + binde=,k,resizeactive,0 -15 + binde=,j,resizeactive,0 15 + bind=,escape,submap,reset + submap=reset + bind=CTRL SHIFT, left, resizeactive,-15 0 + bind=CTRL SHIFT, right, resizeactive,15 0 + bind=CTRL SHIFT, up, resizeactive,0 -15 + bind=CTRL SHIFT, down, resizeactive,0 15 + bind=CTRL SHIFT, l, resizeactive, 15 0 + bind=CTRL SHIFT, h, resizeactive,-15 0 + bind=CTRL SHIFT, k, resizeactive, 0 -15 + bind=CTRL SHIFT, j, resizeactive, 0 15 + bindm = $mainMod, mouse:272, movewindow + bindm = $mainMod, mouse:273, resizewindow + exec = source ~/.local/bin/upw + exec = bash -c ~/.local/bin/genmenupic + exec = swww init && sww img ~/.config/awesome/theme/alt/${name}.jpg + exec = dunst & + exec-once = xss-lock lock & + exec = eww open bar && eww reload & + exec = xrdb -merge ~/.Xresources & - gestures = { - workspace_swipe_fingers = 4; - workspace_swipe = "on"; - workspace_swipe_direction_lock = false; - workspace_swipe_forever = true; - workspace_swipe_numbered = true; - }; - - windowrule = - let - f = regex: "float, ^(${regex})$"; - in - [ - (f "org.gnome.Calculator") - (f "org.gnome.Nautilus") - (f "pavucontrol") - (f "nm-connection-editor") - (f "blueberry.py") - (f "org.gnome.Settings") - (f "org.gnome.design.Palette") - (f "Color Picker") - (f "xdg-desktop-portal") - (f "xdg-desktop-portal-gnome") - (f "transmission-gtk") - "workspace 7, title:Spotify" - ]; - - bind = - let - binding = mod: cmd: key: arg: "${mod}, ${key}, ${cmd}, ${arg}"; - mvfocus = binding "SUPER" "movefocus"; - ws = binding "SUPER" "split-workspace"; - resizeactive = binding "SUPER CTRL" "resizeactive"; - mvactive = binding "SUPER ALT" "moveactive"; - mvtows = binding "SUPER SHIFT" "split-movetoworkspacesilent"; - e = "exec, ags -b hypr"; - arr = [ 1 2 3 4 5 6 7 ]; - in - [ - "CTRL SHIFT, R, ${e} quit; ags -b hypr" - "SUPER, R, ${e} -t applauncher" - ", XF86PowerOff, ${e} -t powermenu" - "SUPER, Tab, ${e} -t overview" - ", XF86Launch4, ${e} -r 'recorder.start()'" - "SUPER SHIFT,S, ${e} -r 'recorder.screenshot()'" - "SUPER,S, ${e} -r 'recorder.screenshot(true)'" - "SUPER, Return, exec, kitty" - "SUPER SHIFT, Return, exec, kitty -e ~/.config/hypr/scripts/zellij.sh" - "SUPER SHIFT, W, exec, ~/.local/bin/wallpicker" - "SUPER SHIFT,D,exec, tessen -d rofi" - "SUPER CTRL,L,exec, swaylock" - "SUPER, E, exec, wezterm -e lf" - - "ALT, Tab, focuscurrentorlast" - "CTRL ALT, Delete, exit" - "ALT, Q, killactive" - "SUPER, F, togglefloating" - "SUPER, G, fullscreen" - "SUPER, O, fakefullscreen" - "SUPER, P, togglesplit" - - (mvfocus "k" "u") - (mvfocus "j" "d") - (mvfocus "l" "r") - (mvfocus "h" "l") - (ws "left" "e-1") - (ws "right" "e+1") - (mvtows "left" "e-1") - (mvtows "right" "e+1") - (resizeactive "k" "0 -20") - (resizeactive "j" "0 20") - (resizeactive "l" "20 0") - (resizeactive "h" "-20 0") - (mvactive "k" "0 -20") - (mvactive "j" "0 20") - (mvactive "l" "20 0") - (mvactive "h" "-20 0") - ] - ++ (map (i: ws (toString i) (toString i)) arr) - ++ (map (i: mvtows (toString i) (toString i)) arr); - - bindle = let e = "exec, ags -b hypr -r"; in - [ - ",XF86MonBrightnessUp, ${e} 'brightness.screen += 0.05; indicator.display()'" - ",XF86MonBrightnessDown, ${e} 'brightness.screen -= 0.05; indicator.display()'" - ",XF86KbdBrightnessUp, ${e} 'brightness.kbd++; indicator.kbd()'" - ",XF86KbdBrightnessDown, ${e} 'brightness.kbd--; indicator.kbd()'" - ",XF86AudioRaiseVolume, ${e} 'audio.speaker.volume += 0.05; indicator.speaker()'" - ",XF86AudioLowerVolume, ${e} 'audio.speaker.volume -= 0.05; indicator.speaker()'" - ]; - - bindl = let e = "exec, ags -b hypr -r"; in - [ - ",XF86AudioPlay, ${e} 'mpris()?.playPause()'" - ",XF86AudioStop, ${e} 'mpris()?.stop()'" - ",XF86AudioPause, ${e} 'mpris()?.pause()'" - ",XF86AudioPrev, ${e} 'mpris()?.previous()'" - ",XF86AudioNext, ${e} 'mpris()?.next()'" - ",XF86AudioMicMute, ${e} 'audio.microphone.isMuted = !audio.microphone.isMuted'" - ]; - - bindm = [ - "SUPER, mouse:273, resizewindow" - "SUPER, mouse:272, movewindow" - ]; - - decoration = { - drop_shadow = "yes"; - shadow_range = 8; - shadow_render_power = 2; - "col.shadow" = "rgba(00000044)"; - - dim_inactive = false; - - rounding = 15; - blur = { - enabled = true; - size = 8; - passes = 3; - new_optimizations = "on"; - noise = 0.01; - contrast = 0.9; - brightness = 0.8; - }; - }; - - animations = { - enabled = "yes"; - bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; - animation = [ - "windows, 1, 5, myBezier" - "windowsOut, 1, 7, default, popin 80%" - "border, 1, 10, default" - "fade, 1, 7, default" - "workspaces, 1, 6, default" - ]; - }; - - plugin = { - split-monitor-workspaces = { - count = 7; - }; - hyprbars = { - bar_color = "rgb(2a2a2a)"; - bar_height = 10; - col_text = "rgba(ffffffdd)"; - bar_text_size = 11; - bar_text_font = "Ubuntu Nerd Font"; - - buttons = { - button_size = 0; - "col.maximize" = "rgba(ffffff11)"; - "col.close" = "rgba(ff111133)"; - }; - }; - }; - }; + #---------------# + # windows rules # + #---------------# + #`hyprctl clients` get class、title... + windowrule=float,title:^(Picture-in-Picture)$ + windowrule=size 960 540,title:^(Picture-in-Picture)$ + windowrule=move 25%-,title:^(Picture-in-Picture)$ + windowrule=float,imv + windowrule=move 25%-,imv + windowrule=size 960 540,imv + windowrule=float,mpv + windowrule=move 25%-,mpv + windowrule=size 960 540,mpv + windowrule=float,danmufloat + windowrule=move 25%-,danmufloat + windowrule=pin,danmufloat + windowrule=rounding 5,danmufloat + windowrule=size 960 540,danmufloat + windowrule=float,termfloat + windowrule=move 25%-,termfloat + windowrule=size 960 540,termfloat + windowrule=rounding 5,termfloat + windowrule=float,nemo + windowrule=move 25%-,nemo + windowrule=size 960 540,nemo + windowrule=opacity 0.95,title:Telegram + windowrule=opacity 0.95,title:QQ + windowrule=opacity 0.95,title:NetEase Cloud Music Gtk4 + windowrule=animation slide right,st + windowrule=workspace name:QQ, title:Icalingua++ + windowrule=workspace name:TG, title:Telegram + windowrule=workspace name:Music, title:NetEase Cloud Music Gtk4 + windowrule=workspace name:Music, musicfox + windowrule=float,ncmpcpp + windowrule=move 25%-,ncmpcpp + windowrule=size 960 540,ncmpcpp + windowrule=noblur,^(firefox)$ + windowrule=noblur,^(eww)$ + ''; }; } +