来自 Arch Linux 中文维基

Hyprland 是一个独立的且使用 C++ 编写的平铺式 Wayland 合成器。 Hyprland 值得注意的功能包括动态平铺、选项卡窗口、整洁可读的 C++ 代码库,和提供窗口动画的自定义渲染器,窗口圆角,以及透明窗口上的 Dual Kawase Blur。一般用法和配置在 Hyprland Wiki 中有详细文档介绍。

当你遇到输入法问题时,请查看故障排除

安装

如果你使用包管理器,安装以下的其中一个

如果要使用CMake编译安装

首先将Git仓库克隆到本地

git clone --recursive https://github.com/hyprwm/Hyprland

其次切换到Git仓库目录

cd Hyprland

最后编译安装

make all && sudo make install

#6608起,Hyprland 使用aquamarine作为自己的渲染后端库。在此之前,它捆绑了它自己的wlroots版本,与wlroots-gitAUR类似

注意:
  • NVIDIA GPU用户也应该在尝试启动Hyprland之前确保遵守上游的NVIDIA页面Hyprland Wiki。如果不这么做,可能会导致很多错误,包括可能无法登录、窗口闪烁和CPU使用率较高
  • Hyprland不支持使用NVIDIA GPU,很多用户成功了,但如果一些东西出现了错误,那你只能靠你自己来修复了
  • Also make sure to install the Polkit package, as the lack thereof will cause Hyprland to fail to start. (logind missing permissions)
提示:NVIDIA显卡在 Wayland 客户端的支持大多数都在一个固定的点上。Wayland最近合并了显式同步,支持是最后的问题,一旦 NVIDIA 驱动程序555版本稳定下来,NVIDIA显卡支持就应该可以正常工作,并且希望在 Hyprland 上得到官方支持。

配置

注意:Hyprland Wiki变量中详细解释了列出的大部分选项(以及更多选项)

配置是通过一个配置文件,hyprland.conf 完成的,尽管它支持将配置拆分为多个文件并将它们包含到hyprland.conf中。默认的配置文件在 /usr/share/hypr/hyprland.conf ,在第一次登录后,为~/.config/hypr/hyprland.conf

hyprland.conf 包括配置设备(键盘、鼠标、触控板、显示器)的指令,以及动画、装饰、布局等设置。你可以设置按键绑定、窗口规则以及在重新加载配置时执行命令(一次或者每次)

每次更新文件时,配置都会自动重新加载。你可以使用 hyprctl reload 来重载以获得相同的效果。对于某些设置(尤其是输入设置),你可能需要重启你的 Hyprland 会话。

设置也可以使用 hyprctl 动态更改设置,但是这些设置不会保存

移除最上方的警告

请在~/.config/hypr/hyprland.conf中移除或使用#注释以下内容:

~/.config/hypr/hyprland.conf
autogenerated = 1

键盘

按键映射

Hyprland默认使用 US Qwerty 键盘布局,你可以使用以下配置来配置它

~/.config/hypr/hyprland.conf
# German Colemark layout
input {
    ...
    kb_layout = de
    kb_variant = colemark
    ...
    }

查看 Hyprland Wiki 以查看所有可用选项

注意: Hyprland 将会覆盖 locale 定义,如果你不使用 US 布局的键盘则有必要更改按键映射

键入延迟和速率

虽然Xorg用户将习惯于在服务器级别定义此设置,在Wayland上,每个合成器都会自行处理:

~/.config/hypr/hyprland.conf
# Repeat rate and delay
input {
    ...
    repeat_rate = 25
    repeat_delay = 600
    ...
    }

键盘背光

你可以在Hyprland中使用键盘亮度控制。

在Hyprland中使用键盘背光控制是有可能的。安装brightnessctl然后添加一个与其有关的按键绑定(替换keyboard_brightness_*with SUPER,FX or XF86KbdBrightness 取决于你的硬件是如何发出键盘背光的)

~/.config/hypr/hyprland.conf
# Keyboard backlight
bind = , xf86KbdBrightnessUp, exec, brightnessctl -d *::kbd_backlight set +33%
bind = , xf86KbdBrightnessDown, exec, brightnessctl -d *::kbd_backlight set 33%-

