前言
i3 是一种动态的平铺式窗口管理器,其灵感来自于面向开发者与资深用户的 wmii。
i3 的既定目标包括清晰可读的文档,完善的多显示器支持,基于树形结构的窗口管理,提供 vim 式的多种操作模式。 ——Archwiki
i3的窗口排布正如Archwiki所说,与一般的桌面环境不同,窗口的排布方式是平铺而非浮动,就像这样:
再来个常规的neofetch:
i3wm的绝大部分操作也都是用键盘实现的,如果有使用vim的经验就能很快转换过来 (懒癌福音)
如果你对gnome,kde等桌面环境感到了厌倦 不妨来试试i3wm
安装i3wm
安装i3wm不会和现有的桌面产生冲突 所以想试一下又怕影响到之前的桌面的伙伴们大可放心
i3在arch的官方仓库里有两个版本 一个是i3官方的i3-wm
另一个是带有gaps补丁的i3-gaps
gaps补丁实现的是窗口与窗口之间的间隙 喜欢窗口间隙的就选i3-gaps
w
我们还需要安装一些程序 以便等下能专心配置i3
软件包名 | 简介 |
---|---|
picom | 混成器,为窗口模糊和透明等提供支持 |
polybar | i3bar的替代品,比i3bar更好看 扩展性也更强 |
dmenu | 一个简单快捷的程序启动器 |
network-manager-applet | networkmanager的前端,可以在i3中实现在托盘里连接网络 |
feh | 一个图片浏览程序,在这里我们用来设置壁纸 |
betterlockscreen | 基于i3lock-color锁屏程序 |
rofi | 一个扩展性强,外观优雅的程序启动器 体验类似于utools |
建议安装一个终端模拟器(不要gnome-terminal和konsole,这两个在i3下面并不好看,也不好用)
推荐安装kitty
,alacritty
或urxvt
等终端模拟器(记得调下配置文件,这几个默认都很难看,一般来说启用透明度就很好看了)
启动i3wm
启动i3wm的方法有两种
第一种是使用登陆管理器启动(例如sddm和gdm),从gnome或者kde切换过来的可以直接用登陆管理器启动
第二种是使用xinit从tty启动到i3 在.xinitrc
中加入exec i3
后就能通过在tty中执行startx
进入i3(xinit的archwiki页面)
配置
现在 你应该进入了一个黑乎乎的界面 下面有一个bar 还会有个报错(等下会处理) 以及一个小窗口(先按照这个窗口的提示设置mod键)
设置好mod键后 按下$mod+Enter
打开你的终端模拟器
通过设置TERMINAL
环境变量来选择$mod+Enter
打开的终端模拟器
接下来就用编辑器去配置i3wm吧
编辑.config/i3/config
gaps inner 15 #设置窗口间隙,单位是像素
default_border none #关闭窗口边框
default_floating_border none # 关闭浮动窗口边框
exec_always --no-startup-id picom # 启用picom混成器
# 在i3中 exec一些不支持启动提醒的程序会导致鼠标一直在转圈圈 所以exec一律加上--no-startup-id参数
按下$mod+Shift+r
重载配置文件
i3wm的常用快捷键
$mod+Enter
打开终端模拟器$mod+Shift+r
重新加载配置文件$mod+Shift+e
退出i3$mod+Shift+q
关闭当前聚焦的窗口$mod+1-0
切换到桌面1-10$mod+j/;/k/l
向左/上/下/右切换窗口$mod+Shift+1-0
把当前窗口放到桌面1-10$mod+f
全屏当前窗口
在之后编辑完配置文件后都建议重载一次,检查是否存在错误
polybar
将polybar的配置文件范例/etc/polybar/config.ini
复制到.config/polybar/config.ini
注释掉配置文件最后的这段代码 关闭i3wm的i3bar
bar {
status_command i3status
}
在.config/i3
下创建polybar.sh
执行chmod +x ~/.config/i3/polybar.sh
给予可执行权限
!/bin/bash
# 终止正在运行的 bar 实例
killall -q polybar
# 如果你所有的 bar 都启用了 ipc,你也可以使用
# polybar-msg cmd quit
# 运行 Polybar,使用默认的配置文件路径 ~/.config/polybar/config.ini
polybar 2>&1 | tee -a /tmp/polybar.log & disown
echo "Polybar launched..."
在i3 config里插入exec_always --no-startup-id ~/.config/i3.polybar.sh
就能让polybar和i3wm一起启动
编辑.config/polybar/config.ini
,反注释tray-position = right
,启用程序托盘
壁纸
由于i3自己并没有设置壁纸的功能,我们需要用feh
来把图片填充到背景
编辑i3 config,插入exec_always --no-startup-id feh --bg-fill $图片地址
Numlock (可选)
安装numlockx
用法:numlockx on/off
开启/关闭小键盘
在i3 config中插入exec_always --no-startup-id numlockx on
可以实现自动启动小键盘
IME
参考IBus(ArchWIki)或Fcitx5(Archwiki)安装IME
在这里 jackie更推荐使用Fcitx5,IBus只有在配合gnome使用时才会使用gnome-shell的主题 在i3下IBus可以说是难看到家了
而Fcitx5能够更换主题,比IBus好多了
安装好IME并配置好环境变量后编辑i3 config
IBus
插入exec_always --no-startup-id ibus-daemon -d -r
Fcitx5
插入exec_always --no-startup-id fcitx5 -d
锁屏
使用betterlockscreen -u $图片地址
更改锁屏背景
执行betterlockscreen -l
就能锁屏 输入密码后直接回车就能解锁
在i3 config中插入bindsym $mod+Shift+x exec --no-startup-id betterlockscreen -l
后可通过mod+Shift+x锁屏
dmenu
$mod+d
可以打开dmenu,dmenu类似与一个终端,输入什么就执行什么(但是dmenu自带补全)
文件管理器
如果你是从gnome或kde来的无需担心 使用安装好的nautilus
或dolphin
即可
而从零开始安装的i3需要安装文件管理器 否则在某些需要选择文件的场景就会出问题了
nautilus
和dolphin
都是不错的选择
截图软件
jackie推荐使用flameshot
来截图 体验不亚于windows下的snipaste
在i3 config中插入bindsym $快捷键 exec --nostartup-id flameshot gui
就能用快捷键启动flameshot
结尾
希望你的i3之旅愉快 最后 jackie也贴上自己的配置文件以供参考w
i3 config
~/.config/i3/config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
# betterlockscreen
bindsym $mod+shift+x exec --no-startup-id betterlockscreen -l
# rofi
bindsym control+space exec --no-startup-id rofi -show combi
# Flameshot
bindsym $mod+shift+a exec flameshot gui
# Run polybar
exec_always --no-startup-id ~/.config/i3/polybar.sh
# Turn on numlock
exec_always --no-startup-id numlockx on
#Run chromium
bindsym $mod+c exec chromium --proxy-server=http://127.0.0.1:7891 -ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder --use-gl=egl --ozone-platform-hint-auto
# Run clash for windows
exec_always --no-startup-id cfw
# exec ibus
#exec_always --no-startup-id ibus-daemon -d -r
# exec fcitx5
exec --no-startup-id fcitx5 -d
# set background image
exec_always --no-startup-id feh --bg-fill ~/Pictures/background.png
# exec picom
exec_always --no-startup-id picom
# Set gaps
gaps inner 15
# Auto Fullscreen
smart_borders on
# Remove windows border
default_border none
default_floating_border none
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:Sarasa Mono SC 13
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
exec --no-startup-id dex --autostart --environment i3
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.
# 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
# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet
# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $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
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id dmenu_run
# A more modern dmenu replacement is rofi:
# bindcode $mod+40 exec "rofi -modi drun,run -show drun"
# There also is i3-dmenu-desktop which only displays applications shipping a
# .desktop file. It is a wrapper around dmenu, so you need that installed.
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
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"
# switch to workspace
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
# move focused container to workspace
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
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+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'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym semicolon resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
#bar {
# status_command i3status
#}
polybar config
.config/polybar/config.ini
[colors]
background = #282A2E
background-alt = #373B41
foreground = #C5C8C6
primary = #F0C674
secondary = #8ABEB7
alert = #A54242
disabled = #707880
[bar/mybar]
width = 100%
height = 24pt
radius = 6
; dpi = 96
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 3pt
border-size = 4pt
border-color = #00000000
padding-left = 0
padding-right = 1
module-margin = 1
separator = |
separator-foreground = ${colors.disabled}
font-0 = Font Awesome 5 Free Solid:style=Solid
font-1 = Font Awesome 5 Free Regular:style=Regular
font-2 = Font Awesome 5 Brands Regular:style=Regular
font-3 = Sarasa Mono SC;style=regular
modules-left = xworkspaces xwindow
modules-right =
filesystem pulseaudio memory cpu wlan eth date
cursor-click = pointer
cursor-scroll = ns-resize
enable-ipc = true
tray-position = right
tray-maxsize = 15
tray-detached = false
tray-padding = 2
tray-scale = 1.0
; wm-restack = generic
; wm-restack = bspwm
; wm-restack = i3
; override-redirect = true
[module/xworkspaces]
type = internal/xworkspaces
label-active = %name%
label-active-background = ${colors.background-alt}
label-active-underline= ${colors.primary}
label-active-padding = 1
label-occupied = %name%
label-occupied-padding = 1
label-urgent = %name%
label-urgent-background = ${colors.alert}
label-urgent-padding = 1
label-empty = %name%
label-empty-foreground = ${colors.disabled}
label-empty-padding = 1
[module/xwindow]
type = internal/xwindow
label = %title:0:60:...%
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %{F#F0C674}%mountpoint%%{F-} %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.disabled}
[module/pulseaudio]
type = internal/pulseaudio
format-volume-prefix = "VOL "
format-volume-prefix-foreground = ${colors.primary}
format-volume = <label-volume>
label-volume = %percentage%%
label-muted = muted
label-muted-foreground = ${colors.disabled}
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
label-layout = %layout%
label-layout-foreground = ${colors.primary}
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-foreground = ${colors.background}
label-indicator-background = ${colors.secondary}
[module/memory]
type = internal/memory
interval = 2
format-prefix = "RAM "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%
[module/cpu]
type = internal/cpu
interval = 2
format-prefix = "CPU "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%
[network-base]
type = internal/network
interval = 5
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected
[module/wlan]
type = internal/network
interface = wlp0s20f3
interval = 3.0
format-connected = <label-connected>
format-connected-prefix = " "
format-connected-prefix-foreground = #b6a49b
label-connected = %upspeed:5% %downspeed:5%
format-disconnected = <label-disconnected>
label-disconnected = not connected
label-disconnected-foreground = #66ffffff
format-padding = 0
[module/eth]
type = internal/network
interface = enp8s0
interval = 3.0
format-connected = <label-connected>
format-connected-prefix = " "
format-connected-prefix-foreground = #b6a49b
label-connected = %upspeed:5% %downspeed:5%
format-disconnected = <label-disconnected>
label-disconnected = not connected
label-disconnected-foreground = #66ffffff
format-padding = 0
[module/date]
type = internal/date
interval = 1
date = %H:%M
date-alt = %Y-%m-%d %H:%M:%S
label = %date%
label-foreground = ${colors.primary}
[settings]
screenchange-reload = true
pseudo-transparency = true
; vim:ft=dosini
jackie的polybar配置文件需要搭配font awesome5使用哦(可以在aur找到) 还有,记得修改配置文件之中的网卡为你的网卡名,不然会出问题的哦
如果Jackie没有及时回复也请不要着急
学习太忙了qwq