Archlinux下i3wm與urxvt的配置


      前段時間學習了GitHub的兩位前輩:Airblader和wlh320。他們的相關教程在https://github.com/Airblader/i3https://github.com/wlh320。本篇博客則是根據他們的教程總結出來的,當然大部分是直接扒的配置。這篇博客將告訴你如何配置一個漂亮的i3wm界面以及支持透明的urxvt。當然我這個透明是在i3wm下的,應該還會有別的通用方法,如果各位知道,請發到我的郵箱,感激不盡!

1 urxvt的基本配置

1.1 安裝及配置文件

urxvt是一個輕量級的終端,功能不是很多,但是用着很舒服。在Archlinux下安裝它的命令為:

 #pacman -S urxvt  

它的配置文件在$HOME/.Xresources這個文件中。

1.2 配置文件代碼

 1 !!$HOME/.Xresources
 2 URxvt.preeditType:Root
 3 !!調整此處設置輸入法
 4 URxvt.inputMethod:fcitx
 5 !!顏色設置
 6 URxvt.depth:32
 7 !!中括號內數表示透明度
 8 URxvt.inheritPixmap:true
 9 URxvt.background:#000000
10 URxvt.foreground:#ffffff
11 URxvt.colorBD:Gray95
12 URxvt.colorUL:Green
13 URxvt.color1:Red2
14 URxvt.color4:RoyalBlue
15 URxvt.color5:Magenta2
16 URxvt.color8:Gray50
17 URxvt.color10:Green2
18 URxvt.color12:DodgerBlue
19 URxvt.color14:Cyan2
20 URxvt.color15:Gray95
21 !!URL操作
22 URxvt.urlLauncher:chromium
23 URxvt.matcher.button:1
24 Urxvt.perl-ext-common:matcher
25 !!滾動條設置
26 URxvt.scrollBar:False
27 URxvt.scrollBar_floating:False
28 URxvt.scrollstyle:plain
29 !!滾屏設置
30 URxvt.mouseWheelScrollPage:True
31 URxvt.scrollTtyOutput:False
32 URxvt.scrollWithBuffer:True
33 URxvt.scrollTtyKeypress:True
34 !!光標閃爍
35 URxvt.cursorBlink:True
36 URxvt.saveLines:3000
37 !!邊框
38 URxvt.borderLess:False
39 !!字體設置
40 Xft.dpi:96
41 URxvt.font:xft:Source Code Pro:antialias=True:pixelsize=18,xft:WenQuanYi Zen Hei:pixelsize=18
42 URxvt.boldfont:xft:Source Code Pro:antialias=True:pixelsize=18,xft:WenQuanYi Zen Hei:pixelsize=18
View Code

1.3 終端提示符配置

寫完.Xresources文件后,urxvt的終端提示符是黑白的,如何將提示符變成彩色的呢?詳情參考我的另一篇博客:終端提示符的配置

我的設置如下($HOME/.bashrc):

 PS1='\[\033[31m\]\h\[\033[34m\]@\u:\[\033[0;32m\]\w\[\033[33m\]>>> \[\033[0m\]' 

1.4 生效

改完了以上的內容,還缺少一步,讓這個設置生效。我是直接把這個命令寫進i3wm的啟動配置文件$HOME/.xinitrc里了:

 xrdb -load ~/.Xresources

現在除了透明,其他都不錯的。

2 i3wm的配置

2.1 安裝及配置文件

i3wm是一個平鋪式桌面管理器,Archlinux下載如下:

 #pacman -S i3wm 

它的配置文件是$HOME/.config/i3/config。它的語法規則可以查看i3wm官方手冊

2.2 配置文件代碼

 如果你沒有找到這個config文件,則把/etc/i3/config這個文件復制過去,或者是直接運行命令

 #i3-config-wizard 

這時候$HOME/.config/i3/config文件里的配置是比較基本的,這里介紹一下我添加的一些功能,或者是美化的部分。

首先要清楚的是i3wm的特色是可以綁定各種快捷鍵,當然大部分是與mod有關,mod鍵可以由用戶設定,可以是alt(Mod1)或者是win(Mod4)。

介紹幾種實用的改進:

•設置win鍵為mod鍵,在配置文件里添加:

 set $mod Mod4 