此外,还可以设置更改时弹出屏幕通知

媒体按键

在Hyprland上有可能通过使用 XF86Audio 键盘按键和一个外部像 pavucontrol 或者 pamixerplayerctl 的应用程序使用键盘媒体按键控制媒体(翻译可能不准确,请参照下面英语)

通过 XF86Audio 按键在Hyprland中使用键盘的媒体控制键和启动一个像pavucontrolpamixerplayerctl的应用

~/.config/hypr/hyprland.conf
# Volume and Media Control
bind = , XF86AudioRaiseVolume, exec, pamixer -i 5 
bind = , XF86AudioLowerVolume, exec, pamixer -d 5 
bind = , XF86AudioMicMute, exec, pamixer --default-source -m
bind = , XF86AudioMute, exec, pamixer -t
bind = , XF86AudioPlay, exec, playerctl play-pause
bind = , XF86AudioPause, exec, playerctl play-pause
bind = , XF86AudioNext, exec, playerctl next
bind = , XF86AudioPrev, exec, playerctl previous

当有更改时,也可以触发屏幕通知

触摸板手势

作为 Wayland 合成器,Hyprland 完全支持触摸板手势即使它默认是禁用的。使用以下更改来启用它

~/.config/hypr/hyprland.conf
# Enable touchpad gestures
gestures {
    workspace_swipe = true
    workspace_swipe_fingers = 3
}

查看上游Wiki 来获取所有可用的选项

显示设置

屏幕共享

查看屏幕共享

作为一个wlroots合成器,Hyprland可以利用 xdg-desktop-portal-wlr 通过 xdg-desktop-portal 在一系列应用程序中启用屏幕录制。

Hyprland 还维护 xdg-desktop-portal-hyprland ,一个支持屏幕共享(包括选区功能)和窗口共享,全局快捷键,并且有一个图形选择其的工具。关于使用该工具在 Hyprland wiki 中有进一步的文档介绍

值得注意的是,xdg-desktop-portal-hyprland不包括一个文件选择器,用户可以安装xdg-desktop-portal-gtk

设置屏幕分辨率

Hyprland 将会尝试去自动检测你的屏幕分辨率。不过在某些情况下它将会失败并默认为故障保护,通常是在存在多个屏幕或你有混合笔记本电脑的情况下。如果屏幕下所有的东西都很大,那么你需要设置你默认的显示器和分辨率

首先使用 hyprctl 找到你的默认显示器:

$ hyprctl monitors
Monitor eDP-1 (ID 0):
        1920x1080@144.003006 at 0x0
        description: Chimei Innolux Corporation 0x153C (eDP-1)
        ...

然后在配置文件中添加你的显示器:

~/.config/hypr/hyprland.conf
...
# Monitor details
monitor=eDP-1,1920x1080@144,0x0,1
...

此处的@144指的是屏幕的刷新率,1920x1080指的是分辨率。请替换为你的屏幕所支持的刷新率和分辨率 使用如下来查看屏幕所支持的刷新率:

$ hyprctl monitors
Monitor eDP-1 (ID 0):
        1920x1080@144.003006 at 0x0
        description: Chimei Innolux Corporation 0x153C (eDP-1)
        ...
	availableModes: 1920x1080@60.00Hz ...

0x0是一个用于多屏幕设置和最终设置的位置偏移,1是屏幕缩放倍数

亮度

安装 brightnessctl 并添加以下内容:

~/.config/hypr/hyprland.conf
# Screen brightness
bind = , XF86MonBrightnessUp, exec, brightnessctl s +5%
bind = , XF86MonBrightnessDown, exec, brightnessctl s 5%-

此外,还可以设置更改时弹出通知

使用

启动

目前推荐从TTY启动Hyprland

$ Hyprland

虽然从显示管理器中启动不是官方支持的,但是用户们报告成功在 GDMSDDM 和其他的显示管理器中成功启动。hyprland中包含一个显示管理器条目,且所有Hyprland AUR 包将会自动生成一个条目。

两种方法都提供相同的结果,加上或减去一些环境变量和服务。

