我的 Hyprland 之旅
前言
说实话,我用 Plasma 有点用腻了……
公式 Breeze,公式的 “Wayland 标准桌面”,公式的堆栈窗口管理器。
与此同时,我就 8G RAM,跑个 KWin + Shell + 游戏完全跑不爽了。
故直接开始研究 WM。
可能玩腻了就回到 Plasma 的怀抱了呢?也可能 Ocean 正式版符合我的胃口呢?

Why Hyprland
其实答案蛮简单的,色彩管理支持。
我最初考虑的 Niri,它不支持 ColorManagement 协议(Smithay 的问题,不选 Denial 的原因也在这)。而我是 WCG 屏幕,且拥有自己的 icc 文件。故我比较依赖这个,但我确实更喜欢 Niri,功能更全,实现更好,Hyprland 用起来感觉跟 GNOME 一样是依赖插件生存的(如工作区预览)。
虽然 Niri 用了我最“喜欢”的臭脚门户(至于为什么我称 GNOME 为 GNOE 和臭脚,这个等有机会我觉得我可以好好聊聊),但瑕不掩瑜,它引领了 Scrolling Tiling 的 Workflow。
好,那我就选择 Sway 吧,好巧不巧,Sway 的背后,是 wlroots,而 wlroots 并不支持 NVIDIA (其实是开始慢慢解禁了),我之前装了个 swayfx,发现配置文件没热重载,且默认配置也没动画,遂放弃。
最后思来想去,好像也就 Hyprland 一个选择了?遂开干!
配置
首先,我发行版是 Fedora Linux KDE Plasma Desktop Edition,Fedora 仓库原来也没有 Hyprland,需要 COPR。
sudo dnf in lionheartp/Hyprland然后安装一些比较核心的包
sudo dnf in wl-mirror xclip qt6ct hyprland-qt-support hyprland-plugins noctalia-git nemo hyprpolkitagent hyprpaper dunst hyprland-guiutils hyprland noctalia-greeter-git nautilus xdg-desktop-portal-gnome plasma-discover其实 WM 上,GNOME 的软件确实会比 KDE 的软件来说会相对好用,且方便美化,但涉及高级操作和一些 Corner Case,GNOE 还是那个 GNOE,总是给我惊吓。
然后打开,抄 Noctalia 的配置文件,改改适合我的设置,设置显示器,boom,Just working!
自启动项
自启动项主要是在 Noctalia、Fcitx5、剪切板同步、KDE KWallet 加载、XWayland 分数缩放参数加载上。
hl.on("hyprland.start", function () hl.exec_cmd("noctalia") hl.exec_cmd("fcitx5 --replace -d") hl.exec_cmd("clipboard") hl.exec_cmd("/usr/libexec/pam_kwallet_init") hl.exec_cmd("xrdb ~/.Xresources")+end)环境变量
环境变量主要是为了设置光标、缩放、Qt 主题。
hl.env("XCURSOR_THEME","Zhuang Fangyi_by BLZ")hl.env("XCURSOR_SIZE", "24")hl.env("HYPRCURSOR_SIZE", "24")hl.env("GDK_SCALE", "1.25")hl.env("QT_QPA_PLATFORMTHEME","qt6ct")快捷键
主要是为了让自己用习惯的快捷键回来。
local ipc = "noctalia msg "-- Example binds, see https://wiki.hypr.land/Configuring/Basics/Binds/ for morehl.bind(mainMod .. " +SHIFT+S",hl.dsp.exec_cmd(ipc .. "screenshot-region"))hl.bind(mainMod .. " +ALT+S",hl.dsp.exec_cmd(ipc .. "screenshot-fullscreen pick"))hl.bind(mainMod .. " +V",hl.dsp.exec_cmd(ipc .. "panel-toggle clipboard"))hl.bind(mainMod .. " +L",hl.dsp.exec_cmd(ipc .. "session lock"))hl.bind("CTRL+ALT+T", hl.dsp.exec_cmd(terminal))local closeWindowBind = hl.bind("ALT + F4", hl.dsp.window.close())-- hl.bind(mainMod .. "+ALT+LEFT",hl.dsp.workspace({work}))-- closeWindowBind:set_enabled(false)-- hl.bind(mainMod .. " + M", hl.dsp.exec_cmd("command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprct>hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager))hl.bind(mainMod .. " + SHIFT+F", hl.dsp.window.float({ action = "toggle" }))hl.bind(mainMod .. " + R", hl.dsp.exec_cmd(menu))hl.bind(mainMod .. " + P", hl.dsp.window.pseudo())hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit")) -- dwindle onlyhl.bind("CTRL+ALT+DELETE", hl.dsp.exec_cmd(ipc .. "panel-toggle session"))显示器
设置笔记本显示器模式为高刷模式,且载入 ICC 文件。
hl.monitor({ output = "eDP-1", mode = "highrr", position = "auto", scale = "1.25", icc = "/home/ne0w0r1d/GU603ZM.icm"
})踩坑
KWallet
我踩了最大的坑在:KWallet 上面。
因为我是 Chrome 用户,如果不设置好启动参数就会出现 Google Chrome 验证身份,意味着安全状态是不可信的,数据也都丢失了。
在询问了 Arch Linux CN 美化群里的大佬,我现在的解决方式是:在配置文件加入 KWallet Pam 的 Init,但对我来说并不生效……
最后研究了一下,需要在 Chrome 的启动项加入 --password-store=kwallet6 。
用起来……相对稳定……对吧?
但是切记,如果你有 PWA 程序,你也得给你的 PWA 程序加上,否则你先打开 PWA 再打开 Chrome 你就会傻眼了。
Matugen
我快了,我当时没注意 Noctalia 自带染色系统……
折腾了半天的 Matugen,最后选择了卸载 Matugen。
直接使用 Noctalia 的模板系统就行,勾选了一些我用得到的(Qt、GTK、Obsidian、KColorScheme、Kitty、Hyprland、Fcitx5、Steam),然后就,Boom!working!
拿 Obsidian 举例子一下:

Steam 这里要注意一下,目前的 RT3 测试版并不支持千禧年插件系统,请退回 32 位的正式版。
IME
这个简单很多,除了全局环境变量 + XIM + Qt + GTK 外,在 Hyprland 自启动加入个 Fcitx5 即可。
模糊的话,在特效 - 模糊的配置文件部分,加入一个 input_methods = true, 即可。
decoration = { rounding = 20, rounding_power = 2,
-- Change transparency of focused and unfocused windows active_opacity = 1.0, inactive_opacity = 1.0,
shadow = { enabled = true, range = 4, render_power = 3, color = 0xee1a1a1a, },
blur = { enabled = true, size = 3, passes = 1, vibrancy = 0.1696, input_methods = true, }, },
animations = { enabled = true, },})默认应用在不同桌面环境下隔离
由于我喜欢在 KDE 上面用 KDE 软件,Hyprland 上用 GNOME 的文件管理器,看图,PDF Reader,故 mimelist 隔离很有必要,但是现在的桌面环境的文件管理器很喜欢直接写入 mimelist,故应该做默认应用隔离。
首先,建个 hyprland-mimeapps.list,然后在文件管理器更改了默认应用的情况下,会在 mimeapp.list 下面加入内容,把那条规则移动过去即可。
默认情况,符合 XDG 标准的目录下,文件目录一定是 ~/.config/mimeapps.list ~/.config/hyprland-mimeapps.list。
XWayland 缩放
刚用 Hyprland 的时候,我有些程序是不得不使用 XWayland 的,比如 Bitwig Studio(Java)、Ardour(GTK2)、微信 WebView。
刚用的时候就发现了这个问题,如果直接用 Hyprland 的默认缩放机制,会导致比 KWin 环境下由混成器拉伸的情况下还模糊,在找了一圈后,我是这样解决的。
- 首先,打开“强制不缩放”开关。
hl.config({ xwayland = { force_zero_scaling = true, }})- 然后在
~/.Xresources加入Xft.dpi: 120。 - 并在 Hyprland 自启动加入 xrdb 自动获取 .Xresources 数据,以及设置 GDK/GTK 环境变量,为方便观看,我就直接列出这两行内容。
hl.exec_cmd("xrdb ~/.Xresources")hl.env("GDK_SCALE", "1.25")至于 Qt 为什么不加入这种环境变量?因为 Qt 如果加入了,会导致所有 Qt 软件的渲染有问题,无论 Wayland 还是 XWayland。
不过听说集成 XWayland 是不如 XWayland Satellite 的(会出现不可控的层级问题),到时候试试关闭 KWin XWayland 和 Hyprland XWayland 跑下 XWayland Satellite 看看?
剪切板同步
X11 和 Wayland 同步剪切板这功能,基本上主流桌面环境都会去做 Workaround,但是 WM 不会,而且如果以 Wayland 模式运行 QQ 的话,QQ 的剪切板还是走的 X11 的工具链,所以我们需要一个剪切板同步工具。
新建文件 /usr/local/bin/clipboard 在里面加入以下内容,并给予可执行权限,且按照上面的配置文件方式,加入 clipboard 自启。
#!/bin/bashSELF_PID=$$
ps -ef | grep clipboard_sync | grep -v grep | grep -v "$SELF_PID" | awk '{print $2}' | xargs -r kill
# 下面放原来的脚本内容# --------------------# 防抖变量last_text=""last_img_hash=""temp_file_path="/tmp/sync-img"ext=""
rm_temp_file(){ if [[ -f "$temp_file_path" ]]; then rm $temp_file_path fi}
temp_file(){ echo "$temp_file_path.$ext"}
# X11 → Wayland 同步x11_to_wayland() { while true; do # ------- 判断wayland是否复制图片,是则删除x11复制的临时图片 ------- if [[ -f "$temp_file_path" ]]; then clip_types=$(wl-paste --list-types 2>/dev/null || true) if [[ "$clip_types" == *"image/png"* ]] || [[ "$clip_types" == *"image/jpeg"* ]]; then rm_temp_file fi fi
# -------- 图片 -------- if xclip -selection clipboard -t TARGETS -o 2>/dev/null | grep -q "image/png"; then if [[ $(xclip -selection clipboard -t image/png -o 2>/dev/null | wc -c) -gt 0 ]]; then x11_img_hash=$(xclip -selection clipboard -t image/png -o | sha256sum | awk '{print $1}') if [[ -f "$temp_file_path" ]]; then img_file_hash=$(sha256sum "$temp_file_path" | awk '{print $1}') else img_file_hash="" fi
if [[ -n "$x11_img_hash" && "$x11_img_hash" != "$img_file_hash" ]]; then xclip -selection clipboard -t image/png -o > $temp_file_path magic=$(head -c 12 "$temp_file_path" | xxd -p) case "$magic" in 89504e470d0a1a0a*) ext="png" ;; 474946383761*|474946383961*) ext="gif" ;; ffd8ff*) ext="jpg" ;; 52494646*) ext="webp" ;; *) ext="bin" ;; esac path=$(temp_file) echo "$path" mv "$temp_file_path" "$path" echo -n "file://$path" | wl-copy -t text/uri-list fi xclip -selection clipboard -i /dev/null fi fi
# -------- 文本 -------- current_text=$(wl-paste --type text/plain 2>/dev/null || true) x11_text=$(xclip -selection clipboard -o 2>/dev/null || true)
if [[ -n "$x11_text" && "$x11_text" != "$last_text" && "$x11_text" != "$current_text" ]]; then echo -n "$x11_text" | wl-copy --type text/plain last_text="$x11_text" current_text=$(wl-paste --type text/plain 2>/dev/null || true) echo "copy to wl $(wl-paste)" fi
if [[ -n "$current_text" && "$current_text" != "$last_text" && "$x11_text" != "$current_text" ]]; then echo "$current_text" | xclip -selection clipboard -t UTF8_STRING -i last_text="$current_text" echo "copy to x11 $(xclip -selection clipboard -o)" fi
sleep 0.5 done}
# 启动同步服务x11_to_waylandrm_temp_file该内容取自 Busyo 的博客,毕竟同为 WM,很多地方互通的。
Noctalia AppImage 图标丢失问题
这个问题短时间内我也不知道怎么解决,目前看 Issue 说是因为用了比 GNOME 更严格的文件路径选择,应该只能改 Desktop 了🤔。
Noctalia Greeter 相关问题
初步设置
警告
默认状态下,需要加入 greetd 组以能够正常使用 Noctalia Greeter。
sudo usermod -aG greetd username你也可以修改 greetd 可以访问的用户/组,找到这个字眼的就行,不过不太推荐。
[default_session]# ...... #user = "greetd"首先使用你最喜欢文本编辑器,找到以下内容,并修改成如下样式(默认应该是 agetty)。
[default_session]command = "/usr/bin/noctalia-greeter-session"无法同步 Noctalia Greeter / 启用无密码同步
先执行下 sudo noctalia-greeter-apply-appearance --setup-system
再试试命令行同步看看,即使用 noctalia-greeter-apply-appearance --sync ,理论上是能正常使用的。
至于无密码同步,先查看 sudo noctalia-greeter passwordless-sync enable username,再使用 sudo noctalia-greeter passwordless-sync status 查看情况。如果出现以下字眼,说明成功了。
Passwordless appearance sync users managed by noctalia-greeter: usernameNoctalia Greeter 在登陆时会进入英语 Shell
这个问题是 Fedora 的问题,Fedora 目前的做法是如果检测到在 TTY 状态,则 Fallback 到英语,将 /etc/profile.d/lang.sh 移动到 /etc/profile.d.bak/lang.sh 即可。
至于为什么不直接删掉,还是觉得系统文件没必要说删就删。
后话
WM 说实话,真的很折腾,不过享受这个折腾的时候,用了一阵子,发现习惯了也都还好。
能提供一个较为新鲜的工作流体验的同时,换个口味。毕竟 Plasma 用了太久了,看 Breeze 和传统的堆叠桌面也累了。
不过 KDE 我还会留着,两边一起用😋。
支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!


