从零开始配置 i3-wm

一篇关于配置i3wm以及polybar的教程。

本教程的配置后效果图:

建议可以先阅读一些Linux图形界面相关的知识作为背景,本教程提到的所有文件可以在此仓库下载。

为什么要使用窗口管理器(WM)而不是桌面环境(DE)

优点:

  1. 比之 DE,WM 需要较少的系统资源(内存, cpu, 硬盘空间…)。
  2. WM 在各个方面都有更高的配置自由度。
  3. WM 的配置容易备份和还原

缺点:

  1. 默认情况下 WM 比 DE 丑很多。
  2. 对于新手来说,WM 的配置比较繁琐。

配置 i3-wm

下载

请务必下载 i3-gaps 而不是 i3-wm 以免部分包冲突。

基本设置

当下载完 i3-wm 后,从登录管理器选择环境为 i3。第一次登录(没检测到修改过的 i3 配置文件)时,会有一个弹出窗口进行非常基本的配置。

默认的配置文件夹路径是 ~/.config/i3/

i3 本体相关的配置应放在 ~/.config/i3/config 文件里。

在窗口管理器的环境下,绝大部分的操作可以通过键盘完成,为了避免与其他软件提供的快件键冲突,需要配置一个前导键(Leader Key)。

1
2
3
4
#++++++=定义按键变量=++++++#
#(Mod1 = Alt, Mod4 = Super/Win)
set $mod Mod4
set $m_alt Mod1

整体外观

i3 的外观配置的具体含义可以通过尝试/查询得到,个人认为这部份配置不是特别重要。

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
#++++++=外观=++++++#;
## 启动窗口后的默认配置
new_window none
new_float normal
hide_edge_borders both #隐藏窗口边缘

## 窗口间距设置(如果是小屏幕就别设置了)
# gaps inner 5
# gaps outer 5
# smart_gaps on

#%%# 颜色设置(真的没啥用)
## set primary gruvbox colorscheme colors
set $bg #282828
set $red #cc241d
set $green #98971a
set $yellow #d79921
set $blue #458588
set $purple #b16286
set $aqua #689d68
set $gray #a89984
set $darkgray #1d2021
set $white #ffffff

##class border backgr. text indicator child_border
client.focused #4c7899 #285577 #ffffff #2e9ef4 #285577
client.focused_inactive #81c2d6 #5f676a #ffffff #484e50 #0b6e48
client.unfocused #c9cabb #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #199475 #900000
client.placeholder #a2b4ba #0c0c0c #ffffff #1793d0 #0c0c0c
client.background #82abba

## 弹出窗口的设置
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable

## 默认浮动的程序(程序的名字可以在 "/usr/share/applictions" 找到)
for_window [class="Gpicview"] floating enable
for_window [class="mpv"] floating enable
for_window [class="Gimp"] floating enable
for_window [class="Xarchiver"] floating enable
for_window [class="Genymotion"] floating enable
for_window [class="Vlc"] floating enable
for_window [class="VirtualBox"] floating enable
for_window [class="Thunar"] floating enable
for_window [class="Catfish"] floating enable

## 字体设置
## sarasa mono sc nerd 是我个人比较喜欢的字体,不过含有的符号不够多,可以自己换,但是注意文件后面设置中的符号变化
font pango:Sarasa Mono SC Nerd 10

自启动应用

这里都是登录后的自启动应用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#++++++=自启动程序=++++++#
# xcompmgr: 窗口透明相关
exec --no-startup-id xcompmgr
# compton: 窗口透明相关
exec --no-startup-id compton -b
# mate-power-manager: 电池管理和屏幕亮度调节(主要用于笔记本,PC可以不用)
exec --no-startup-id mate-power-manager
# network-manager: 网络管理器(及托盘图标)
exec --no-startup-id nm-applet
# blueman: 蓝牙设置
exec --no-startup-id blueman
exec --no-startup-id blueman-applet
# polkit: 进程优先级相关
exec --no-startup-id /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &
# emacs: 如果不用 C-S 模式的 emacs(或者根本不用)就没必要开了
exec --no-startup-id emacs --daemon


# 默认在 1 号工作区打开终端
exec --no-startup-id i3-msg 'workspace 1; exec --no-startup-id sakura'

键盘快捷键

