出自 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.

參見