迁移到hyprland的体验
2024-06-19 16:16:14

为什么要转到 wayland?

刚开始实际上只是为了实现动态壁纸这一个功能,之前用的使用 i3wm,并没有找到合适的方法,直到看到了 mpvpaper这个项目,发现实现起来相对于我之前所看到的方法来说简单很多,并且也早就听说了 wayland 的大名了,于是便开始动手了。

有一说一,最打动我的还是 waydroid 之前就看到了 但是只能运行在 wayland 上,当然可以套个壳,但是太麻烦了

安装

使用的是 hyprland,系统是 arch,arch 的安装就不再说了,hyprland 可以复制这条命令

1
pacman -S hyprland

简单配置

主要使用的软件:
sddm(显示管理器)主题是 abstract
hyprpaper(壁纸)
mpvpaper(动态壁纸)
hyprlock(锁屏)
wlogout(电源菜单)
fuzzel(应用程序启动器)
waybar(状态栏)
kitty(终端)
mako(通知守护进程)

hyprpaper 配置

1
2
3
preload = path
wallpaper = 显示的屏幕, path
ipc = off

hyprlock 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
general {
text-trim = true
}

background {
monitor =
path = /home/$USER/Pictures/lock_bg.png
color = rgba(25, 20, 20, 1.0)

# all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
blur_passes = 1 # 0 disables blurring
blur_size = 4
noise = 0.0117
contrast = 0.8916
brightness = 0.8172
vibrancy = 0.1696
vibrancy_darkness = 0.0
}

input-field {
monitor =
size = 250, 60
outline_thickness = 2
dots_size = 0.2 # Scale of input-field height, 0.2 - 0.8
dots_spacing = 0.2 # Scale of dots' absolute size, 0.0 - 1.0
dots_center = true
outer_color = rgba(0, 0, 0, 0)
inner_color = rgba(0, 0, 0, 0.5)
font_color = rgb(200, 200, 200)
fade_on_empty = false
font_family = JetBrains Mono Nerd Font Mono
placeholder_text = <i><span foreground="##cdd6f4">Input Password...</span></i>
hide_input = false
position = 0, -120
halign = center
valign = center
}

label {
monitor =
text = cmd[update:1000] echo "$(date +"%H:%M:%S %A")"
#color = $foreground
color = rgba(255, 255, 255, 0.6)
font_size = 120
font_family = JetBrains Mono Nerd Font Mono ExtraBold
position = 0, -300
halign = center
valign = top
}

label {
monitor =
text = Hi there, $USER
#color = $foreground
color = rgba(255, 255, 255, 0.6)
font_size = 25
font_family = JetBrains Mono Nerd Font Mono
position = 0, -40
halign = center
valign = center
}

label {
monitor =
text = cmd[update:1000] echo "$(~/Documents/Scripts/whatsong.sh)"
#color = $foreground
color = rgba(255, 255, 255, 0.6)
font_size = 18
font_family = JetBrainsMono, Font Awesome 6 Free Solid
position = 0, -50
halign = center
valign = bottom
}

wlogout 使用的是默认配置,够用就行,那天有时间了在配置
fuzzel 开箱即用,很方便
waybar 配置
kitty 只配置了一个透明和模糊