个人认为 i3 最棒的部分,可以完全定义一套自己习惯的操作快捷键

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
#++++++=快捷键=++++++#
# 应用程序启动器:drun(i3 自带),rofi(推荐)
# rofi 的主题样式可以通过更改位于 `~/.config/rofi/` 下的配置文件实现,文件名是参数 `-theme` 的值
bindsym $mod+d exec --no-startup-id dmenu_run
bindsym $m_alt+space exec --no-startup-id rofi -show drun -theme ctheme

# 终端
# 这个 sakura 终端还行,唯一问题就是不能通过键盘快捷键缩放字体,稍微有点不好
bindsym $mod+Return exec --no-startup-id sakura
bindsym $mod+z exec --no-startup-id sakura

# 浏览器
# 也不知道 chrome 的产品有什么毛病,非要把下载为 mhtml 这个选项显式地去掉,加上 `--save-page-as-mhtml` 可以开启这个功能
bindsym $mod+c exec --no-startup-id firefox
bindsym $mod+Shift+c exec --no-startup-id chromium --save-page-as-mhtml

# 文件管理器
# 这里用的是 thunar,随便换
bindsym $mod+e exec --no-startup-id thunar

# screenshot
# -u 使用当前激活的窗口, -s 手动选择窗口, -b = 选择窗口带上边缘
bindsym Print exec --no-startup-id "scrot -u -q 100 './Pictures/Screenshots/%Y%m%d_%H%M%s_$wx$h.png'"
bindsym --release Shift+Print exec --no-startup-id "scrot -bs -q 100 './Pictures/Screenshots/%Y%m%d_%H%M%s_$wx$h.png'"
bindsym --release Control+Print exec --no-startup-id "scrot -s -q 100 './Pictures/Screenshots/%Y%m%d_%H%M%s_$wx$h.png'"

# emacs
# 不用 emacs 可以把这个键另作它用
bindsym $mod+Shift+e exec --no-startup-id emacsclient -c

# VSC
# ### 注意 ### 用这个快捷键打开的 VS code 不会读取到配置在用户路径下默认shell 的 rc 文件里的环境变量,比如 Latex Workshop 的工作可能会出问题,这种情况可以通过应用启动器开启 VS code 以避免
bindsym $mod+q exec --no-startup-id code

# XMind
bindsym $mod+m exec --no-startup-id xmind

# Zotero
bindsym $mod+Shift+z exec --no-startup-id zotero

工作区设置

工作区的定义可以在这里找。

工作区

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
## 给应用程序添加默认启动到的窗口
assign [class="sakura"] 1
assign [class="code"] 2
assign [class="Firefox"] 3

## 切换工作区
bindsym $mod+Tab workspace next
bindsym $m_alt+Tab workspace prev
# bindsym $mod+Shift+Tab workspace prev

## 定义工作区的变量以方便使用
set $ws1 1
set $ws2 2
set $ws3 3
set $ws4 4
set $ws5 5
set $ws6 6
set $ws7 7
set $ws8 8
set $ws9 9
set $ws10 10

## 切换到指定工作区
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

## 移动到指定工作区
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10

焦点控制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#------=焦点控制=------#
## 移动焦点
# bindsym $mod+j focus left
# bindsym $mod+k focus down
# bindsym $mod+l focus up
# bindsym $mod+semicolon focus right

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

## 移动焦点到当前容器的父级
bindsym $mod+u focus parent
## 移动焦点到当前容器的子级
bindsym $mod+Shift+u focus child

## 使焦点跟随鼠标移动(利弊皆有,用着调吧)
focus_follows_mouse yes

## 改变窗口排列方式(贴片/浮动)
# bindsym $mod+space focus mode_toggle

窗口控制

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
#------=窗口控制=------#
## 按着 $mod 可以拖动窗口
floating_modifier $mod

## 移动窗口
# bindsym $mod+Shift+J move left
# bindsym $mod+Shift+K move down
# bindsym $mod+Shift+L move up
# bindsym $mod+Shift+colon move right
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

## 水平分割
bindsym $mod+h split h
## 竖直分割
bindsym $mod+v split v

## 切换状态栏的显隐 (polybar 不管用)
# bindsym $mod+m bar mode toggle

## 切换工作区内窗口的堆叠方式
bindsym $mod+space floating toggle
bindsym $mod+Shift+space sticky toggle

## 切换全屏
bindsym $mod+f fullscreen toggle

# 切换窗口样式
bindsym $mod+s layout stacking
bindsym $mod+t layout tabbed
bindsym $mod+a layout toggle split

