效果预览

本文将简要介绍i3桌面的安装、配置与美化。

正所谓“无图言屌”,先上几张桌面截图看看效果。左上角是电源菜单,并显示CPU和内存使用率;右上角显示亮度、音量、电量;左下角显示工作区,右下角显示网络状况(没错,因为我长得帅,同学们都叫我男神,宿舍wifi名也直接叫男神了,嘿嘿)以及系统托盘。

空白桌面
悬浮窗口,Neofetch一波
平铺窗口,左边LibreOffice,右边纯属装逼
全屏的chrome浏览器,注意这不是F11那种没标签页的全屏哦

安装i3

i3是一款平铺式桌面,窗口不会自动重叠,因此能够轻松的同时看到全部的窗口;此外平铺式桌面的快捷键也十分丰富,基本可以双手不离开键盘,抛弃鼠标,从而提高工作效率。

然而,平铺式桌面配置起来也是比较麻烦的,但配置好了性能也是棒棒的。既然看到这里了,说明你也是个玩Gentoo的,咱们玩Gentoo本身就是折腾,追求性能最大化啊。

i3使用的的程序,我使用这些:

  • i3-gaps——比i3美观,窗口之间可以有间隔
  • i3lock-fancy——美化的锁屏
  • i3status——底部状态栏,我用他显示网络状况和系统托盘
  • polybar——顶部状态栏,显示cpu、内存、音量、亮度、时间、电池状态
  • compton——透明终端
  • rofi——程序起动器
  • fontawesome——图标
  • terminator——终端
emerge -av i3-gaps i3lock i3status compton fontawesome rofi polybar terminator

初次登陆i3桌面,会提示创建配置文件。选择自己的mod键。我选择的是win键。本文大部分是配置文件,不便于解释,只能通过注释方式进行简单说明,具体解释可查看官方文档。(什么?官方文档被墙了?自行解决吧,这里不提供解决方案。)

配置polybar——用作i3的的状态栏

本文提及到的所有配置文件,在我的Github上均有备份,可以直接下载借鉴。

首先咱们编辑一下polybar配置文件。polybar的配置文件是[颜色设置]+[bar1]+[模块1]+[模块2]…

vim .config/polybar/config 


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

[bar/example]
monitor = ${env:MONITOR:eDP-1}
width = 100%
height = 30
radius = 0.0
fixed-center = true
background = ${colors.background}
foreground = ${colors.foreground}
;bottom = true
line-size = 0
line-color = #f00
border-top-size = 0
border-left-size = 0
border-right-size = 0
border-color = #00000000
padding-left = 0
padding-right = 2
module-margin-left = 1
module-margin-right = 2
font-0 = ttf-liberation-sans:fixed:pixelsize=12;1
font-1 = source han sans cn:pixelsize=12:antialias=false;1
font-2 = "Font Awesome 5 Free:style=Solid:pixelsize=12;1"
font-3 = "Font Awesome 5 Brands:style=Regular:pixelsize=12;1"
font-4 = "material icons:pixelsize=16;3"

modules-left = powermenu cpu memory
modules-center = date
modules-right = backlight pulseaudio battery
;左中右引用的模块

tray-position = right
tray-padding = 2
tray-background = ${colors.background}
cursor-click = pointer
cursor-scroll = ns-resize

[module/pulseaudio]
;音量显示
type = internal/pulseaudio
sink = alsa_output.pci-0000_00_1b.0.analog-stereo
; Sink to be used, if it exists (find using pacmd list-sinks, name field)
; If not, uses default sink
format-volume =
format-muted =
label-muted = ""
label-muted-foreground = #ff
ramp-volume-0 = 
ramp-volume-1 = 
ramp-volume-2 = 
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}
label-volume = %percentage%%

[module/battery]
;电量显示
type = internal/battery
battery = BAT0
adapter = ADP1
full-at = 98
format-charging =
format-charging-underline = #ffb52a
format-discharging =
;format-discharging-underline = ${self.format-charging-underline}
format-full-prefix = " "
;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-3 = 
;ramp-capacity-foreground = ${colors.foreground-alt}
animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
;animation-charging-foreground = ${colors.foreground-alt}
animation-charging-framerate = 750

[module/temperature]
;温度显示
type = internal/temperature
thermal-zone = 0
hwmon-path = /sys/devices/virtual/hwmon/hwmon0/temp2_input
warn-temperature = 60
format =
;format-underline = #f50a4d
format-warn =
;format-warn-underline = ${self.format-underline}
label = %temperature%
label-warn = %temperature%
label-warn-foreground = ${colors.secondary}
ramp-0 = 
ramp-1 = 
ramp-2 = 
;ramp-foreground = ${colors.foreground-alt}

[module/date]
;时间日期显示
type = internal/date
interval = 5
label = %date% %time%
date = " %m/%d "
time =  %H:%M %A

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

[module/memory]
;内错占用率显示
type = internal/memory
interval = 2
format-prefix = " "
;format-prefix-foreground = ${colors.foreground-alt}
;format-underline = #4bffdc
label = %percentage_used%%

[module/backlight]
;背光显示
type = internal/xbacklight
format =
label = ""
bar-width = 10
bar-indicator = |
bar-indicator-foreground = #ff
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/powermenu]
;电源菜单
type = custom/menu
label-open = 
label-open-foreground = #ff5c56
label-close =  cancel
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-0-2 = log out
menu-0-2-exec = menu-open-3
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 = shutdown now
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
menu-3-0 = log out
menu-3-0-exec = i3-msg exit
menu-3-1 = cancel
menu-3-1-exec = menu-open-0

新建一个polybar启动脚本。

!/usr/bin/env bash
killall -q polybar
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
polybar example &
echo "Bars launched…"

加可执行权限,运行脚本,查看有没有报错信息。

sudo chmod +x ~/.config/polybar/start.sh
~/.config/polybar/start.sh

配置i3主体

然后自己编辑i3的config文件。

vim ~/.config/i3/config


set $mod Mod4
#设置mod键为win键

exec --no-startup-id compton
exec --no-startup-id ss-qt5
exec --no-startup-id fcitx
exec ~/.config/polybar/start.sh
bar {
status_command i3status
colors{
background #333333
}
}
#进入桌面后的启动项

bindsym $mod+x exec XMind
bindsym $mod+g exec google-chrome-stable
bindsym $mod+Escape exec i3lock-fancy
bindsym $mod+Return exec i3-sensible-terminal
bindsym $mod+Shift+q kill
bindsym $mod+d exec rofi -show run
#快捷键设置

new_window pixel 0
use window title, but no border
bindsym $mod+t border normal 0
use no window title and a thick border
bindsym $mod+y border pixel 3
use neither window title nor border
bindsym $mod+u border none
#窗口不显示边框,美观

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 1 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 1 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 1 toggle
bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10 # increase screen brightness
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10
#声音、亮度设置

font pango:hack 13
#字体设置

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+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon 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
bindsym $mod+f fullscreen toggle
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle
bindsym $mod+space focus mode_toggle
#水平、垂直、全屏、窗口堆叠、窗口悬浮

bindsym $mod+a focus parent
#bindsym $mod+d focus child
#父窗口

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 $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
#工作区设置


bindsym F5 restart
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'"
#重启、退出i3

mode "resize" {
  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
  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
  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
#改变窗口大小

gaps inner 20
gaps outer -10
#窗口间空隙,美化用

Rofi配色修改

vim .Xresources


! ------------------------------------------------------------------------------
! ROFI Color theme
! ------------------------------------------------------------------------------
rofi.color-enabled: true
rofi.color-window: #393939, #393939, #268bd2
rofi.color-normal: #393939, #ffffff, #393939, #268bd2, #ffffff
rofi.color-active: #393939, #268bd2, #393939, #268bd2, #205171
rofi.color-urgent: #393939, #f3843d, #393939, #268bd2, #ffc39c

5 Comments

      1. 看见你在知乎上的回答了
        突然想起来就在这里评论了:ArchWiki的i3有这么一句
        > Note: i3-wm 与 i3-gaps 冲突,默认安装的是 i3-gaps (原始i3加上窗口间间隔和别的功能)。

        Avatar V

Leave a Reply

Your email address will not be published. Required fields are marked *