第四回,舍KDE抱Hyprland,新境界追求更添

我目前的桌面效果。

0.为什么不用KDE

1.没有理由的不喜欢KDE

2.感觉KDE的很多功能我根本没有用到,有点臃肿。

经过考量,选择Hyprland这个窗口管理器。

1.安装

先安装一些应用。

eos-update # EndeavourOS的更新命令
sudo pacman -S paru 
paru -S wayland hyprland dunst sddm rofi waybar kitty brave zsh 
# 理论上只要这么多应用就够,有其他需求自行安装
paru -S yazi ffmpegthumbnailer unarchiver jq poppler fd ripgrep fzf zoxide 
# yazi 后面的包都是给yazi增强文件支持

需要的应用配置都在第三回了,需要的回去看。

2.配置

基本配置,创建~/ .config/hypr/hyprland.conf

########################################################################################
AUTOGENERATED HYPR CONFIG.
PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT,
OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
########################################################################################

autogenerated = 1 # remove this line to remove the warning

# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,auto


# See https://wiki.hyprland.org/Configuring/Keywords/ for more

# Execute your favorite apps at launch
exec-once = waybar & hyprpaper 

# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf


# Some default env vars.
env = XCURSOR_SIZE,24
env = QT_QPA_PLATFORMTHEME,wayland

# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
    kb_layout = us
    kb_variant =
    kb_model =
    kb_options =
    kb_rules =

    follow_mouse = 1

    touchpad {
        natural_scroll = no
    }

    sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}

general {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    gaps_in = 5
    gaps_out = 20
    border_size = 2
    col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
    col.inactive_border = rgba(595959aa)

    layout = dwindle

    # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
    allow_tearing = false
}

decoration {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more

    active_opacity = 1
    inactive_opacity = 0.9
    fullscreen_opacity = 1

    rounding = 10
    # blur = false
    drop_shadow = false
    # blur_size = 7
    # blur_passes = 2
    # blur_new_optimizations = on
}

animations {
    enabled = yes
    # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more

    bezier = md3_decel, 0.05, 0.7, 0.1, 1
    animation = windowsIn, 1, 6, md3_decel, slide
    animation = windowsOut, 1,6, md3_decel, slide
    animation = windowsMove, 1,6, md3_decel, slide
    animation = fade, 1, 10, md3_decel
    animation = workspaces, 1, 7, md3_decel,slide
    animation = specialWorkspace, 1, 8, md3_decel, slide
}

dwindle {
    # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
    pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
    preserve_split = yes # you probably want this
}

master {
    # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
    new_is_master = true
}

gestures {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    workspace_swipe = off
}

misc {
    # See https://wiki.hyprland.org/Configuring/Variables/ for more
    vfr = true
}

# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
device:epic-mouse-v1 {
    sensitivity = -0.5
}

# Example windowrule v1
# windowrule = float, ^(kitty)$
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrulev2 = nomaximizerequest, class:.* # You'll probably like this.


# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Set programs that you use
$terminal = kitty
$fileManager = yazi
$menu = rofi --show drun
$browser = brave
$mainMod = SUPER

# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Q, exec, $terminal
bind = $mainMod, C, killactive, 
bind = $mainMod, M, exit, 
bind = $mainMod, W, exec, $browser
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating, 
bind = $mainMod, R, exec, $menu
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle

bind = , XF86MonBrightnessUp, exec, changebrightness up
bind = , XF86MonBrightnessDown, exec, changebrightness down
bind = , XF86AudioPrev, exec, playerctl prev
bind = , XF86AudioNext, exec, playerctl next
bind = , XF86AudioPlay, exec, playerctl play-pause
bind = , XF86AudioRaiseVolume, exec, changevolume up
bind = , XF86AudioLowerVolume, exec, changevolume down
bind = , XF86AudioMute, exec, changevolume mute

# Move focus with mainMod + arrow keys
bind = $mainMod, h, movefocus, l
bind = $mainMod, l, movefocus, r
bind = $mainMod, k, movefocus, u
bind = $mainMod, j, 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

# Switch between most recent workspace
bind = $mainMod, TAB, workspace, previous

# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, movetoworkspace, 1
bind = $mainMod SHIFT, 2, movetoworkspace, 2
bind = $mainMod SHIFT, 3, movetoworkspace, 3
bind = $mainMod SHIFT, 4, movetoworkspace, 4
bind = $mainMod SHIFT, 5, movetoworkspace, 5
bind = $mainMod SHIFT, 6, movetoworkspace, 6
bind = $mainMod SHIFT, 7, movetoworkspace, 7
bind = $mainMod SHIFT, 8, movetoworkspace, 8
bind = $mainMod SHIFT, 9, movetoworkspace, 9
bind = $mainMod SHIFT, 0, movetoworkspace, 10

# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1

# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

重启后,在登录界面sddm中的会话,选hyprland而不是plasma。

WIN+ENTER键,开启kitty终端。

卸载KDE桌面环境(可选)

如果想卸载KDE,可以执行以下命令。

paru -Rns plasma
paru -Rns eos-plasma-sddm-config eos-sddm-theme 

3.适配屏幕

hyprctl monitors all

列出可用屏幕。

我的输出示例。

hyprctl monitors all        

Monitor eDP-2 (ID 0):
    2560x1440@165.00000 at 0x0
    description: (null) (null) (eDP-2)
    make: 
    model: 
    serial: 
    active workspace: 2 (2)
    special workspace: 0 ()
    reserved: 0 35 0 0
    scale: 1.00
    transform: 0
    focused: yes
    dpmsStatus: 1
    vrr: 0
    activelyTearing: false

~/.config/hypr/hyprland.conf下添加下面配置:

# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=eDP-2,2560x1440@165,0x0

4.NVIDIA支持

~/.config/hypr/hyprland.conf下添加下面配置:

# See https://wiki.hyprland.org/Nvidia/ for more
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1

5.屏幕共享支持

paru -S xdg-desktop-portal-hyprland pipewire wireplumber

安装完成后,在~/.config/hypr/hyprland.conf下添加下面配置:

# See https://wiki.hyprland.org/Useful-Utilities/Screen-Sharing/
exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP

6.设置壁纸

paru -S hyprpaper

我使用hyprpaper工具来设置壁纸。

安装完成后,创建~/.config/hypr/hyprpaper.conf添加下面配置:

# See https://wiki.hyprland.org/Useful-Utilities/Wallpapers/ for more
preload = ~/.config/hypr/wallpaper.jpg
wallpaper = eDP-2,~/.config/hypr/wallpaper.jpg 
# eDP-2改为你显示器的参数,在配置显示器适配有提

# enable splash text rendering over the wallpaper
splash = true

# fully disable ipc
ipc = off 

preload改成图片路径,wallpaper改成显示器,图片路径。(我的显示器是eDP-2,我的图片路径是~/.config/hypr/wallpaper.jpg)

7.截图

paru -S hyprshot

然后在hyprland.conf添加快捷键。

bind = $mainMod SHIFT, s, exec, hyprshot -m region

8.剪贴板

使用copyQ。

paru -S copyQ

然后在hyprland.conf添加开机启动。

exec-once = waybar & fcitx5 & hyprpaper & copyq --start-server

9.其他

https://wiki.hyprland.org/

需要更多配置请参考官方文档