模块的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
"layer": "top",
"position": "top",
"height": 15,
"spacing": 10,
"modules-left": [
"custom/launcher",
"hyprland/workspaces",
"hyprland/window"
],
"modules-right": [
"memory",
"battery",
"backlight",
"pulseaudio",
"network#1",
"network#2",
"tray",
"clock"
],
// modules config
"hyprland/workspaces": {
"format": "{name}"
},
"hyprland/window": {
"format": "{title}",
"icon": true,
"icon-size": 24
},
"clock": {
"interval": 1,
"format": "{:%Y-%m-%d %H:%M:%S %A}",
"timezone": "Asia/Shanghai"
},
"memory": {
"interval": 60,
"format": "memory: {used}GiB"
},
"battery": {
"bat": "BAT0",
"interval": 60,
"full_at": 96,
"format": "BT: {capacity}%"
},
"tray": {
"icon-size": 20,
"spacing": 10
},
"pulseaudio": {
"format": "voice: {volume}%",
"format-muted": "MUTE",
"format-bluetooth": "BTvoice: {volume}%"
},
"network#1": {
"interface": "enp47s0",
"format-ethernet": "{ipaddr}/{cidr}"
},
"netmork#2": {
"interface": "wlp45s0",
"format-wifi": "{ifname} {signalStrength}"
},
"backlight": {
"device": "intel_backlight",
"interval": 2,
"format": "BL: {percent}%"
},
"custom/launcher": {
"format": "\udb82\udcc7",
"on-click": "fuzzel",
"on-click-right": "fuzzel"
}
}

样式的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
* {
font-family: LXGWWenKaiScreen, Roboto, Helvetica, Arial, sans-serif;
font-size: 13px;
font-weight: 500;
}

window#waybar {
background-color: rgba(55, 51, 51, 0.35);
border-bottom: 3px solid rgba(100, 114, 125, 0.5);
color: #ffffff;
transition-property: background-color;
transition-duration: .5s;
}


.modules-left,
.modules-center,
.modules-right {
background-color: transparent;
}


button {
box-shadow: inset 0 -3px transparent;
border: none;
border-radius: 0;
}

button:hover {
background: inherit;
box-shadow: inset 0 -3px #ffffff;
}

#workspaces button {
padding: 0 5px;
background-color: transparent;
color: #ffffff;
}

#workspaces button:hover {
background: lightslategray;
}

#workspaces button.active {
background-color: lightskyblue;
box-shadow: inset 0 -3px #ffffff;
}

#workspaces button.urgent {
background-color: lightsalmon;
}

#mode {
background-color: #64727D;
box-shadow: inset 0 -3px #ffffff;
}

#battery,
#cpu,
#memory,
#network,
#pulseaudio,
#tray,
#network,
#clock,
#mode {
color: #fff;
}

#custom-launcher {
padding-left: 5px;
}

#clock {
padding-right: 5px;
}

hyprland 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# #######################################################################################
# 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

# This is an example Hyprland config file.
# Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/Configuring-Hyprland/

# Please note not all available settings / options are set here.
# For a full list, see the wiki

# You can split this configuration into multiple files
# Create your files separately and then link them to this file like this:
# source = ~/.config/hypr/myColors.conf


################
### MONITORS ###
################

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


###################
### MY PROGRAMS ###
###################

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

# Set programs that you use
$terminal = kitty
$fileManager = nemo
$menu = fuzzel


#################
### AUTOSTART ###
#################

# Autostart necessary processes (like notifications daemons, status bars, etc.)
# Or execute your favorite apps at launch like this:

# exec-once = $terminal
exec-once = nm-applet &
exec-once = waybar &

exec-once = [workspace 1 silent] firefox
exec-once = [workspace 10 silent] qbittorrent

#

exec-once = fcitx5 -d
exec-once = hyprpaper
exec-once = udiskie &
exec-once = swayidle -w timeout 1800 'hyprlock'
exec-once = /usr/lib/polkit-kde-authentication-agent-1
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = waydroid session start
exec-once = blueman-applet

#############################
### ENVIRONMENT VARIABLES ###
#############################

# See https://wiki.hyprland.org/Configuring/Environment-variables/

env = HYPRCURSOR_THEME,rose-pine-hyprcursor
env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24

env = GDK_BACKEND,wayland,x11,*
env = QT_QPA_PLATFORM,wayland;xcb
env = SDL_VIDEODRIVER,wayland

env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM,wayland;xcb
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1

#####################
### LOOK AND FEEL ###
#####################

# Refer to https://wiki.hyprland.org/Configuring/Variables/

