官方wiki
本人目前在用的是 archlinux, 因为你都想高度自定义了, 肯定得安装很多应用, 而且最好是最新的, 防止一些奇怪的bug
用其他发行版, 到时候还得一个个 git clone 下来, 手动安装依赖, 手动编译, 会很痛苦的 (别问我为什么这么清楚)
当然, 你也可以用诸如 nixos 这种, 不然即使是 opensuse 这种也是滚动更新的照样会让人不爽, 当然用起来肯定是 arch 又爽又简单
因为我已经添加了 archlinuxcn 的源, 我可以直接:
paru -S archlinuxcn/hyprland-git
# paru -S aur/hyprland-git
下载成功后, 你应该会得到两个命令: Hyprland(大写字母开头)
, hyprctl
, 可以通过以下命令查看版本:
Hyprland, built from branch at commit 1b48642fd15c433c53876f1b933dcd46265caf8f dirty ().
Tag: v0.32.3
flags: (if any)
hyprland 默认以 kitty 作为启动终端, 所以你可以再下一个 kitty, 本人是 wezterm, 都差不多
当你下载好之后, 你可以在诸如 GNOME 的 GDM, 或 KDE 的 KDM 等桌面管理器中, 找到名为 Hyprland 的条目(entry)
桌面管理器(Desktop manager), 故名思意, 指管理你不同桌面环境(GUI)的管理器
如果你用的是 GNOME 等, 开机之后进入的第一次 "选择用户, 输入密码" 的地方就是 DM 了, 通过角落的小齿轮选择不同桌面环境
当你在 DM 中选择了 Hyprland, 并输入密码敲下回车并进入桌面环境之后, 你会发现一个空无一物的世界(可能有个默认壁纸)
最顶部有个无比刺眼的框框会提醒你, 告诉你这是自动生成的配置文件, 还告诉了 terminal 与 logout 的默认快捷键
hyprland 的配置文件是 ~/.config/hypr/hyprland.conf
, 我们可以在其中导入多个配置文件来划分功能层级:
~/.config/hypr/
├── env.conf
├── hyprland.conf
├── keybindings.conf
├── scripts
│ ├── color-picker.sh
│ ├── idle.sh
│ ├── launcher.sh
│ ├── light.sh
│ ├── lock.sh
│ ├── reload.sh
│ ├── screenshot.sh
│ ├── tips-when-low-battery.sh
│ ├── toggle-layout.sh
│ └── volume.sh
├── startup.conf
├── wallpapers
│ ├── wallpaper-1.jpg
│ ├── wallpaper-2.jpg
│ ├── wallpaper-3.jpg
│ ├── wallpaper-4.jpg
│ ├── wallpaper-5.jpg
│ └── wallpaper-6.jpg
└── window-rules.conf
在 hyprland.conf
文件中, 我们可以定义变量, 导入其他位置的配置, 根据 官网wiki 进行配置:
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,1
# Set some variables
$hypr = ~/.config/hypr
$scripts = ~/.config/hypr/scripts
$smart_gaps = yes
# Import configurations
source = $hypr/env.conf
source = $hypr/window-rules.conf
source = $hypr/keybindings.conf
source = $hypr/startup.conf
# 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
natural_scroll = true;
sensitivity = 0.4 # -1.0 - 1.0, 0 means no modification.
touchpad {
natural_scroll = true
}
}
general {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
gaps_in = 4
gaps_out = 0
border_size = 1
no_border_on_floating = no
cursor_inactive_timeout = 0
col.active_border = rgba(1affffee)
col.inactive_border = rgba(595959aa)
layout = dwindle
}
animations {
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
enabled = yes
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 5, myBezier
animation = windowsOut, 1, 6, default, popin 90%
animation = border, 1, 10, default
animation = fade, 1, 7, default
animation = workspaces, 0, 6, default
}
dwindle {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = no # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
force_split = 2
preserve_split = yes # you probably want this
no_gaps_when_only = $smart_gaps
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = no
no_gaps_when_only = $smart_gaps
}
gestures {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = yes
}
misc {
# See https://wiki.hyprland.org/Configuring/Variables/#misc for more
focus_on_activate = yes
disable_hyprland_logo = yes
disable_splash_rendering = no
layers_hog_keyboard_focus = no
}
# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
device:epic mouse V1 {
sensitivity = -0.5
}
这些效果直接看官网解释, 很详细, 所以我拒绝再抄一遍并进行翻译
其实我修改的不多, 甚至把不用的直接删掉了, 类似那些动画效果的各种参数我也懒得仔细看, 直接默认
修改了 follow_mouse
, 开启自然滚动, 配置了下 gap/border, 设置了新变量 smart_gap
作为 no_gaps_when_only
的值
要配置的重头戏在于, 在于编写脚本/配置快捷键/配置其他应用/编写css等
下面将进入正戏, 你可以直接使用我编写的脚本, 参考我的快捷键配置
# Modify the following variables to your favorite
$mainMod = SUPER
$browser = firefox
$term_1 = wezterm
$term_2 = foot
# Vim-style key which will be used to move focus and window
$left = h
$right = l
$up = k
$down = j
# Paths
$scripts = ~/.config/hypr/scripts
# Binds
bind = $mainMod, Return, exec, $term_1
bind = $mainMod SHIFT, Return, exec, $term_2
bind = $mainMod, B, exec, $browser
bind = $mainMod, Slash, exec, killall -SIGUSR1 waybar
bind = $mainMod, Escape, exec, sh $scripts/lock.sh
bind = $mainMod, P, exec, alacritty -t bottom -e btm
bind = $mainMod, C, exec, sh $scripts/color-picker.sh
bind = $mainMod, A, exec, sh $scripts/launcher.sh drun
bind = $mainMod, W, exec, sh $scripts/launcher.sh window
bind = $mainMod, D, exec, sh $scripts/launcher.sh run
bind = ALT, space, exec, fcitx5 -r
# Volume && Brightness
bindel = , XF86AudioRaiseVolume , exec, sh $scripts/volume.sh raise
bindel = , XF86AudioLowerVolume , exec, sh $scripts/volume.sh lower
bindl = , XF86AudioMute , exec, sh $scripts/volume.sh toggle-mute
bindel = , XF86MonBrightnessUp , exec, sh $scripts/light.sh increase
bindel = , XF86MonBrightnessDown, exec, sh $scripts/light.sh decrease
bind = , Print, exec, sh $scripts/grimblast.sh --notify copy area
bind = SHIFT, Print, exec, sh $scripts/grimblast.sh --notify copy window
bind = CTRL SHIFT, Print, exec, sh $scripts/grimblast.sh --notify copy screen
bind = $mainMod SHIFT, Q, killactive,
bind = $mainMod SHIFT, R, exec, sh $scripts/reload.sh
bind = $mainMod SHIFT, Escape, exit,
bind = $mainMod SHIFT, Space, exec, playerctl play-pause
bind = $mainMod SHIFT, N, exec, playerctl next
bind = $mainMod SHIFT, P, exec, playerctl previous
bind = $mainMod, F, fullscreen, 0
bind = $mainMod, M, fullscreen, 1
bind = $mainMod, O, exec, sh $scripts/cava-pinbox.sh
bind = $mainMod SHIFT, O, exec, pkill -9 cava
bind = $mainMod, E, exec, nautilus
bind = $mainMod, V, togglefloating
bind = $mainMod, C, centerwindow
# Focus && Window && Workspace
bind = $mainMod, $left, movefocus, l
bind = $mainMod, $right, movefocus, r
bind = $mainMod, $up, movefocus, u
bind = $mainMod, $down, movefocus, d
bind = $mainMod SHIFT, $left, movewindow, l
bind = $mainMod SHIFT, $right, movewindow, r
bind = $mainMod SHIFT, $up, movewindow, u
bind = $mainMod SHIFT, $down, movewindow, d
bindm = $mainMod, x, movewindow
bindm = $mainMod, R, resizewindow
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 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, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
bind = $mainMod, S, movetoworkspacesilent, special
bind = $mainMod SHIFT, S, togglespecialworkspace
# Pass the global key forward the special app
bind = $mainMod,F10,pass,^(com\.obsproject\.Studio)$
我们可以定义一些变量在最开头, 方便后来修改
我以 Super-Key
作为主修饰键, 也就是那个有着 Windows 图标, 或者在 macos 里叫做 Command 的键位, 一般位于左手边
请别只用一个终端, 不然当某个终端突然崩溃时, 另外一个可以应急, 进行快速修改
#!/usr/bin/env bash
pactl set-sink-mute @DEFAULT_SINK@ toggle
playerctl stop
swaylock
hyprctl dispatch workspace empty
下一篇: GNOME 入坑指南