自动登录

用户可以通过一个显示管理器或着在登录时采用 Xinit#Autostart X at login 中描述的方法进行自动登录

hyprctl 和 IPC

hyprctl 是一个命令行实用程序,随Hyprland一起安装,用于与显示服务器通信。它允许你向服务器发送命令(相当于配置文件中的命令,但语法略有不同)、设置关键词、发送询问和请求信息。请查看完整文档

Hyprland 还公开了 2 UNIX 套接字,以便通过代码或命令行实用程序控制和获取有关 Hyprland 的信息。这些套接字会广播焦点变化(窗口、工作区、监视器)、窗口/工作区创建等事件。

hyprctl 和 IPC 接口都在脚本中有效使用,对于复杂任务控制 Hyprland。

exec 与 exec-once

在启动应用程序是,选择正确类型的调度器是非常重要的。不正确地使用`exec`可以使应用程序启动多次而占用系统资源然后造成糟糕的状况。造成竞争系统资源的情况然后使你的系统崩溃。

注意:#配置中提到,Hyprland会自动解析hyprland.conf文件每次的更改:不要对每个软件都使用exec


在大多数情况下,你应该使用exec-once在启动时来运行应用程序和守护程序,使用这个命令启动的软件在Hyprland重新加载时将不会再次启动。仅当你绝对确定希望每次重新加载时再次运行该命令时,才使用exec

设置环境变量

通过env关键词在hyprland.conf中设置环境变量,它的语法不同于在Unix shell中使用env命令

这些差异在上游Wiki中被解释

Hypr生态

警告: 以下所提及的部分软件仍在开发,有bug都是在意料之中的。因此,完整的说明和示例会被略去,直到它足够稳定以成为稳定版。关于使用说明,参见上游 Wiki.

Hyprland 开发团队正在构建一个专门用于Hyprland的软件生态,这些工具将包括调度器,允许使用hyprctl而不是依赖脚本来控制它们。

目前,软件生态包括以下软件:

Hyprpaper

Hyprpaper 是一个壁纸工具,你可以安装hyprpaper来使用它

Hyprpicker

Hyprpicker 是一个用于在你的桌面中抓取一个颜色的工具,你可以安装hyprpickerAUR来使用它

Hypridle

Hypridle 是一个idle管理守护程序,你可以安装hypridle来使用它

Hyprlock

Hyprlock 是一个屏幕锁定管理器,你可以安装hyprlock来使用它

Hyprcursor

Hyprcursor 是一个处理屏幕光标的新格式,它在传统的方式上提升了很多,你可以安装hyprcursor来使用它

Hyprcursor 主题

提示:如果你安装了hyprcursor并且没有安装一个主题,它将会使用你之前的光标设置

光标主题可以使用AUR安装,以下是例子:

将现有的光标主题移植到Hyprcursor,你可以参照上游GitHub仓库

关于设置光标样式,你也可以查阅光标样式来设置

技巧提示

提示:
  • 对于以下所有部分,通常有不止一种方法可以达到类似的效果,这里提供的只是一些基本示例。

文件管理器

在 Hyprland 环境下,如果需要图形化的文件管理功能,则需要一个兼容 Wayland 的外部应用程序。以 thunar 为例,我们只需为其分配一个快捷键,操作如下:

~/.config/hypr/hyprland.conf
...
bind = SUPER, E, exec, thunar
...

应用程序启动器

在 Hyprland 环境下,如果需要启动应用程序,则需要一个兼容 Wayland 的外部应用程序。以 wofi 软件包为例,我们只需为其分配一个快捷键,操作如下:

~/.config/hypr/hyprland.conf
...
bind = SUPER, F, exec, wofi --show drun
...

也可以使用 rofi-wayland

~/.config/hypr/hyprland.conf
...
bind = SUPER, F, exec, rofi -show drun
...

Idle

Hyprland 需要一个外部的 Wayland 兼容的 idle 管理守护进程。最普遍安装的是 swayidleswaylock。你可以使用如下的快捷键来手动锁定屏幕:

~/.config/hypr/hyprland.conf
...
bind = SUPER, L, exec, swaylock -f -c 000000
...

