conky驱动信息,在某些情况下更改totalbar颜色

时间:2018-10-06 14:01:03

标签: conky

我有一个简洁的脚本,显示驱动器信息,已用百分比, 当前使用的数量和总大小

每个驱动器名称下都有一个总条,我想更改颜色 如果总数大于90%,则显示为红色

对于最高的cpu / mem部分,我为top4进程运行top命令,并将top1设置为红色

我是否需要某种if语句来对驱动器的总条进行此操作?不确定conky中的语句如何处理。

enter image description here

这是我当前的脚本

use_xft yes
xftfont 123:size=8
xftalpha 0.1
update_interval 1
total_run_times 0

own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour 000000
own_window_argb_visual yes
own_window_argb_value 0

double_buffer yes
#minimum_size 250 5
#maximum_width 500
draw_shades no
draw_outline yes
draw_borders no
draw_graph_borders no
default_color 000000
default_shade_color 000000
default_outline_color 99ddff

alignment top_left
gap_x 0
gap_y 320
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale yes
use_spacer yes


minimum_size 0 0
TEXT
${font GE Inspira:pixelsize=25}
${color }CPU:  ${color }$cpu% 
${color 99ddff}${cpubar 5,150}
${color }MEM:  ${color }$memperc% $mem/$memmax
${color 99ddff}${membar 5,150}

${color }SWAP: ${color }$swapperc% $swap/$swapmax
${color 99ddff}${swapbar 5,150}
${color }ROOT: ${color }${fs_used_perc /}% ${fs_free /}/${fs_size /}
${color 99ddff}${fs_bar 5,150 /}
${color }HOME: ${color }${fs_used_perc /home/brian/}% ${fs_free /home/brian/}/${fs_size /home/brian/}
${color 99ddff}${fs_bar 5,150 /home/brian/}
${color }MOVIES: ${color }${fs_used_perc /media/brian/Movies/}% ${fs_free /media/brian/Movies/}/${fs_size /media/brian/Movies/}
${color 99ddff}${fs_bar 5,150 /media/brian/Movies}
${color }ANIME: ${color }${fs_used_perc /media/brian/Anime/}% ${fs_free /media/brian/Anime/}/${fs_size /media/brian/Anime/}
${color 99ddff}${fs_bar 5,150 /media/brian/Anime}
${color }TV SHOWS: ${color }${fs_used_perc /media/brian/Tv Shows/}% ${fs_free /media/brian/Tv Shows/}/${fs_size /media/brian/Tv Shows/}
${color 99ddff}${fs_bar 5,150 /media/brian/Tv Shows}

1 个答案:

答案 0 :(得分:0)

Conky对象if_match是关键。例如...

${if_match ${fs_used_perc /media/brian/Tv Shows/} > 90}${color red}${else}${color 99ddff}${endif}${fs_bar 5,150 /media/brian/Tv Shows}

有关更多信息,请参见man conky