V4if 's Blogwebsite

i3wm平铺式桌面管理器

发表于2016-02-29
默认

i3wm,一款平铺式窗口管理器,轻量、运行速度快,可定制性高,相对于awesome配置简单,上手起来更加容易,而且平铺式管理的效果也比较好,可以参考Arch的wiki https://wiki.archlinux.org/index.php/I3

我的电脑最后配置截图
i3wm

安装i3wm

apt-get install i3 feh conky

  • i3 我们的窗口管理器
  • feh 用来设定透明的壁纸
  • conky 用来代替i3 status,定制电脑信息状态栏

常用软件

i3wm没有提供x session管理器,需要配合一些常用软件获得更好的使用效果

xfce4-terminal

终端使用xfce的默认终端xfce4-terminal
apt-get install xfce4-terminal

zsh

shell选用zsh,并配置oh-my-zsh,可以参考其GitHub https://github.com/robbyrussell/oh-my-zsh

apt-get install zsh
chsh -s /bin/zsh

thunar

文件管理器选用thunar,安装xfce桌面之后,已经安装了thunar作为file manager

smplayer

影音播放器选用smplayer
apt-get install smplayer

i3wm配置

声音管理

kali下启用声音快捷键需要额外安装alsa-utils,然后在启动i3的时候进行alsactl init初始化

apt-get install alsa-utils    # 发现alsa-utils没装,装上
alsamixer # 查看也正常,但还是没声音
alsactl init   # 由于升级,可能没初始化,初始化一下试试

网络管理

使用wicd代替NetworkManager,这两个共存会产生冲突,首先需要完全卸载NetworkManager
apt-get purge network-manager
然后安装wicd,在kali rolling中用apt-get install wicd安装一直404,于是下载tar包解压安装,参考这里 http://www.linuxfromscratch.org/blfs/view/svn/basicnet/wicd.html
安装完之后重启进来弹出"Could not connect to wicd's D-Bus interface. Check the wicd log for error messages."的提示
在终端执行update-rc.d wicd defaults重启提示消失

font awesome

下载fontawesome-webfont.ttf放到/usr/share/fonts/truetype/fontawesome/目录下,然后就可以在config里面输入font awesome字体
如何输入unicode字符参考Arch Wiki如下:

Add icons to the format strings in ~/.config/i3status/config using the unicode numbers given in the cheatsheets linked above. The input method will vary between text editors. For instance, to insert the "heart" icon (unicode number f004): 

in various gui text editors (e.g. gedit, Leafpad) and terminals (e.g. GNOME Terminal, xfce4-terminal): ctrl+shift+u, f004, Enter
in Emacs: ctrl+x, 8, Enter, f004, Enter
in Vim (while in insert mode): Ctrl+v, uf004
in urxvt: while holding Ctrl+Shift, type f004

config配置

如果找不到自己的i3配置位置是在哪里,可以在终端输入find / -name "i3"命令进行查找,我的电脑查找结果如下:
i3-config
这个时候稍微分析一下配置目录肯定位于/root/.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 http://i3wm.org/docs/userguide.html for a complete reference!

# => 开机自启
# 壁纸须先安装feh,并在此指定路径
exec --no-startup-id feh --bg-scale "/root/Pictures/Wallpapers/zoro.jpeg"
# for sound 初始化
exec --no-startup-id alsactl init
# makes i3 beautiful, and painless
exec --no-startup-id gnome-settings-daemon
# wifi manager
# exec --no-startup-id nm-applet
# exec --no-startup-id /etc/init.d/dbus start
# exec --no-startup-id /etc/init.d/wicd start
# exec --no-startup-id wicd-gtk --no-tray  #t
# apt-get remove network-manager
# thunar =>file manager
# smplayer =>media player


set $mod Mod4

# for sound control
bindsym XF86AudioRaiseVolume exec amixer set Master playback 500+
bindsym XF86AudioLowerVolume exec amixer set Master playback 500-
bindsym XF86AudioMute exec amixer set Master toggle

# 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 10
# 窗口颜色                边框    背景    文字    提示
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
#屏幕截图
bindsym Print exec scrot -e 'mv $f ~/Pictures/'
bindsym --release $mod+Print exec "scrot -s"

# 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

# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec xfce4-terminal

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

# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run
# 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

# 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

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

# 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
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

bindsym $mod+r mode "resize"

# => 系统管理(Pause Break键呼出)
set $mode_system 系统设置:锁屏(L) 注销(O) 关机(S) 重启(R) 取消(Esc)
mode "$mode_system" {
        bindsym l exec i3lock -c '#333333', exec sleep .1 && exec xset dpms force off, mode "default"
        bindsym o exec i3-msg exit
        bindsym s exec systemctl poweroff
        bindsym r exec systemctl reboot
        bindsym Escape mode "default"
    bindsym Return mode "default"
}
bindsym Pause mode "$mode_system"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
    # status_command i3status
    # i3bar调用
        status_command conky -c ~/.config/i3/conkyrc
        tray_output primary         #none | primary
        #mode hide
        workspace_buttons yes
    font pango:monospace 10, FontAwesome 10


    colors {
        background #333333
        statusline #FFFFFF
        #eparator  #3399FF
        # 工作区颜色         边框    背景    文字
        focused_workspace  #111111 #111111 #FFFFFF
        active_workspace   #FFFFFF #FFFFFF #FFFFFF
        inactive_workspace #333333 #333333 #FFFFFF
        urgent_workspace   #990000 #990000 #FFFFFF
        #binding_mode       #990000 #990000 #FFFFFF
    }
}

conky配置

我用的conky来代替i3 status作为状态栏的输出,conky配置如下:

# 不输出到X
out_to_x no
out_to_console yes
background no
double_buffer no

# 刷新时间
update_interval 1
# 运行时间,0为一直运行
total_run_times 0
# 强制uft8编码,需xft支持
override_utf8_locale no
# 缩写单位字符 比如kib->k Gib->G 默认为off
short_units yes
# 监视端口
if_up_strictness address
# cpu数据监测模式,一般选2
cpu_avg_samples 2

# wlan0

TEXT
  \
 ${upspeed eth0}/s  ${downspeed eth0}/s \
 ${cpu cpu0}% \
 ${mem} \
 ${fs_used /} \
 ${battery_percent}% \
${execi 1 amixer | grep -A10 'Master' | sed -rn 's/.*\[([0-9]+%)\].*\[(on|off)\]/\2 \1/p' | sed -n '1p' | sed 's/off.*/ /' | sed -r 's/on( [01234]?[0-9]%)/\1/' | sed -r 's/(on|) 0%/ 0%/' | sed -r 's/on//'} \
 ${time %H:%M}