## 关闭窗口(带着里面的程序)
bindsym $mod+Shift+q kill
bindsym $mod+Escape kill

## 隐藏/显示窗口(加减号)
bindsym $mod+minus move scratchpad
bindsym $mod+plus scratchpad show

## 窗口标题/边缘切换
# bindsym $mod+u border none
# bindsym $mod+n border normal
# bindsym $mod+o border 1pixel
bindsym $mod+b border toggle

控制窗口大小

i3默认不能直接用鼠标改变窗口大小,需要进入到缩放状态下操作

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
#------=缩放窗口=------#
bindsym $mod+Shift+r mode "resize"

## 缩放状态下快捷键
mode "resize" {
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow width 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt

bindsym Left resize shrink width 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt

bindsym Shift+Left resize shrink width 5 px or 5 ppt
bindsym Shift+Right resize grow width 5 px or 5 ppt
bindsym Shift+Up resize shrink height 5 px or 5 ppt
bindsym Shift+Down resize grow height 5 px or 5 ppt

bindsym Ctrl+Left resize shrink width 1 px or 1 ppt
bindsym Ctrl+Right resize grow width 1 px or 1 ppt
bindsym Ctrl+Up resize shrink height 1 px or 1 ppt
bindsym Ctrl+Down resize grow height 1 px or 1 ppt

bindsym Return mode "default"
bindsym Escape mode "default"
}

多屏幕相关设置

如果没有同时使用多屏的需求,可直接跳过本节

在开始配置本节之前,需要先正确的安装好显示适配器的驱动,否则可能会有难以解决的问题发生

可以通过一些软件如 arandr 在 GUI 下对屏幕布局进行调整,最终目的是为了获得一条 xrandr 命令。

获得命令后,可以在任意路径下(i3路径下最好)建立一个名为 screen.sh 的脚本,将得到的命令复制进去,而后在 i3 的配置文件中添加以下的这条命令。

1
2
3
#### ~/.config/i3/config

exec --no-startup-id bash ~/.config/i3/screen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#### ~/.config/i3/screen.sh

#!/bin/bash

f=$(xrandr | grep -c 'HDMI-0 connected')

if [ $f = "1" ]
then xrandr --output DP-0 --primary --mode 3840x2160 --pos 0x0 --rotate normal \
--output HDMI-0 --mode 1920x1080 --pos 3840x120 --rotate right \
--output DP-2 --mode 1920x1080 --pos 4920x487 --rotate normal \
--output DP-1 --off \
--output DP-3 --off \
--output DP-4 --off
fi

这个脚本通过检测是否插入了多屏设备(如 HDMI-0)来控制是否进行多屏操作。如果有三个及以上的屏幕,只需要判断启动一个就好,也可以手动添加 case 以适配多种应用情况。

如果想要将一些工作区默认固定在一些屏幕下,可以通过以下命令调整,屏幕(其实是显卡输出口)的名字可以通过 xrandr 命令获得

1
2
3
4
workspace 1 output DP-0
workspace 2 output DP-0
workspace 9 output HDMI-0
workspace 10 output DP-2

操作系统控制

音量、电源、息屏时间与快捷键控制

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
#++++++=操作系统控制=++++++#

# volume 这里的XF86默认对应的是笔记本键盘上的音量加减键
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

# power 这些快捷键可以自己修改
set $mode_system select: 锁屏(L) 退出用户(E) 重启(R) 关机(O) 取消(Esc)
bindsym $mod+$m_alt+Escape mode "$mode_system"
mode "$mode_system" {
bindsym l mode "default" exec --no-startup-id betterlockscreen -l blur
bindsym e exec --no-startup-id i3-msg exit, mode "default"
bindsym r exec --no-startup-id systemctl reboot, mode "default"
bindsym o exec --no-startup-id systemctl poweroff, mode "default"
bindsym Escape mode "default"
}

# 关闭屏幕 | 睡眠 | 关机 (单位:秒)
exec --no-startup-id xset dpms 1200 1200
#exec --no-startup-id xset dpms 300 1357 6789

# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork

壁纸、锁屏和会话控制

壁纸

这里使用 feh 来控制壁纸,同时这个软件只支持位图形式的图片,不支持矢量图形式的。这里使用的 Debian 系统自带的壁纸(初始为 .svg 文件,通过 inkscape 将其转为 .png)

1
2
inkscape --export-type=png /usr/share/wallpapers/FuturePrototype/contents/images/3840x2160.svg /usr/share/wallpapers/FuturePrototype/contents/images/3840x2160.png
feh --no-fehbg --bg-fill '/usr/share/wallpapers/FuturePrototypeWithLogo/contents/images/3840x2160.png'

本文未考虑动态壁纸。

会话

1
2
3
4
5
6
7
8
9
10
11
12
#++++++=会话=++++++#

# 重载 i3wm 配置(~/.config/i3/config),会在下一次登录时生效
bindsym $mod+$m_alt+c reload

# 立刻重启 i3 (会保存当前会话和窗口布局,主要用来更新 i3 配置)
bindsym $mod+$m_alt+r restart

# 退出 i3(实际是退出 X-session)
bindsym $mod+$m_alt+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

bindsym $mod+$m_alt+l mode "i3lock: Return to lock/Escape to Cancel"

锁屏

i3 支持多种锁屏软件,本文使用 betterlockscreen,同时直接把桌面作为锁屏图片。

1
2
3
4
5
6
7
8
9
10
### 首先需要用图片更新锁屏软件缓存
betterlockscreen -u '/usr/share/wallpapers/FuturePrototypeWithLogo/contents/images/3840x2160.png'

#### ~/.config/i3/config
# i3lock
mode "i3lock: Return to lock/Escape to Cancel" {
bindsym Return mode "default" exec --no-startup-id betterlockscreen -l blur
# bindsym Return mode "default" exec i3lock -i /usr/shre/wallpapers/FuturePrototype/contents/images/3840x2160.png
bindsym Escape mode "default"
}

状态栏设置

i3 支持多种状态栏,比如 i3status,i3blocks 或者 polybar。每个状态栏有很多内置组件,也可以自制然后在状态栏的配置文件中调用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## status bar
# bar {
# # status_command i3status -c ~/.config/i3/i3status.conf
# status_command i3blocks -c ~/.config/i3/i3blocks.conf
# position bottom
# mode hide
# workspace_buttons yes
# tray_padding 0
# # separator_symbol "|"
# colors {
# background #285477
# statusline #dedede
# separator #2d2d2d
# focused_workspace #636e88 #285de7 #dedfdg
# active_workspace #556677 #234567 #56ef67
# inactive_workspace #636d72 #2d2d2d #dedede
# urgent_workspace #ffffff #900000 #d23d32
# }
# #height 30
# }

## polybar
exec --no-startup-id bash ~/.config/i3/polybar/launch.sh

本文现在使用 polybar 作为状态栏,但也附了一份 i3blocks 的可行配置。

polybar

此脚本用于在所有显示器(如果有)上启用 polybar,也可以通过改写脚本实现在固定的显示器输出。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#### ~/.config/i3/polybar/launch.sh
#!/usr/bin/env bash

# 关闭现有polybar
killall -q polybar

# 等待全部关闭
while pgrep -u $UID -x polybar > /dev/null; do sleep 1; done

if type "xrandr" > /dev/null; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload mybar -c ~/.config/i3/polybar/config &
done
else
polybar --reload mybar -c ~/.config/i3/polybar/config &
fi

echo "polybars 已(重新)启动..."

Polybar 有一套自己的配置文件,同时其相关组件的配置要与系统内其他配置符合,如 mpd 的地址和端口号,还有不同网卡的名称等。

如果想要在 polybar 的工作区标题附近显示 符号,请运行以下脚本。

1
2
3
4
5
6
## gic.sh
#!/bin/bash
counter=0
i3-msg -t get_workspaces | tr ',' '\n' | sed -nr 's/"name":"([^"]+)"/\1/p' | while read -r name; do
printf 'ws-icon-%i = "%s;<insert-icon-here>"\n' $((counter++)) $name
done

polybar 的主配置文件。

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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
;;; ~/.config/i3/polybar/config