•win+enter鍵啟動urxvt,透明啟動哦!

這里如果要想urxvt透明,先得安裝compton,並且在配置文件里設置自啟,安裝如下

 #pacman -S compton 

透明啟動urxvt,在配置文件里添加:

  exec --no-startup-id compton -b #開機自啟

  bindsym $mod+Return exec urxvt -sh 40 #透明參數0-100  

•設置壁紙,首先安裝feh,同樣的pacman,這里不再贅述,安裝完成后添加:

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

•按鍵盤上的print鍵全屏截圖,按win+print鍵用戶自選區域截圖,需要安裝shutter,pacman搞定,然后添加:

 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官網手冊來自己寫。下面介紹三處較大改進的地方。

2.3 工作區的配置

下面的代碼可以實現將我比較常用的軟件在用戶設定的工作區打開,下面是代碼:

 1 #打開URxvt的同時切換到tab模式
 2 for_window [class="URxvt"] layout tabbed
 3 
 4 #打開軟件時自動移至相應工作區
 5 assign [class="URxvt"] $WS1
 6 assign [class="Thunar"] $WS1
 7 assign [class="Firefox"] $WS2
 8 assign [class="Zathura"] $WS3
 9 assign [class="Gvim"] $WS4
10 assign [class="Ise"] $WS5
11 assign [class="VirtualBox"] $WS6
View Code

2.4 電源管理

win+c可以調出選項,你可以選擇鎖屏(L),注銷(O),重啟(R),關機(S),退出選項(Esc)。

 1 #*********************************************電源管理*************************************
 2 set $mode_system  lock(L) logout(O) reboot(R) shutdown(S) exit(Esc)
 3 bindsym $mod+c mode "$mode_system"
 4 mode "$mode_system" {
 5     bindsym l exec --no-startup-id i3lock -c '#000000', mode "default"
 6     bindsym o exec --no-startup-id i3-msg exit, mode "default"
 7     bindsym r exec --no-startup-id systemctl reboot, mode "default"
 8     bindsym s exec --no-startup-id systemctl poweroff, mode "default"
 9     bindsym Escape mode "default"
10 }
View Code

2.5 主題設置

將i3bar美化,這里要用到腳本文件jconky以及i3bar美化文件conkyrc,后面我會貼下載地址,當然也可以按照下面的代碼寫一份。文件需要移至$HOME/.config/i3/下。

注意:這里需要安裝ttf-font-awesome字體(點擊下載),AUR里有。且這里要安裝conky

jconky:

 1 #!/bin/sh
 2  
 3 # Send the header so that i3bar knows we want to use JSON:
 4 echo '{"version":1}'
 5  
 6 # Begin the endless array.
 7 echo '['
 8  
 9 # We send an empty first array of blocks to make the loop simpler:
10 echo '[],'
11  
12 # Now send blocks with information forever:
13 exec conky -c ~/.config/i3/conkyrc
View Code

conkyrc

 1 out_to_x no
 2 out_to_console yes
 3 background no
 4 double_buffer no
 5 update_interval 1
 6 total_run_times 0
 7 override_utf8_locale no
 8 short_units yes
 9 if_up_strictness address
10 cpu_avg_samples 2
11 
12 TEXT
13 [
14 #{ "full_text" : "", "color": "\#BADA55"},
15 #{ "full_text": " ${exec curl icanhazip.com}"},
16 { "full_text" : ${if_up eno1}"  ${upspeed eno1}/s  ${downspeed eno1}/s"${else}""${endif}, "color" : "\#94F397" },
17 { "full_text" : ${if_up wlo1}"  ${upspeed wlo1}/s  ${downspeed wlo1}/s"${else}""${endif}, "color" : "\#94F397" },
18 { "full_text" : " ${cpu cpu0}%" , "color" : "\#8BC3E7" },
19 { "full_text" : " ${mem}" , "color" : "\#B987D9" },
20 { "full_text" : " ${fs_used_perc /}%" , "color" : "\#FF9D17" },
21 { "full_text" : " ${battery_percent}%" , "color" : "\#A4DC6A" },
22 { "full_text" : " ${time %Y/%m/%d %a}" , "color" : "\#ff797b" },
23 { "full_text" : " ${time %H:%M}" , "color" : "\#8BADF9" }
24 ],
View Code

