Conky

conky - 如何設置硬寬度限制

  • August 23, 2020

我正在將我的垂直 conky 更改為橫穿螢幕頂部的水平 conky 條。

對於Name and CPU %,如何設置最大寬度列?我需要設置一個固定的寬度,Name CPU%所以我將下一列帶出它並帶有偏移量。現在它會自動擴展到終端邊緣的末端。

在此處輸入圖像描述

conky.text = [[
${alignc} Darin's Computer <<<Gentoo>>> on $machine
$stippled_hr
${alignc}${color}Uptime:${color} $uptime ${color}
${voffset 10}${color }${color}CPU Temperature: ${color white}${exec sensors | grep Tctl | cut -c16-17} c
${color yellow}${cpugraph cpu0 40,500ffff00 ffffff}
${voffset -67} ${offset 545}${color }RAM Usage:${color white} $memperc
${offset 550}${color}${color yellow}${membar 8,500 /}
${offset 550}${color}File Systems:${color white} ${fs_used_perc /}
${offset 550}${color yellow}${fs_bar 8,500 /}

$color$stippled_hr

${voffset -105}${offset 1130}${color}Name       ${alignr}CPU o/o #HERE IS WHERE I NEED TO SET A HARD WIDTH
${offset 1130}${color white} ${top name 1} ${alignr}${top cpu 1}
${offset 1130}${color yellow} ${top name 2} ${alignr}${top cpu 2}
${offset 1130}${color yellow} ${top name 3} ${alignr}${top cpu 3}
${offset 1130}${color yellow} ${top name 4} ${alignr}${top cpu 4}

${color}$stippled_hr

${offset 1300}${color}Networking:
Down:${color white} ${downspeed enp2s0} k/s${color white}
${color yellow}${downspeedgraph enp2s0 10,150 ffffff}
${color}${offset 5}Up:${color white} ${upspeed enp2s0} k/s
${color yellow}${upspeedgraph enp2s0 10,150 ffffff}

${color}Port(s) and Connections 
$color Inbound: ${color white}${tcp_portmon 1 32767 count} ${color} Outbound: ${color white}${tcp_portmon 32768 61000 count}  ${color}ALL: ${color white}${tcp_portmon 1 65535 count}
${color}Inbound Con. ${alignr} Port${color white}
${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}

一種方法是使用tab對象來定位右側標題並使用偏移量來定位右側列top對象。

${offset 15}${color orange}Name${tab 160 15}CPU o/o
${offset 15}${color white}${top name 1}${offset 25}${top cpu 1}
${offset 15}${color yellow}${top name 2}${offset 25}${top cpu 2}
${offset 15}${color yellow}${top name 3}${offset 25}${top cpu 3}
${offset 15}${color yellow}${top name 4}${offset 25}${top cpu 4}

conky中頂部對象的固定寬度列的插圖

引用自:https://unix.stackexchange.com/questions/605833