# https://wiki.hyprland.org/Configuring/Variables/#general
general {
gaps_in = 5
gaps_out = 5

border_size = 1

# https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors
col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border = rgba(595959aa)

# Set to true enable resizing windows by clicking and dragging on borders and gaps
resize_on_border = false

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

layout = dwindle
}

# https://wiki.hyprland.org/Configuring/Variables/#decoration
decoration {
rounding = 4

# Change transparency of focused and unfocused windows
active_opacity = 1.0
inactive_opacity = 1.0

drop_shadow = false
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)

# https://wiki.hyprland.org/Configuring/Variables/#blur
blur {
enabled = true
size = 5
passes = 1

vibrancy = 0.1696
}
}

# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
enabled = true
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
}

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

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

# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
force_default_wallpaper = 0 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = true # If true disables the random hyprland logo / anime girl background. :(
}


#############
### INPUT ###
#############

# https://wiki.hyprland.org/Configuring/Variables/#input
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =

follow_mouse = 1

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

touchpad {
natural_scroll = false
}
}

# https://wiki.hyprland.org/Configuring/Variables/#gestures
gestures {
workspace_swipe = false
}

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


####################
### KEYBINDINGSS ###
####################

# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier

# 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, E, exec, $fileManager
bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle

# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, 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

# 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

# Example special workspace (scratchpad)
bind = $mainMod, S, togglespecialworkspace, magic
bind = $mainMod SHIFT, S, movetoworkspace, special:magic

# 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

# lock
bind = $mainMod, l, exec, hyprlock

# 电源菜单
bind = $mainMod SHIFT, L, exec, wlogout

# 截图
bind = $mainMod, s, exec, grim -g "$(slurp)" $(xdg-user-dir PICTURES)/temp/$(date +'%s_grim.png') && notify-send "添加了一个截图" "在 Pictures/temp 文件夹下"

# 亮度控制
bind = , XF86MonBrightnessDown, exec, light -U 1
bind = , XF86MonBrightnessUp, exec, light -A 1

# 声音控制
bind = , XF86AudioMute, exec, amixer -q -D pulse sset Master toggle
bind = , XF86AudioRaiseVolume, exec, amixer -q -D pulse sset Master 1%+ unmute
bind = , XF86AudioLowerVolume, exec, amixer -q -D pulse sset Master 1%- unmute


##############################
### WINDOWS AND WORKSPACES ###
##############################

# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules

# Example windowrule v1
# windowrule = float, ^(kitty)$

# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$

windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.

# unscale XWayland
xwayland {
force_zero_scaling = true
}

# toolkit-specific scale
env = GDK_SCALE,2
env = XCURSOR_SIZE,32

设置一些 xwayland 运行的应用在 wayland 下运行

1
2
3
4
5
6
7
8
9
10
11
env = HYPRCURSOR_THEME,rose-pine-hyprcursor
env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24

env = GDK_BACKEND,wayland,x11,*
env = QT_QPA_PLATFORM,wayland;xcb
env = SDL_VIDEODRIVER,wayland

env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM,wayland;xcb
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1

设置 electron 应用使用 wayland
PATH: .config/electron-flags.conf

1
2
--enable-features=UseOzonePlatform
--ozone-platform=wayland

vscode 无法使用 fcitx5,可以在使用时添加 --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime,当然也可以编辑/usr/share/applications/code.desktop这个文件

体验

hyprland 有着相对 i3wm 来说过有着直接能用的动画,不像 i3wm 需要使用 picom 来实现动画,以及 waydroid 实在是方便
个人认为 wayland 相对于 x11 来说,wayland 还是有很多问题没有解决,比如 nvidia, 在比如 steam 游戏我无法启动,总的来说 wayland 现在还是处于”半成品”的状态用起来还是太麻烦了

最后还是安顿在 xfce4 上面了,从 1月份的 i3wm 和最近几天的 hyprland 发现多少都有些问题。还是 xfce4 好用些。