[colors]
;background = ${xrdb:color0:#222}
background = #77222222
background-alt = #444
;foreground = ${xrdb:color7:#222}
foreground = #dfdfdf
foreground-alt = #555
primary = #ffb52a
secondary = #e60053
alert = #bd2c40

[bar/mybar]
monitor = ${env:MONITOR}
width = 100%
height = 35
;offset-x = 1%
;offset-y = 1%
radius = 7%
fixed-center = false
bottom = true

background = ${colors.background}
foreground = ${colors.foreground}

line-size = 5%
line-color = #f00

border-size = 0.2%
border-color = #00000000

padding-left = 0
padding-right = 1

module-margin-left = 0
module-margin-right = 1%

font-0 = Sarasa Mono SC Nerd:size=14:antialias=true;1
;; font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
;; font-2 = siji:pixelsize=10;1

modules-left = bspwm i3
modules-center = mpd
modules-right = filesystem memory cpu wlan eth battery temperature pulseaudio date

tray-position = right
tray-padding = 1
;tray-background = #0063ff

;wm-restack = bspwm
;wm-restack = i3

;override-redirect = true

;scroll-up = bspwm-desknext
;scroll-down = bspwm-deskprev

;scroll-up = i3wm-wsnext
;scroll-down = i3wm-wsprev

cursor-click = pointer
cursor-scroll = ns-resize

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;modules;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[module/xwindow]
type = internal/xwindow
label = %title:0:30:...%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock

format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
format-prefix-underline = ${colors.secondary}

label-layout = %layout%
label-layout-underline = ${colors.secondary}

label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-background = ${colors.secondary}
label-indicator-underline = ${colors.secondary}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/filesystem]
type = internal/fs
interval = 25

mount-0 = /
mount-1 = /home
mount-2 = /data

label-mounted = %mountpoint%%{F-}:%percentage_used%%
;label-mounted =  %mountpoint%%{F-}:%percentage_used%%
label-unmounted = %mountpoint% umnt
label-unmounted-foreground = #ebebeb

format-mounted-underline = #ebebeb
format-unmounted-underline = #ebebeb
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/bspwm]
type = internal/bspwm

label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2

label-occupied = %index%
label-occupied-padding = 2

label-urgent = %index%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2

label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2

; Separator in between workspaces
; label-separator = |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false


;;; NOTICE ;;;
; to show these icons on the bar, please run the script named `gic.sh` in the shell
ws-icon-0 = 1;#
ws-icon-1 = 2;
ws-icon-2 = 3;
ws-icon-3 = 4;
ws-icon-4 = 5;
ws-icon-5 = 6;
ws-icon-6 = 7;
ws-icon-7 = 8;
ws-icon-8 = 9;
ws-icon-9 = 10;

;; ws-icon-default =

; Only show workspaces on the same output as the bar
pin-workspaces = true

label-mode = %mode%
label-mode-padding = 1
label-mode-foreground = #000
label-mode-background = ${colors.primary}

; focused = Active workspace on focused monitor
label-focused = %index% %icon%
;; label-focused-foreground = #dfdfdf
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2

; unfocused = Inactive workspace on any monitor
label-unfocused = %index% %icon%
label-unfocused-padding = 2

; visible = Active workspace on unfocused monitor
label-visible = %index% %icon%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}

; urgent = Workspace with urgency hint set
label-urgent = %index%
label-urgent-background = ${colors.alert}
label-urgent-padding = 2

; Separator in between workspaces
; label-separator = |

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/mpd]
type = internal/mpd

host = 127.0.0.1
port = 7777

format-online = <label-song> <label-time> <icon-prev> <icon-seekb> <icon-stop> <toggle> <icon-seekf> <icon-next> <icon-repeat> <icon-random>
;; format-online = <label-song> <label-time> <bar-progress> <icon-prev> <icon-seekb> <icon-stop> <toggle> <icon-seekf> <icon-next> <icon-repeat> <icon-random>
;format-online = <toggle> <label-song> <icon-next>
format-offline = <label-offline>
format-offline-foreground = #66
label-offline = --------

label-song-maxlen = 20
label-song-font = 8

icon-prev = ⇐
icon-seekb = ⇠
icon-stop = 
icon-play = 
icon-pause = 
icon-next = ⇒
icon-seekf = ⇢
icon-random = 
icon-repeat = 

toggle-on-foreground = #2278ff
toggle-off-foreground = #66

bar-progress-width = 9
bar-progress-indicator = |
bar-progress-indicator-foreground = #bb
bar-progress-fill = 
bar-progress-fill-foreground = #bb
bar-progress-fill-font = 3
bar-progress-empty = 
bar-progress-empty-foreground = #44
bar-progress-empty-font = 3

label-time-foreground = #55
;; label-time-font = 8
;;; }}}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/xbacklight]
type = internal/xbacklight

format = <label> <bar>
label = BL

bar-width = 10
bar-indicator = |
bar-indicator-foreground = #fff
bar-indicator-font = 2
bar-fill = ─
bar-fill-font = 2
bar-fill-foreground = #9f78e1
bar-empty = ─
bar-empty-font = 2
bar-empty-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/backlight-acpi]
inherit = module/xbacklight
type = internal/backlight
card = intel_backlight
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = " "
format-prefix-foreground = #f90000
;; format-prefix-foreground = ${colors.foreground-alt}
format-underline = #f90000
label = %percentage:2%%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/memory]
type = internal/memory
interval = 2
format-prefix = " "
format-prefix-foreground = #7CFC00
;; format-prefix-foreground = ${colors.foreground-alt}
format-underline = #7CFC00
label = %percentage_used:2%%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/wlan]
type = internal/network
interface = wlan0
interval = 3.0

format-connected = <ramp-signal> <label-connected>
format-connected-underline = #9f78e1
label-connected = %essid%

format-disconnected =
;format-disconnected = <label-disconnected>
;format-disconnected-underline = ${self.format-connected-underline}
;label-disconnected = %ifname% disconnected
;label-disconnected-foreground = ${colors.foreground-alt}

ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 
ramp-signal-foreground = #9f78e1
;; ramp-signal-foreground = ${colors.foreground-alt}

;; ramp-signal-0 = 
;; ramp-signal-1 = 
;; ramp-signal-2 = 
;; ramp-signal-3 = 
;; ramp-signal-4 = 
;; ramp-signal-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/eth]
type = internal/network
interface = eth0
interval = 3.0

format-connected-underline = #55aa55
format-connected-prefix = " "
format-connected-prefix-foreground = #55aa55
;; format-connected-prefix-foreground = ${colors.foreground-alt}
label-connected = %local_ip%

format-disconnected =
;format-disconnected = <label-disconnected>
;format-disconnected-underline = ${self.format-connected-underline}
;label-disconnected = %ifname% disconnected
;label-disconnected-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/date]
type = internal/date
interval = 1

date =
date-alt = " %Y-%m-%d %A"

time = %H:%M
time-alt = %H:%M:%S

format-prefix = 
format-prefix-foreground = #0a6cf5
;; format-prefix-foreground = ${colors.foreground-alt}
format-underline = #0a6cf5

label = %date% %time%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/pulseaudio]
type = internal/pulseaudio

format-volume = <label-volume>
;; format-volume = <label-volume> <bar-volume>
format-volume-underline = #4bffdc

label-volume =  %percentage%%
label-volume-foreground = ${root.foreground}

label-muted =  muted
label-muted-foreground = #666
format-muted-underline = #4bffdc

bar-volume-width = 5
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/alsa]
type = internal/alsa

format-volume = <label-volume> <bar-volume>
label-volume = VOL
label-volume-foreground = ${root.foreground}
;; format-volume = <label-volume> <bar-volume>
;; label-volume = VOL
;; label-volume-foreground = ${root.foreground}

format-muted-prefix = " "
;; format-muted-foreground = ${colors.foreground-alt}
label-muted = sound muted

bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/battery]
type = internal/battery
battery = BAT1
adapter = ADP1
full-at = 98

format-charging = <animation-charging> <label-charging>
format-charging-underline = #ffb52a

format-discharging = <animation-discharging> <label-discharging>
format-discharging-underline = ${self.format-charging-underline}

format-full-prefix = " "
format-full-prefix-foreground = #ffb52a
;; format-full-prefix-foreground = ${colors.foreground-alt}
format-full-underline = ${self.format-charging-underline}

ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-foreground = ${colors.foreground-alt}

animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-foreground = #ffb52a
animation-charging-framerate = 750

animation-discharging-0 = 
animation-discharging-1 = 
animation-discharging-2 = 
animation-discharging-foreground = #ffb52a
animation-discharging-framerate = 750
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/temperature]
type = internal/temperature
thermal-zone = 0
warn-temperature = 60

format = <ramp> <label>
format-underline = #228B22
format-warn = <ramp> <label-warn>
format-warn-underline = ${self.format-underline}

label = %temperature-c%
label-warn = %temperature-c%
label-warn-foreground = ${colors.secondary}

ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-foreground = #228B22
;; ramp-foreground = ${colors.foreground-alt}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/powermenu]
type = custom/menu

expand-right = true

format-spacing = 1

