Conky: Modularize more generated configs

This commit is contained in:
Salt 2020-06-04 18:12:15 -05:00
parent 2dd26fcbab
commit 71020bd1b1

View File

@ -149,67 +149,69 @@ conky.config = {
EOF
}
step_text() {
local -r topitems=4
# Generate our actual functional Conky stuff
# Header
cat << 'EOF' >> "$_optout"
conky.text = [[
${font Roboto:style=Light:size=30}$alignr${no_update $nodename_short}$font
${font Roboto:style=Light:size=17}$alignr${time %I:%M %p}$font
${font Roboto:style=Light:size=12}${acpitemp}°C$alignr${time %A, %B %d, %Y}$font
EOF
cat <<- 'EOF' >> "$_optout"
conky.text = [[
${font Roboto:style=Light:size=30}$alignr${no_update $nodename_short}$font
${font Roboto:style=Light:size=17}$alignr${time %I:%M %p}$font
${font Roboto:style=Light:size=12}${acpitemp}°C$alignr${time %A, %B %d, %Y}$font
EOF
# CPU info
cat << 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}CPU$font: $freq_g GHz$alignr$cpu%
${color8}${cpugraph cpu1 36,200} ${cpugraph cpu2 36,200}
${cpugraph cpu3 36,200} ${cpugraph cpu4 36,200}$color
${color8}${top name 1}$color$alignr${top cpu 1}%
${color8}${top name 2}$color$alignr${top cpu 2}%
${color8}${top name 3}$color$alignr${top cpu 3}%
${color8}${top name 4}$color$alignr${top cpu 4}%
EOF
cat <<- 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}CPU$font: $freq_g GHz$alignr$cpu%
${color8}${cpugraph cpu1 36,200} ${cpugraph cpu2 36,200}
${cpugraph cpu3 36,200} ${cpugraph cpu4 36,200}$color
EOF
for i in $(seq $topitems); do
echo "\${color8}\${top name $i}\$color\$alignr\${top cpu $i}%" >> "$_optout"
done
# Memory info
cat << 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Memory$font: $mem / $memmax used$alignr$memperc%
${color9}${memgraph}$color
Memory$alignr$memeasyfree ${color9}${membar}$color
Swap$alignr$swapfree ${color9}${swapbar}$color
${color9}${top_mem name 1}$color$alignr${top_mem mem 1}%
${color9}${top_mem name 2}$color$alignr${top_mem mem 2}%
${color9}${top_mem name 3}$color$alignr${top_mem mem 3}%
${color9}${top_mem name 4}$color$alignr${top_mem mem 4}%
EOF
cat <<- 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Memory$font: $mem / $memmax used$alignr$memperc%
${color9}${memgraph}$color
Memory$alignr$memeasyfree ${color9}${membar}$color
EOF
if [ -n "$(swapon)" ]; then
echo "Swap\$alignr\$swapfree \${color9}\${swapbar}\$color" >> "$_optout"
fi
for i in $(seq $topitems); do
echo "\${color9}\${top_mem name $i}\$color\$alignr\${top_mem mem $i}%" >> "$_optout"
done
# Disk info
cat << 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Disk$font (R/W):$alignr${diskio /dev/sda}
${color7}${diskiograph_read /dev/sda 36,200} ${diskiograph_write /dev/sda 36,200}$color
/$alignr${fs_free /} ${color7}${fs_bar /}$color
/home$alignr${fs_free /home} ${color7}${fs_bar /home}$color
/boot$alignr${fs_free /boot} ${color7}${fs_bar /boot}$color
/boot/efi$alignr${fs_free /boot/efi} ${color7}${fs_bar /boot/efi}$color
${color7}${top_io name 1}$color$alignr${top_io io_perc 1}%
${color7}${top_io name 2}$color$alignr${top_io io_perc 2}%
${color7}${top_io name 3}$color$alignr${top_io io_perc 3}%
${color7}${top_io name 4}$color$alignr${top_io io_perc 4}%
EOF
cat <<- 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Disk$font (R/W):$alignr${diskio /dev/sda}
${color7}${diskiograph_read /dev/sda 36,200} ${diskiograph_write /dev/sda 36,200}$color
EOF
# Mountpoint detection
for mountpoint in / /home /var /usr /opt /boot /boot/efi; do
if mountpoint $mountpoint > /dev/null 2>&1; then
echo "$mountpoint\$alignr\${fs_free $mountpoint} \${color7}\${fs_bar $mountpoint}\$color" >> "$_optout"
fi
done
for i in $(seq $topitems); do
echo "\${color7}\${top_io name $i}\$color\$alignr\${top_io io_perc $i}%" >> "$_optout"
done
# Networking
cat << 'EOF' >> "$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Network$font:${alignr}Default $gw_iface${if_up wlp1s0}
wlp1s0 (U/D):$alignr${addr wlp1s0} / ${wireless_essid wlp1s0}
${color6}${upspeedgraph wlp1s0 36,200} ${downspeedgraph wlp1s0 36,200}$color$endif${if_up wlp5s0}
wlp5s0 (U/D):$alignr${addr wlp5s0} / ${wireless_essid wlp5s0}
${color6}${upspeedgraph wlp5s0 36,200} ${downspeedgraph wlp5s0 36,200}$color$endif${if_up enp0s31f6}
enp0s31f6 (U/D):$alignr${addr enp0s31f6}
${color6}${upspeedgraph enp0s31f6 36,200} ${downspeedgraph enp0s31f6 36,200}$color$endif${if_up eno1}
eno1 (U/D):$alignr${addr eno1}
${color6}${upspeedgraph eno1 36,200} ${downspeedgraph eno1 36,200}$color$endif${if_up enp0s20f0u2}
enp0s20f0u2 (U/D):$alignr${addr enp0s20f0u2}
${color6}${upspeedgraph enp0s20f0u2 36,200} ${downspeedgraph enp0s20f0u2 36,200}$color$endif
]]
EOF
cat <<-'EOF' >>"$_optout"
${color3}$hr$color
${font Roboto:style=Medium:size=9}Network$font:${alignr}Default $gw_iface${if_up wlp1s0}
EOF
for interface in $(iw dev | awk '$1=="Interface"{print $2}'); do
cat <<- EOF >>"$_optout"
$interface (U/D): \$alignr\${addr $interface} / \${wireless_essid $interface}
\${color6}\${upspeedgraph $interface 36,200} \${downspeedgraph $interface 36,200}\$color
EOF
done
echo "]]" >> "$_optout"
}
genconfig() {
log "Generating config: $_optout"