i3status - 為i3bar
,dzen2
,xmobar
或lemonbar
生成一個(gè)狀態(tài)行
格式: i3status [-c configfile] [-h] [-v]
選項(xiàng):
-c 指定備用配置文件路徑。 默認(rèn)情況下蓖捶,i3status按以下順序查找配置文件:
1.~/.config/i3status/config (or $XDG_CONFIG_HOME/i3status/config if set)
2./etc/xdg/i3status/config (or $XDG_CONFIG_DIRS/i3status/config if set)
3.~/.i3status.conf
4./etc/i3status.conf
描述:
i3status是一個(gè)小程序(大約1500 SLOC)刻像,用于為i3bar,dzen2并闲,xmobar细睡,lemonbar或類似程序生成狀態(tài)欄。
它通過發(fā)布極少數(shù)系統(tǒng)調(diào)用而設(shè)計(jì)為非常高效帝火,因?yàn)槿藗兺ǔOM棵敫乱淮芜@種狀態(tài)行溜徙。
這可確保即使在高負(fù)載情況下,狀態(tài)欄也能正確更新犀填。
而且蠢壹,它不會(huì)像占用相應(yīng)數(shù)量的shell命令那樣占用CPU,而是節(jié)省一點(diǎn)資源九巡。
配置:
i3status的基本思想是你可以指定應(yīng)該使用哪些“模塊”(順序指令)图贸。然后您可以使用各自的部分配置每個(gè)模塊。
對(duì)于每個(gè)模塊,您可以指定輸出格式疏日。 請(qǐng)參閱下面的完整參考偿洁。
示例配置:
general {
output_format = "dzen2"
colors = true
interval = 5
}
order += "ipv6"
order += "disk /"
order += "run_watch DHCP"
order += "run_watch VPNC"
order += "path_exists VPN"
order += "wireless wlan0"
order += "ethernet eth0"
order += "battery 0"
order += "cpu_temperature 0"
order += "load"
order += "tztime local"
order += "tztime berlin"
wireless wlan0 {
format_up = "W: (%quality at %essid, %bitrate) %ip"
format_down = "W: down"
}
ethernet eth0 {
# if you use %speed, i3status requires the cap_net_admin capability
format_up = "E: %ip (%speed)"
format_down = "E: down"
}
battery 0 {
format = "%status %percentage %remaining %emptytime"
format_down = "No battery"
status_chr = "? CHR"
status_bat = "?? BAT"
status_unk = "? UNK"
status_full = "? FULL"
path = "/sys/class/power_supply/BAT%d/uevent"
low_threshold = 10
}
run_watch DHCP {
pidfile = "/var/run/dhclient*.pid"
}
run_watch VPNC {
# file containing the PID of a vpnc process
pidfile = "/var/run/vpnc/pid"
}
path_exists VPN {
# path exists when a VPN tunnel launched by nmcli/nm-applet is active
path = "/proc/sys/net/ipv4/conf/tun0"
}
tztime local {
format = "%Y-%m-%d %H:%M:%S"
}
tztime berlin {
format = "%Y-%m-%d %H:%M:%S %Z"
timezone = "Europe/Berlin"
}
load {
format = "%5min"
}
cpu_temperature 0 {
format = "T: %degrees °C"
path = "/sys/devices/platform/coretemp.0/temp1_input"
}
disk "/" {
format = "%free"
}
如果將colors
設(shè)置為false,colors指令將禁用所有顏色沟优。
interval指令指定i3status在打印下一個(gè)狀態(tài)行之前將要休眠的時(shí)間(以秒為單位)涕滋。
Time
輸出當(dāng)?shù)貢r(shí)區(qū)的當(dāng)前時(shí)間。要使用不同的時(shí)區(qū)净神,可以設(shè)置TZ環(huán)境變量何吝,或使用tztime模塊。
有關(guān)格式字符串的詳細(xì)信息鹃唯,請(qǐng)參閱strftime(3)爱榕。
例 order: time
例 format: %Y-%m-%d %H:%M:%S
TzTime
輸出給定時(shí)區(qū)中的當(dāng)前時(shí)間。如果沒有給出時(shí)區(qū)坡慌,則使用本地時(shí)間黔酥。 有關(guān)格式字符串的詳細(xì)信息,請(qǐng)參閱strftime(3)洪橘。
系統(tǒng)的時(shí)區(qū)數(shù)據(jù)庫(kù)通常安裝在/usr/share/zoneinfo
中跪者。該路徑下的文件使得有效的時(shí)區(qū)字符串成為可能,
例如 對(duì)于/usr/share/zoneinfo/Europe/Berlin
熄求,您可以在tztime
模塊中設(shè)置時(shí)區(qū)為Europe/Berlin
渣玲。
要覆蓋您的環(huán)境的區(qū)域設(shè)置,請(qǐng)?jiān)O(shè)置區(qū)域設(shè)置選項(xiàng)弟晚。
例 order: tztime berlin
例 format: %Y-%m-%d %H:%M:%S %Z
例 timezone: Europe/Berlin
例 locale: de_DE.UTF-8
如果您想在本節(jié)中使用markup
忘衍,則會(huì)自動(dòng)轉(zhuǎn)義一個(gè)單獨(dú)的format_time
選項(xiàng)。
然后它的輸出將替換格式字符串中的%time
卿城。
示例配置(markup):
tztime berlin {
format = "<span foreground='#ffffff'>time:</span> %time"
format_time = "%H:%M %Z"
timezone = "Europe/Berlin"
}
DDate
以用戶指定的格式輸出當(dāng)前的日期枚钓。有關(guān)格式字符串的詳細(xì)信息,請(qǐng)參閱ddate(1)瑟押。
注意:沒有%. 也沒有 %X 搀捷。
例 order: ddate
例 format: %{%a, %b %d%}, %Y%N - %H
CPU Usage
從 /proc/stat (Linux) 或 sysctl(3) (FreeBSD/OpenBSD) 獲取百分比CPU使用率。
可以定義一個(gè)max_threshold
多望,以便在最后一個(gè)時(shí)間間隔內(nèi)CPU的平均值高于配置的閾值時(shí)使負(fù)載值變?yōu)榧t色嫩舟。默認(rèn)為95。
max_threshold
的輸出格式可以使用format_above_threshold
進(jìn)行定制怀偷。
可以定義一個(gè)degraded_threshold
至壤,以便在最后一個(gè)時(shí)間間隔內(nèi)CPU的平均值高于配置的閾值時(shí)將負(fù)載值變?yōu)辄S色。默認(rèn)為90枢纠。
可以使用format_above_degraded_threshold
定制高于降級(jí)閾值時(shí)的輸出格式像街。
例 order: cpu_usage
例 format: %usage
例 max_threshold: 75
例 format_above_threshold: Warning above threshold: %usage
例 degraded_threshold: 25
例 format_above_degraded_threshold: Warning above degraded threshold: %usage
Ethernt
獲取IP地址和(如果可能)給定以太網(wǎng)接口的鏈接速度黎棠。
獲得鏈接速度需要cap_net_admin功能。 使用setcap cap_net_admin=ep $(其中i3status)進(jìn)行設(shè)置镰绎。
特殊接口名稱_first_
將被系統(tǒng)中第一個(gè)非無線網(wǎng)絡(luò)接口(不包括以“l(fā)o”開頭的設(shè)備)取代脓斩。
例 order: ethernet eth0
例 format: E: %ip (%speed)
CPU-Temperature
獲取給定熱區(qū)的溫度。 可以定義一個(gè)max_threshold畴栖,以便在指定的散熱區(qū)變得太熱的情況下使溫度變成紅色随静。默認(rèn)為75攝氏度
在max_threshold以上時(shí)的輸出格式可以使用format_above_threshold進(jìn)行定制。
例 order: cpu_temperature 0
例 format: T: %degrees °C
例 max_threshold: 42
例 format_above_threshold: Warning T above threshold: %degrees °C
例 path: /sys/devices/platform/coretemp.0/temp1_input
如果溫度報(bào)告它無法讀取溫度數(shù)值吗讶,那修改一句:
path = "/sys/class/thermal/thermal_zone0/temp"
Load
獲取系統(tǒng)負(fù)載(在最后1分鐘燎猛,5分鐘和15分鐘內(nèi)等待CPU時(shí)間的進(jìn)程數(shù)量)。
可以定義一個(gè)max_threshold照皆,以便在最后一分鐘的負(fù)載平均值高于配置的閾值的情況下將負(fù)載值變成紅色重绷。 默認(rèn)為5。
max_threshold的輸出格式可以使用format_above_threshold進(jìn)行定制膜毁。
例 order: load
例 format: %1min %5min %15min
例 max_threshold: "0,1"
例 format_above_threshold: Warning: %1min %5min %15min