label-open = 
label-open-foreground = ${colors.secondary}
label-close = 
label-close-foreground = ${colors.secondary}
label-separator = |
label-separator-foreground = ${colors.foreground-alt}

menu-0-0 = reboot
menu-0-0-exec = menu-open-1
menu-0-1 = power off
menu-0-1-exec = menu-open-2

menu-1-0 = cancel
menu-1-0-exec = menu-open-0
menu-1-1 = reboot
menu-1-1-exec = sudo reboot

menu-2-0 = power off
menu-2-0-exec = sudo poweroff
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[settings]
screenchange-reload = true
;compositing-background = xor
;compositing-background = screen
;compositing-foreground = source
;compositing-border = over
;pseudo-transparency = false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[global/wm]
margin-top = 5
margin-bottom = 5

; vim:ft=dosini

i3blocks

i3blocks 的主配置文件。

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
# ~/.config/i3/i3blocks.conf
# align
# color
# command
# full_text
# instance
# interval
# label
# min_width
# name
# separator
# separator_block_width
# short_text
# signal
# urgent
# Global properties
#
# The top properties below are applied to every block, but can be overridden.
# Each block command defaults to the script name to avoid boilerplate.

# Global properties
#
# The top properties below are applied to every block, but can be overridden.
# Each block command defaults to the script name to avoid boilerplate.
command=~/.config/i3/i3blocks/$BLOCK_NAME
separator_block_width=20
markup=none
separator=false

#lightred #fb4934
#red #cc241d
#green #98971a
#lightgreen #b8bb26
#yellow #d79921
#lightyellow #fabd2f
#blue #458588
#purple #b16286
#aqua #689d68


# Find your own networking interfaces by typing
# 'ip link' or 'ifconfig' in a terminal window.
# Yours are probably different than mine!

#my ethernet interface is eno1
#most people is eth0
[bandwidth]
# instance=eno1
instance=eth0
interval=5
color=#fabd2f
label=


########################
separator_block_width=1
[spacer]
separator_block_width=1
full_text=|
# color=#fb4934
########################


# [wifi]
# instance=wlan0
# interval=10
# color=#d79921
# label=
# separator_block_width=0
[bandwidth]
label=
instance=wlan0
interval=1
color=#d79921


########################
separator_block_width=1
[spacer]
separator_block_width=1
full_text=|
# color=#fb4934
########################


# CPU usage
#
# The script may be called with -w and -c switches to specify thresholds,
# see the script for details.
[cpu_usage]
label=
interval=10
min_width=100.00%
color=#fb4934


########################
separator_block_width=1
[spacer]
separator_block_width=1
full_text=|
# color=#fb4934
########################


# Temperature
#
# Support multiple chips, though lm-sensors.
# The script may be called with -w and -c switches to specify thresholds,
# see the script for details.
[temperature]
label=
interval=10
color=#fabd2f


########################
separator_block_width=1
[spacer]
separator_block_width=1
#full_text=
full_text=|
# color=#fb4934
########################


# Memory usage
#
# The type defaults to "mem" if the instance is not specified.
[memory]
label=
interval=20
color=#b8bb26


########################
separator_block_width=1
[spacer]
separator_block_width=1
#full_text=
full_text=|
# color=#fb4934
########################


[volume_pactl]
label=
# instance=Master
interval=1
color=#fb4934
# signal=10


########################
separator_block_width=1
[spacer]
separator_block_width=1
#full_text=
full_text=|
# color=#fb4934
########################


# Disk usage
#
# The directory defaults to $HOME if the instance is not specified.
# The script may be called with a optional argument to set the alert
# (defaults to 10 for 10%).

# [disk]
# label= DU /home
# interval=30
# color=#fabd2f
# separator_block_width=0

[disk_usage]
label=
instance=/
interval=20
color=#fabd2f
separator_block_width=5

[disk_usage]
instance=/home
interval=20
color=#fabd2f


########################
separator_block_width=1
[spacer]
separator_block_width=1
#full_text=
full_text=|
# color=#fb4934
########################


# Battery indicator
#
# The battery instance defaults to 0.
[battery]
#label=BATT/
label=
instance=1
interval=20
color=#b8bb26


########################
separator_block_width=1
[spacer]
separator_block_width=1
#full_text=
full_text=|
# color=#fb4934
########################


[date]
command=date "+%a %Y-%m-%d %H:%M:%S"
interval=1
# label=
color=#fabd2f