自动锁定屏幕和挂起

创建下面的脚本:

~/.config/hypr/scripts/sleep.sh
swayidle -w timeout 300 'swaylock -f -c 000000' \
            timeout 600 'systemctl suspend' \
            before-sleep 'swaylock -f -c 000000' &
提示:你可以通过修改数值(以秒为单位)来调整无操作时的锁屏超时时间。300 是 5 分钟,600 是 10 分钟等等。

使之可执行并调用:

~/.config/hypr/hyprland.conf
...
exec-once = ~/.config/hypr/scripts/sleep.sh
...

在超时期限后使用 DPMS 关闭屏幕

Hyprland 有一个内置的调度器来控制 DPMS 请求,不过不建议使用它作为一个直接按键绑定,这样做的结果是你不能打开重新打开你的屏幕,且需要你重新启动。

更改在上文的脚本并将其更改为:

~/.config/hypr/scripts/sleep.sh
swayidle -w timeout 300 'swaylock -f -c 000000' \
            timeout 600 'hyprctl dispatch dpms off' \
            resume 'hyprctl dispatch dpms on' \
            timeout 900 'systemctl suspend' \
            before-sleep 'swaylock -f -c 000000' &
提示:hyprctl dispatch dpms on 命令必须直接来自在脚本中的 hyprctl dispatch dpms off 命令,使其能正常地工作。resume 命令与上面的 timeout 相关联
当使用应用程序时停止 DPMS

上面的配置将会使你的显示器关闭当你正在做一些事情,像玩一个游戏,看一个视频或听音乐。在这些情况下您可能不会在超时期限内长时间触摸系统。

来修复这个问题,你可以使用 Hyprland 内置的 Window Rules V2 功能(含有 idleinhibit 规则),你也可以安装一个 idlehack-gitAUR 或者 sway-audio-idle-inhibit-gitAUR。前者是在 Firefox 或 Chromium 播放音频或视频时使用 D-Bus 来阻止 Swayidle 请求。后者会在任何应用程序播放音频时阻止 Swayidle 请求。

对于使用 org.freedesktop.ScreenSaver.inhibit 程序来暂停屏幕保护,你可以安装 wscreensaver-bridge-gitAUR[损坏的链接:包未找到]在 Hyprland(或其他支持 idle-inhibit 协议的 Wayland 合成器)实现它。

状态栏

在 Hyprland 环境下,如果需要状态栏,则需要一个兼容 Wayland 的外部应用程序。以 waybar 软件包为例,操作如下:

~/.config/hypr/hyprland.conf
...
exec-once = waybar -c ~/.config/waybar/waybar.conf
...

工作区总揽

waybar 内置了适于这个功能的完全可自定义模块,支持Hyprland工作区自然地切换。

查看 waybar Wiki[1] 了解详情。

Polkit 认证

Polkit 认证需要使用外部身份验证代理。Hyprland 建议使用 polkit-kde-agent 和任何可以使用的应用程序。

使用以下代码来使用:

~/.config/hypr/hyprland.conf
...
exec-once = /usr/lib/polkit-kde-authentication-agent-1
...

桌面壁纸

在 Hyprland 环境下,如果需要管理桌面壁纸,则需要一个兼容 Wayland 的外部应用程序。以 swww 软件包为例,操作如下:

~/.config/hypr/hyprland.conf
...
exec-once = swww-daemon
exec-once = swww img path/to/image
...

使用脚本以每 X 分钟更换一次壁纸

创建以下脚本并确保其可执行

~/.config/hypr/scripts/swww-random
#!/bin/bash

# 该脚本将随机浏览一个目录中的文件,
# 每隔一段时间将其设置为壁纸。
#
# 注意:本脚本使用 bash(而非 POSIX shell)来设置 RANDOM 变量