config代碼

 1 #**************************************************主題設置*********************************************
 2 # 窗口顏色                邊框    背景    文字    提示
 3 client.focused          #333333 #333333 #FFFFFF #333333
 4 client.focused_inactive #999999 #999999 #FFFFFF #3399FF
 5 client.unfocused        #999999 #999999 #FFFFFF #3399FF
 6 client.urgent           #990000 #990000 #FFFFFF #990000
 7 client.placeholder      #000000 #000000 #FFFFFF #000000
 8 client.background       #FFFFFF
 9 
10 #i3bar設置
11 bar {
12     i3bar_command i3bar -t
13     height 28
14     #禁止systemtray
15     tray_output none
16     # i3bar調用
17     status_command ~/.config/i3/jconky
18     # 顯示位置top/bottom
19     position bottom
20     # 是否隱藏
21     #mode hide
22     # 拆解工作區名(隱藏前面的1:2:3:……)
23     strip_workspace_numbers yes
24     # 定義分隔符∥
25     separator_symbol ""
26 
27     colors {
28         background #10101000
29         statusline #FFFFFF
30         separator  #3399FF
31         # 工作區顏色         邊框    背景    文字
32         focused_workspace  #3297FD #11111100 #FFFFFF
33         active_workspace   #FFFFFF #FFFFFF00 #FFFFFF
34         inactive_workspace #111111 #11111100 #FFFFFF
35         urgent_workspace   #990000 #11111100 #FFFFFF
36         binding_mode       #990000 #99000000 #FFFFFF
37     }
38 }
View Code

注:i3bar_command i3bar -t的-t參數實現i3bar的透明,前提是安裝了i3gap,沒有則不用-t。

2.6 i3gaps

可以透明化i3bar,也可以在使窗口之間設定透明間隔,安裝和編譯可以參考https://github.com/Airblader/i3

安裝具體如下:

•首先在github下載文件,在bash中執行

 #git clone https://github.com/Airblader/i3 ~/i3-gaps --將文件下載到~/i3-gaps文件夾中 

•進入i3-gaps目錄,進行編譯,執行:

 #make && make install 

安裝完成后,貼下config設置:

 1 #********************************************i3-gaps*********************************
 2 for_window [class="^.*"] border pixel 0
 3 gaps inner 8
 4 gaps outer 6
 5 set $mode_gaps Gaps: (o) outer, (i) inner
 6 set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
 7 set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
 8 bindsym $mod+Shift+g mode "$mode_gaps"
 9 
10 mode "$mode_gaps" {
11         bindsym o      mode "$mode_gaps_outer"
12         bindsym i      mode "$mode_gaps_inner"
13         bindsym Return mode "default"
14         bindsym Escape mode "default"
15 }
16 
17 mode "$mode_gaps_inner" {
18         bindsym plus  gaps inner current plus 5
19         bindsym minus gaps inner current minus 5
20         bindsym 0     gaps inner current set 0
21 
22         bindsym Shift+plus  gaps inner all plus 5
23         bindsym Shift+minus gaps inner all minus 5
24         bindsym Shift+0     gaps inner all set 0
25 
26         bindsym Return mode "default"
27         bindsym Escape mode "default"
28 }
29 mode "$mode_gaps_outer" {
30         bindsym plus  gaps outer current plus 5
31         bindsym minus gaps outer current minus 5
32         bindsym 0     gaps outer current set 0
33 
34         bindsym Shift+plus  gaps outer all plus 5
35         bindsym Shift+minus gaps outer all minus 5
36         bindsym Shift+0     gaps outer all set 0
37 
38         bindsym Return mode "default"
39         bindsym Escape mode "default"
40 }
View Code

3 效果圖

說了這么多,終於到了秀桌面的時候了么,這些都是shutter截的圖哦!

各個工作區截圖:

工作區1,urxvt和thunar

工作區2,firefox

工作區3,Zathura,一個pdf閱讀器,用法有着vim的特色

工作區4,gvim

..........

4 相關文件下載

•font-awesome:開源的圖標字體,可通過簡單地復制粘貼使用,具體查看http://fontawesome.io/cheatsheet/

•urxvt配置文件下載:click here

•i3wm相關配置文件下載:click here

完...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM