ArchLinux开发环境第2辑——高效平铺式桌面i3个性化配置与美化

“未来将属于两种人:思想的人和劳动的人。实际上,这两种人是一种人,因为思想也是劳动。”
——维克多·雨果

贴上效果图:

^ konsole

^ VS Code - OSS

i3是一个基于Xorg的平铺式窗口管理器,高效的快捷键组合与平铺式桌面管理方式带来了更加沉浸式的工作体验,能够减少不必要的外界干扰,引领更专注、更高效的工作体验。

[注]本文假设读者已经完成了Arch Linux基础系统的安装并具有一定linux基础。

一、准备工作

(先配置archlinuxcn源并已安装yay,具体可参考我的另一篇博客

yay -S xorg xorg-xinit i3 konsole feh picom conky devilspie transset-df polybar

konsle:KDE官方终端模拟器,成熟稳定、功能强大、操作友好。很多人会推荐URxvt,笔者认为它比较陈旧复杂,性能与konsole并没有明显区别,我们选择更新更成熟的konsole。
feh:一个简洁的图片工具,这里用于渲染背景图片。
picom:一个轻量级混合窗口管理器,便于在简单窗口管理器上实现较华丽的阴影、透明等效果,继承自compton,而后者又继承自xcompmgr-dana,xcompmgr-dana继承自xcompmgr。
conky:Linux系统强大的系统监测程序。
transset-df:基于Xorg一个调节窗口透明度的脚本。
devilspie:一个轻量级窗口绑定工具,用于打开指定窗口时自动调用transset-df。
rofi:类似Windows开始菜单,比dmenu配置性更强。
polybar:一个自由度极高的状态栏。

二、设置DPI

配置文件位于 $HOME/.Xresources
关于这个配置文件可以参阅Archwiki。
输入:

Xft.dpi: 192

[注]dpi具体值可以根据自己调整,一般1080P屏幕96~120,2K屏幕144~192,4K屏幕192及以上。笔者是4K-3840x2160的15.6寸屏幕,dpi设为168约为效果图中大小(较小),供参考。

三、i3基本配置

选择启动桌面环境的方式:
如果喜欢在tty的环境用startx,编辑~/.xinitrc
最后一行exec处改为

exec i3

如果使用dm,直接选择i3进入即可。
进入i3桌面,$Mod + Enter运行:

i3-config-wizard

(一般会进入时自动运行),生成i3基本配置文件。

关于i3默认基本快捷键,参考:
https://blog.csdn.net/weixin_42826353/article/details/107987791
来自官方文档中文翻译。

i3配置位于 ~/.config/i3/config

首先要清楚的是i3wm的特色是可以绑定各种快捷键,当然大部分是与mod有关,mod键可以由用户设定,可以是alt(Mod1)或者是win(Mod4)。

•设置win键为mod键,在配置文件里添加:

set $mod Mod4

配置文件里设置自启picom

exec --no-startup-id picom -b #开机自启

•win+enter键启动konsole

bindsym $mod+Return exec konsole --hide-menubar

•设置壁纸

exec_always --no-startup-id feh --bg-scale "/path/xxx.jpg"

•按键盘上的print键全屏截图,按win+print键用户自选区域截图(需要安装shutter)

bindsym Print exec shutter -f -e -o ~/Pictures/shot/%Y-%m-%d-%T.png
bindsym $mod+Print exec shutter -s -e -o ~/Pictures/shot/%Y-%m-%d-%T.png

这里表示将截图保存在~/Picture/shot/文件夹里,名字为年-月-日-时间.png格式,当然了这些自己随便设定。

•黑屏时间设定,即多久用户无操作黑屏i3wm的黑屏和屏保是一个意思,但是都得设置,如下:

先把关闭屏保功能:

exec --no-startup-id xset s 0

然后黑屏、睡眠、断电时间分别设为6000s,8000s,9000s

exec --no-startup-id xset dpms 6000 8000 9000

•win+shift+减号实现隐藏一个窗口,win+减号重新打开

bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus scratchpad show

还有很多基本的功能,请参照i3wm官网手册来自己写,也可以参照手册中文翻译

3.1 工作区的配置

下面的代码可以实现将我比较常用的软件在用户设定的工作区打开,下面是代码:

#打开URxvt的同时切换到tab模式

for_window [class="URxvt"] layout tabbed
#打开软件时自动移至相应工作区
assign [class="URxvt"] $WS1
assign [class="Thunar"] $WS1
assign [class="Firefox"] $WS2
assign [class="Zathura"] $WS3
assign [class="Gvim"] $WS4
assign [class="Ise"] $WS5
assign [class="VirtualBox"] $WS6

3.2 电源管理

win+c可以调出选项,你可以选择锁屏(L),注销(O),重启®,关机(S),退出选项(Esc)。

#*********************************************电源管理*************************************
set $mode_system  lock(L) logout(O) reboot(R) shutdown(S) exit(Esc)
bindsym $mod+c mode "$mode_system"
mode "$mode_system" {
    bindsym l exec --no-startup-id i3lock -c '#000000', mode "default"
    bindsym o exec --no-startup-id i3-msg exit, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym s exec --no-startup-id systemctl poweroff, mode "default"
    bindsym Escape mode "default"
}

3.3 i3bar美化

注意:这里需要安装ttf-font-awesome字体,可以通过pacman安装或手动安装。

~/.config/i3/jconky:

#!/bin/sh

# Send the header so that i3bar knows we want to use JSON:
echo '{"version":1}'

# Begin the endless array.
echo '['

# We send an empty first array of blocks to make the loop simpler:
echo '[],'

# Now send blocks with information forever:
exec conky -c ~/.config/i3/conkyrc.lua

~/.config/i3/conkyrc.lua

conky.config = {
        out_to_x = false,
        out_to_console = true,
        background = false,
        double_buffer = false,
        update_interval = 1,
        total_run_times = 0,
        override_utf8_locale = false,
        short_units = true,
        if_up_strictness = 'address',
        cpu_avg_samples = 2,

};

conky.text = [[
[
#{ "full_text" : "", "color": "\#BADA55"},
#{ "full_text": " ${exec curl icanhazip.com}"},
{ "full_text" : ${if_up eno1}"  ${upspeed eno1}/s  ${downspeed eno1}/s"${else}""${endif}, "color" : "\#94F397" },
{ "full_text" : ${if_up wlo1}"  ${upspeed wlo1}/s  ${downspeed wlo1}/s"${else}""${endif}, "color" : "\#94F397" },
{ "full_text" : " ${cpu cpu0}%" , "color" : "\#8BC3E7" },
{ "full_text" : " ${mem}" , "color" : "\#B987D9" },
{ "full_text" : " ${fs_used_perc /}%" , "color" : "\#FF9D17" },
{ "full_text" : " ${battery_percent}%" , "color" : "\#A4DC6A" },
{ "full_text" : " ${time %Y/%m/%d %a}" , "color" : "\#ff797b" },
{ "full_text" : " ${time %H:%M}" , "color" : "\#8BADF9" }
],
]];

[注]从conky1.10开始,conkyrc使用lua脚本呈现。
conkyrc可以使用convert.lua转换到lua脚本
https://github.com/brndnmtthws/conky/blob/master/extras/convert.lua

[注]本段代码可能会有字体问题出现乱码,安装Awesome字体后可以解决。

i3config中添加:

#**************************************************主题设置*********************************************
# 窗口颜色                边框    背景    文字    提示
client.focused          #333333 #333333 #FFFFFF #333333
client.focused_inactive #999999 #999999 #FFFFFF #3399FF
client.unfocused        #999999 #999999 #FFFFFF #3399FF
client.urgent           #990000 #990000 #FFFFFF #990000
client.placeholder      #000000 #000000 #FFFFFF #000000
client.background       #FFFFFF

#i3bar设置
bar {
    i3bar_command i3bar -t
    height 28
    #禁止systemtray
    tray_output none
    # i3bar调用
    status_command ~/.config/i3/jconky
    # 显示位置top/bottom
    position bottom
    # 是否隐藏
    #mode hide
    # 拆解工作区名(隐藏前面的1:2:3:……)
    strip_workspace_numbers yes
    # 定义分隔符∥>
    separator_symbol "  >  "

    colors {
        background #10101000
        statusline #FFFFFF
        separator  #3399FF
        # 工作区颜色         边框    背景    文字
        focused_workspace  #3297FD #11111100 #FFFFFF
        active_workspace   #FFFFFF #FFFFFF00 #FFFFFF
        inactive_workspace #111111 #11111100 #FFFFFF
        urgent_workspace   #990000 #11111100 #FFFFFF
        binding_mode       #990000 #99000000 #FFFFFF
    }
}

3.4 i3gaps
可以透明化i3bar,也可以在使窗口之间设定透明间隔
参考https://github.com/Airblader/i3
Arch Repo默认安装的即为i3-gaps

贴如下配置

#********************************************i3-gaps*********************************
for_window [class="^.*"] border pixel 0
gaps inner 8
gaps outer 6
set $mode_gaps Gaps: (o) outer, (i) inner
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym $mod+Shift+g mode "$mode_gaps"

mode "$mode_gaps" {
        bindsym o      mode "$mode_gaps_outer"
        bindsym i      mode "$mode_gaps_inner"
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

mode "$mode_gaps_inner" {
        bindsym plus  gaps inner current plus 5
        bindsym minus gaps inner current minus 5
        bindsym 0     gaps inner current set 0

        bindsym Shift+plus  gaps inner all plus 5
        bindsym Shift+minus gaps inner all minus 5
        bindsym Shift+0     gaps inner all set 0

        bindsym Return mode "default"
        bindsym Escape mode "default"
}
mode "$mode_gaps_outer" {
        bindsym plus  gaps outer current plus 5
        bindsym minus gaps outer current minus 5
        bindsym 0     gaps outer current set 0

        bindsym Shift+plus  gaps outer all plus 5
        bindsym Shift+minus gaps outer all minus 5
        bindsym Shift+0     gaps outer all set 0

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

devispie配置:

~/.devilspie/opacity.ds

( if
  ( or
    ( contains ( window_class ) "Gvim" )
    ( contains ( application_name ) "Konsole" )
    ( contains ( application_name ) "Code - OSS" )
  )
  ( begin
    ( spawn_async (str "transset-df -t -i " (window_xid)  ))
  )
  )

关于阴影等设置,可以参考 Archwiki - picom

关于中文输入法,可以参考 Archwiki - Fcitx我的前一篇文章

关于终端,笔者使用的是fish,一种交互式Shell,使用oh-my-fish美化。fish语法与bash、zsh有巨大的区别(zsh基本完全向下兼容bash),从zsh更换需要谨慎。

关于壁纸,笔者壁纸来自Apple.Inc,为Mojave-Night。

关于i3config、polybar、conkyrc、devilspie语法,读者可以自主深入理解。

polybar文件再此直接贴出:

[colors]
background = #000020
background-alt = #444
foreground = #dfdfdf
foreground-alt = #555
primary = #ffb52a
secondary = #e60053
alert = #bd2c40

[bar/intel]
monitor = ${env:MONITOR:eDP1}
wwidth = 100%
height = 50
;offset-x = 1%
;offset-y = 1%
;radius = 6.0
fixed-center = true

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

line-size = 3
line-color = #f00

;border-top-size = 4
;border-left-size = 4
;border-right-size = 4
;border-color = #00000000

padding-left = 0
padding-right = 2

module-margin-left = 2
module-margin-right = 2

font-0 = "Ubuntu Nerd Font:fixed:size=20;1"
font-1 = "Ubuntu Nerd Font:size=20:antialias=false;2"
font-2 = "Font Awesome 5 Free:style=Solid:pixelsize=24;1"
font-3 = "Font Awesome 5 Brands:style=Regular:pixelsize=24;1"
font-4 = "material icons:pixelsize=24;3"

modules-left = i3 xwindow
;modules-center = mpd

modules-right = alsa wlan date

;tray-position = right
;tray-padding = 2
;tray-background = ${colors.background}

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

[bar/nvidia]
monitor = ${env:MONITOR:eDP-1-1}
width = 100%
height = 50
;offset-x = 1%
;offset-y = 1%
;radius = 6.0
fixed-center = true

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

line-size = 3
line-color = #f00

;border-top-size = 4
;border-left-size = 4
;border-right-size = 4
;border-color = #00000000

padding-left = 0
padding-right = 2

module-margin-left = 2
module-margin-right = 2

font-0 = "Ubuntu Nerd Font:fixed:size=20;1"
font-1 = "Ubuntu Nerd Font:size=20:antialias=false;2"
font-2 = "Font Awesome 5 Free:style=Solid:pixelsize=24;1"
font-3 = "Font Awesome 5 Brands:style=Regular:pixelsize=24;1"
font-4 = "material icons:pixelsize=24;3"

modules-left = i3 xwindow
;modules-center = mpd

modules-right = alsa wlan powermenu

;tray-position = right
;tray-padding = 2
;tray-background = ${colors.background}

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

[module/xwindow]
type = internal/xwindow
label = %title%
width = 50
label-maxlen = 45

[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 = /

label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}

[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

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

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

label-focused-background = ${module/bspwm.label-focused-background}
label-focused-underline = ${module/bspwm.label-focused-underline}
label-focused-padding = ${module/bspwm.label-focused-padding}

label-unfocused-padding = ${module/bspwm.label-occupied-padding}

label-visible-background = ${self.label-focused-background}
label-visible-underline = ${self.label-focused-underline}
label-visible-padding = ${self.label-focused-padding}

label-urgent-background = ${module/bspwm.label-urgent-background}
label-urgent-padding = ${module/bspwm.label-urgent-padding} |


[module/mpd]
type = internal/mpd
format-online =  <icon-prev>  <icon-stop>  <toggle>  <icon-next>  <icon-repeat>  <label-song>

;label-offline = mpd is offline

icon-prev = 
icon-stop = 
icon-play = 
icon-pause = 
icon-next = 
icon-repeat = 
icon-repeatone = 
icon-random = 

toggle-on-foreground = #ff
toggle-off-foreground = #55

label-song-maxlen = 25
label-song-ellipsis = true


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

;format = <label> <bar>
;label = BL

;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/backlight-acpi]
;inherit = module/xbacklight
;type = internal/backlight
;card = intel_backlight

[module/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/wlan]
type = internal/network
interface = wlp2s0
interval = 3.0

format-connected = <ramp-signal>
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 = #999999

ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 
animation-packetloss-0 = ⚠
animation-packetloss-0-foreground = #ffa64c
;ramp-signal-foreground = ${colors.foreground-alt}

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

;format-connected-underline = #55aa55
;format-connected-prefix = "📶"
;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 = 5

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

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

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

;label = %date% %time%


[module/alsa]
type = internal/volume

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 = BAT0
;adapter = ADP1
;full-at = 98

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

;format-discharging = <ramp-capacity> <label-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
;warn-temperature = 60

;format = <ramp> <label>
;format-underline = #f50a4d
;format-warn = <ramp> <label-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/powermenu]
type = custom/menu
expand-right = true

format-spacing = 1

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

menu-0-0 = reboot
menu-0-0-exec = reboot
menu-0-1 = power off
menu-0-1-exec = poweroff


[settings]
screenchange-reload = true


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

完整的i3config:

~/.config/i3/config

# 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!

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:monospace 12

# 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

# 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
exec --no-startup-id compton -b
exec_always --no-startup-id feh --bg-scale "/home/allen/Pictures/MacPictures/macOS-Mojave-Night-wallpaper.jpg"
exec devilspie -a
exec --no-startup-id xset s 0
exec --no-startup-id xset dpms 6000 8000 9000
exec konsole --hide-menubar

# 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 konsole --hide-menubar

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec rofi -show run
bindsym $mod+Shift+d exec rofi -show drun
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

#*********************************************电源管理*************************************
set $mode_system  lock(L) logout(O) reboot(R) shutdown(S) exit(Esc)
bindsym $mod+c mode "$mode_system"
mode "$mode_system" {
    bindsym l exec --no-startup-id i3lock -c '#000000', mode "default"
    bindsym o exec --no-startup-id i3-msg exit, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym s exec --no-startup-id systemctl poweroff, mode "default"
    bindsym Escape mode "default"
}

# 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"

#********************************************i3-gaps*********************************
for_window [class="^.*"] border pixel 0
gaps inner 8
gaps outer 6
set $mode_gaps Gaps: (o) outer, (i) inner
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym $mod+Shift+g mode "$mode_gaps"

mode "$mode_gaps" {
        bindsym o      mode "$mode_gaps_outer"
        bindsym i      mode "$mode_gaps_inner"
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

mode "$mode_gaps_inner" {
        bindsym plus  gaps inner current plus 5
        bindsym minus gaps inner current minus 5
        bindsym 0     gaps inner current set 0

        bindsym Shift+plus  gaps inner all plus 5
        bindsym Shift+minus gaps inner all minus 5
        bindsym Shift+0     gaps inner all set 0

        bindsym Return mode "default"
        bindsym Escape mode "default"
}
mode "$mode_gaps_outer" {
        bindsym plus  gaps outer current plus 5
        bindsym minus gaps outer current minus 5
        bindsym 0     gaps outer current set 0

        bindsym Shift+plus  gaps outer all plus 5
        bindsym Shift+minus gaps outer all minus 5
        bindsym Shift+0     gaps outer all set 0

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

#**************************************************主题设置*********************************************
# 窗口颜色                边框    背景    文字    提示
client.focused          #333333 #333333 #FFFFFF #333333
client.focused_inactive #999999 #999999 #FFFFFF #3399FF
client.unfocused        #999999 #999999 #FFFFFF #3399FF
client.urgent           #990000 #990000 #FFFFFF #990000
client.placeholder      #000000 #000000 #FFFFFF #000000
client.background       #FFFFFF

#i3bar设置
bar {
    i3bar_command i3bar -t
    height 60
    #禁止systemtray
    tray_output none
    # i3bar调用
    status_command ~/.config/i3/jconky
    # 显示位置top/bottom
    position bottom
    # 是否隐藏
    #mode hide
    # 拆解工作区名(隐藏前面的1:2:3:……)
    strip_workspace_numbers yes
    # 定义分隔符
    separator_symbol "  >  "

    colors {
        background #10101000
        statusline #FFFFFF
        separator  #3399FF
        # 工作区颜色         边框    背景    文字
        focused_workspace  #3297FD #11111100 #FFFFFF
        active_workspace   #FFFFFF #FFFFFF00 #FFFFFF
        inactive_workspace #111111 #11111100 #FFFFFF
        urgent_workspace   #990000 #11111100 #FFFFFF
        binding_mode       #990000 #99000000 #FFFFFF
    }
}

全部文件附在github:
https://github.com/VanBinjieWu/dotfiles

参考资料
[1]Archwiki
https://wiki.archlinux.org/
[2]Archlinux下i3wm与urxvt的配置
https://www.cnblogs.com/vachester/p/5649813.html
[3]ArchLinux下i3wm简单配置和美化
https://blog.csdn.net/r8l8q8/article/details/103889972

本文图片来自Bing/CSDN,由公众号工程实战派整理编写。
本文遵照Creative-Commons 4.0协议发表。

CSDN导航页:
https://blog.csdn.net/weixin_42826353/article/details/107884463

欢迎关注我的微信公众号,获取持续推送与资料分享!
在这里插入图片描述

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值