if [[ $# -lt 1 ]] || [[ ! -d $1   ]]; then
	echo "Usage:
	$0 <dir containing images>"
	exit 1
fi

# 编辑以下内容以控制图像过渡
export SWWW_TRANSITION_FPS=144
export SWWW_TRANSITION_STEP=2
export SWWW_TRANSITION_TYPE=random

# 以秒为单位控制何时切换到下一幅图像
INTERVAL=300

while true; do
	find "$1" \
		| while read -r img; do
			echo "$((RANDOM % 1000)):$img"
		done \
		| sort -n | cut -d':' -f2- \
		| while read -r img; do
            if [[ "$img" != "$1" ]]; then
			    swww img "$img"
			    sleep $INTERVAL
            fi 
		done
done

接下来创建一个新文件夹来存储背景图片,类似于 ~/.config/hypr/backgrounds 这样的文件夹就可以了,并在其中填充任何你想要的图片。

最后,调用脚本:

~/.config/hypr/hyprland.conf
...
exec-once = swww-daemon
exec-once = ~/.config/hypr/scripts/swww-random ~/.config/hypr/background
...

屏幕通知

屏幕上对亮度和音量调整等操作显示通知的功能可以借助外部的通知服务程序来实现。然而,深入探讨这一主题超出了本页面的说明范围。这里我们将会聚焦于安装 mako 的操作,现在请继续进行安装

See Desktop notifications for further instructions and Desktop notifications#Standalone for a list of alternatives.

注意: * All scripts offered here are examples and will very likely need to be adjusted for your setup.

Mako

Mako is a lightweight notification daemon, you can read mako(5) for details. Its configuration file is ~/.config/mako/config, icons used for OSD are stored at ~/.config/mako/icons/ and should be in PNG format.

For the rest of this section all the images used by the scripts are available from this GitHub folder.

Keyboard backlight notifications

First create the following script:

~/.config/hypr/scripts/kbbacklight
#!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get brightness
get_backlight() {
	LIGHT="$(cat /sys/class/leds/*::kbd_backlight/brightness)"
	echo "${LIGHT}"
}

# Get icons
get_icon() {
	current="$(cat /sys/class/leds/*::kbd_backlight/brightness)"

	if [[ ("$current" -ge "0") && ("$current" -le "1") ]]; then
		icon="$iDIR/brightness-20.png"
	elif [[ ("$current" -ge "1") && ("$current" -le "2") ]]; then
		icon="$iDIR/brightness-60.png"
	elif [[ ("$current" -ge "2") && ("$current" -le "3") ]]; then
		icon="$iDIR/brightness-100.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Keyboard Brightness : $(brightnessctl -d '*::kbd_backlight' g)"
}

# Increase brightness
inc_backlight() {
	brightnessctl -d *::kbd_backlight set 33%+ && get_icon && notify_user
}

# Decrease brightness
dec_backlight() {
	brightnessctl -d *::kbd_backlight set 33%- && get_icon && notify_user
}

# Zero brightness
zero_backlight() {
	brightnessctl -d *::kbd_backlight s 0%
}

# Full brightness
full_backlight() {
	brightnessctl -d *::kbd_backlight s 100%
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	brightnessctl -d '*::kbd_backlight' g
elif [[ "$1" == "--inc" ]]; then
	inc_backlight
elif [[ "$1" == "--dec" ]]; then
	dec_backlight
elif [[ "$1" == "--zero" ]]; then
	zero_backlight
elif [[ "$1" == "--full" ]]; then
	full_backlight

else
	get_backlight
fi

Then add the following or edit any existing one:

~/.config/hypr/hyprland.conf
# Keyboard brightness
bind = keyboard_brightness_up_shortcut, exec, ~/.config/hypr/scripts/kbbacklight --inc
bind = keyboard_brightness_down_shortcut, exec, ~/.config/hypr/scripts/kbbacklight --dec
Media key notifications

First create the following script:

~/.config/hypr/scripts/volume
#!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get Volume
get_volume() {
	volume=$(pamixer --get-volume)
	echo "$volume"
}

# Get icons
get_icon() {
	current=$(get_volume)
	if [[ "$current" -eq "0" ]]; then
		echo "$iDIR/volume-mute.png"
	elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
		echo "$iDIR/volume-low.png"
	elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
		echo "$iDIR/volume-mid.png"
	elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
		echo "$iDIR/volume-high.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume : $(get_volume) %"
}

# Increase Volume
inc_volume() {
	pamixer -i 5 && notify_user
}

# Decrease Volume
dec_volume() {
	pamixer -d 5 && notify_user
}

# Toggle Mute
toggle_mute() {
	if [ "$(pamixer --get-mute)" == "false" ]; then
		pamixer -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
	elif [ "$(pamixer --get-mute)" == "true" ]; then
		pamixer -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume Switched ON"
	fi
}

# Toggle Mic
toggle_mic() {
	if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
		pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
	elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
		pamixer -u --default-source u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
	fi
}
# Get icons
get_mic_icon() {
	current=$(pamixer --default-source --get-volume)
	if [[ "$current" -eq "0" ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
		echo "$iDIR/microphone.png"
	fi
}
# Notify
notify_mic_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
}

# Increase MIC Volume
inc_mic_volume() {
	pamixer --default-source -i 5 && notify_mic_user
}

# Decrease MIC Volume
dec_mic_volume() {
	pamixer --default-source -d 5 && notify_mic_user
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	get_volume
elif [[ "$1" == "--inc" ]]; then
	inc_volume
elif [[ "$1" == "--dec" ]]; then
	dec_volume
elif [[ "$1" == "--toggle" ]]; then
	toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
	toggle_mic
elif [[ "$1" == "--get-icon" ]]; then
	get_icon
elif [[ "$1" == "--get-mic-icon" ]]; then
	get_mic_icon
elif [[ "$1" == "--mic-inc" ]]; then
	inc_mic_volume
elif [[ "$1" == "--mic-dec" ]]; then
	dec_mic_volume
else
	get_volume
fi

Then add the following (or edit any existing binds):

~/.config/hypr/hyprland.conf
# Volume
bind = , XF86AudioRaiseVolume, exec, ~/.config/hypr/scripts/volume --inc 
bind = , XF86AudioLowerVolume, exec, ~/.config/hypr/scripts/volume --dec 
bind = , XF86AudioMicMute, exec, ~/.config/hypr/scripts/volume --toggle-mic 
bind = , XF86AudioMute, exec, ~/.config/hypr/scripts/volume --toggle
Screen backlight notifications

First create the following script:

~/.config/hypr/scripts/backlight
!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get brightness
get_backlight() {
	LIGHT=$(printf "%.0f\n" $(brightnessctl g))
	echo "${LIGHT}"
}

# Get icons
get_icon() {
	current="$(get_backlight)"
	if [[ ("$current" -ge "0") && ("$current" -le "19200") ]]; then
		icon="$iDIR/brightness-20.png"
	elif [[ ("$current" -ge "19200") && ("$current" -le "38400") ]]; then
		icon="$iDIR/brightness-40.png"
	elif [[ ("$current" -ge "38400") && ("$current" -le "57600") ]]; then
		icon="$iDIR/brightness-60.png"
	elif [[ ("$current" -ge "57600") && ("$current" -le "76800") ]]; then
		icon="$iDIR/brightness-80.png"
	elif [[ ("$current" -ge "76800") && ("$current" -le "96000") ]]; then
		icon="$iDIR/brightness-100.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Brightness : $(get_backlight)"
}

# Increase brightness
inc_backlight() {
	brightnessctl s +5% && get_icon && notify_user
}

# Decrease brightness
dec_backlight() {
	brightnessctl s 5%- && get_icon && notify_user
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	get_backlight
elif [[ "$1" == "--inc" ]]; then
	inc_backlight
elif [[ "$1" == "--dec" ]]; then
	dec_backlight
else
	get_backlight
fi

Then add the following (or edit any existing binds):

~/.config/hypr/hyprland.conf
# Screen brightness
bind = , XF86MonBrightnessUp, exec, ~/.config/hypr/scripts/backlight --inc 
bind = , XF86MonBrightnessDown, exec, ~/.config/hypr/scripts/backlight --dec
Keyboard language notifications

To run this script, you need a command-line JSON processor gojqAUR.

First create the following script:

~/.config/hypr/scripts/lang
#!/usr/bin/env bash

icon="$HOME/.config/mako/icons/language.png"

# Get language
get_lang() {
	lang=$(hyprctl devices -j | gojq -r '.keyboards[] | select(.name == "at-translated-set-2-keyboard") | .active_keymap' | cut -c 1-2 | tr 'A-Z' 'a-z')
	case $lang in
		en)
			lang="English language"
			;;
		ru)
			lang="Русский язык"
			;;
		uk)
			lang="Українська мова"
			;;
	esac
	echo $lang
}

# Notify
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "$(get_lang)"

Then add the following (or edit any existing binds):

~/.config/hypr/hyprland.conf
device:at-translated-set-2-keyboard {
    kb_layout = us,ru,ua
    kb_variant = lang
    kb_options = grp:win_space_toggle
}

# Language
bind = SUPER, SPACE, exec, ~/.config/hypr/scripts/lang

Power control

Hyprland requires a wayland-compatible external application for power control. Using nwg-barAUR as an example, we simply need to bind it as follows:

~/.config/hypr/hyprland.conf
...
bind = SUPER, ESCAPE, exec, nwg-bar
...

Clipboard

Wayland 剪贴板行为会在关闭复制数据的应用程序时删除数据。其他桌面环境通过使用专用的剪贴板管理器来解决这一问题,而 Hyprland 上则有多种兼容的选择。更多信息,请参阅上游 Wiki

本节将介绍 cliphist,因为它支持复制图片和文本:

~/.config/hypr/hyprland.conf
...
exec-once = wl-paste --type text --watch cliphist store 
exec-once = wl-paste --type image --watch cliphist store
...

然后创建一个绑定,以便在您选择的应用程序启动器中调用历史记录:

~/.config/hypr/hyprland.conf
...
bind = SUPER, V, exec, cliphist list | wofi --dmenu | cliphist decode | wl-copy
...

现在按下 Super+v 将打开一个包含剪贴板历史列表的 wofi 窗口。

Enable/disable devices

To enable/disable devices (e.g. touchpad), first use

$ hyprctl devices

to get the name of your device.

Put these lines of code into your configuration file (replace <device_name> with the name of your device queried above) to turn the device on/off:

~/.config/hypr/hyprland.conf
device:<device_name> {
  enabled = {true/false}
}

To dynamically switch the device on/off use hyprctl:

$ hyprctl keyword "device:<device_name>:enabled" {true|false}

You can also create a keybinding, e.g.:

~/.config/hypr/hyprland.conf
...
bind = $mainMod, t, exec, hyprctl keyword "device:pixa3854:00-093a:0274-touchpad:enabled" false
bind = $mainMod Shift, t, exec, hyprctl keyword "device:pixa3854:00-093a:0274-touchpad:enabled" true
...

故障排除

Fcitx5 相关问题

提示:若还未能解决,请重启输入法!

无法输入

当你在任何时候输入中文时出现候选框不在输入框附近(如 QQ 等),而是漂移到 Waybar 的左上角,选择后也无法选词到输入框中,请在 Fcitx5 的配置页面中新建一个分组,选择键盘-英语(美国),然后再设置一个快捷键来轮回切换分组,切换后即可恢复正常

打开 Fcitx5 的配置页面你需要安装 fcitx5-configtool

切换英文时出现问题

当你在输入框中切换英文时,在 Waybar 左上角出现了输入法中文状态,且无法在输入框中输入英文,请重新启动 Fcitx5 以临时解决问题。

xdg-desktop-portal-hyprland is using a lot of CPU

This is a known bug [2] that should be resolved in the latest Git build. You can work around it by calling the nuclear script from the Hyprland wiki, as outlined usage here[失效链接 2024-07-30 ⓘ], in your hyprland.conf file.

Native (wayland) electron apps flickering on NVIDIA

It is a widespread issue among NVIDIA users on Hyprland [3], [4] because of lack of support for explicit sync in Hyprland [5]. Recommended temporary fix is using X11 (XWayland) with the problematic apps by passing them --ozone-platform-hint=x11, or setting env = ELECTRON_OZONE_PLATFORM_HINT,x11 in ~/.config/hypr/hyprland.conf to force all electron apps to run using XWayland.

参见