FreeBSD and Conky

Greetings friends...

I am adjusting the Conky configuration file and I have it almost ready, but I don't know how to put the name of the network card so that its name is automatically selected.

Thanks in advance for your help!

This is the specific part of the problem:

Code:
${if_up re0}\
$color2$alignr${downspeedgraph re0 20,100}$color3${upspeedgraph re0 20,100}
$color ${alignc}Down ${downspeed re0} | Up ${upspeed re0}
${color}${alignc}Total Down ${totaldown re0} | Total Up ${totalup re0}

This is my current configuration file and it looks great, but I have to manually write re0

$ cat ~/.conkyrc

Code:
-- https://github.com/brndnmtthws/conky/blob/main/data/conky.conf

-- this is a comment

--[[
first comment line
second comment line
]]

conky.config = {

 -- conky configuration

    alignment = 'middle_right',
    background = false,
    border_inner_margin = 30,
    border_outer_margin = 0,
    border_width = 1,
    cpu_avg_samples = 2,
    color1 = '#00ff00',
    color2 = '#198844',
    color3 = '#cc342b',
    color4 = '#3971ed',
 -- default_color = '#c5c8c6',
    default_color = '#1AC2FF',
    default_outline_color = 'white',
    default_shade_color = 'white',
    double_buffer = true,
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'Fantasque Sans Mono:size=8',
    gap_x = 30,
    gap_y = 0,
    maximum_width = 260,
    minimum_height = 5,
    minimum_width = 5,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,

    own_window = true,
    own_window_transparent = false,
    own_window_argb_visual = true,
    own_window_argb_value = 50,
    own_window_class = 'Conky',
    own_window_type = 'desktop',
    own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager,below',

    stippled_borders = 0,
    top_name_width = 10,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = false,
    show_graph_range = false
}

conky.text = [[

## Output

${font Cantarell:size=48}${time %H:%M}$font
$alignc${font Roboto:style=Light:size=18}${time %a %d %B}$font
#${color}$alignc $nodename
${color}$alignc $nodename_short

${color1}CPU:
${color}Core 0: -> ${cpu cpu0}% ${alignr} $color2${cpugraph cpu0 10,100}
${color}Core 1: -> ${cpu cpu1}% ${alignr} $color2${cpugraph cpu1 10,100}
${color}Core 2: -> ${cpu cpu2}% ${alignr} $color2${cpugraph cpu2 10,100}
${color}Core 3: -> ${cpu cpu3}% ${alignr} $color2${cpugraph cpu3 10,100}
${color}Core 4: -> ${cpu cpu4}% ${alignr} $color2${cpugraph cpu4 10,100}
${color}Core 5: -> ${cpu cpu5}% ${alignr} $color2${cpugraph cpu5 10,100}

${color1}RAM:
$color3$alignr${memgraph 30,200}
$color3$alignr${membar 6,200}
${color} ${alignr}${mem} / ${memmax} ${color3} / ${memperc}%

${color1}SWAP:
$color3$alignr${swapbar 6,200}
${color} ${alignr}${swap} / ${swapmax} ${color3} / ${swapperc}%

${color1}Partitions:
$color / $color${fs_used /} / ${fs_size /} $color4 $alignr ${fs_bar 6,40 /}
$color /var $color${fs_used /var} / ${fs_size /var} $color4 $alignr ${fs_bar 6,40 /var}
$color /tmp $color${fs_used /tmp} / ${fs_size /tmp} $color4 $alignr ${fs_bar 6,40 /tmp}
$color /home $color${fs_used /home} / ${fs_size /home} $color4 $alignr ${fs_bar 6,40 /home}

${color1}Uptime and Processes:
${color}Uptime:$color $uptime
${color}Processes:$color $processes  ${color}Running:$color $running_processes

${color1}Top 3 sorted by CPU usage:
${color1}NAME $alignr PID      CPU%  MEM%
${color}${top name 1} $alignr ${top pid 1} ${top cpu 1} ${top mem 1}
${color}${top name 2} $alignr ${top pid 2} ${top cpu 2} ${top mem 2}
${color}${top name 3} $alignr ${top pid 3} ${top cpu 3} ${top mem 3}

${color1}Top 3 sorted by MEM usage:
${color1}NAME $alignr PID      CPU%  MEM%
${color} ${top_mem name 1} $alignr ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color} ${top_mem name 2} $alignr ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color} ${top_mem name 3} $alignr ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}

${color1}CPU (freq, temp) and GPU (used, temp):
${color}CPU Frequency: ${alignr} ${freq_g}GHz
${color}Core0 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.0.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}Core1 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.1.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}Core2 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.2.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}Core3 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.3.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}Core4 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.4.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}Core5 Temperature: ${alignr} ${execi 30 sysctl -n dev.cpu.5.temperature | cut -c 1-2}${exec echo $'\xe2\x84\x83'}
${color}GPU Utilization:   $alignr ${execi 30 nvidia-settings -q [gpu:0]/GPUUtilization | awk '{print $4}' | grep graphics | cut -c 10-13 | sed 's/,//'}%
${color}GPU Temperature:   $alignr ${execi 30 nvidia-settings -q [gpu:0]/GPUCoreTemp | grep '):' | awk '{print $4}' | sed 's/\.//'}${exec echo $'\xe2\x84\x83'}

${color1}Networking:
${if_up re0}\
${color}IPv6: $alignr ${exec ifconfig $(ifconfig -l | awk '{print $1}') | grep 'inet6' | sed '1d' | awk '{print $2}'} prefix ${exec cat /etc/rc.conf | grep ifconfig | grep 'inet6' | tail -c -4 | cut -c 1-2}
${color}IPv4: $alignr ${exec ifconfig $(ifconfig -l | awk '{print $1}') | grep 'inet ' | awk '{print $2}'} prefix ${exec cat /etc/rc.conf | grep ifconfig | grep 'inet ' | tail -c -4 | cut -c 1-2}
$color2$alignr${downspeedgraph re0 20,100}$color3${upspeedgraph re0 20,100}
$color ${alignc}Down ${downspeed re0} | Up ${upspeed re0}
${color}${alignc}Total Down ${totaldown re0} | Total Up ${totalup re0}\
${endif}

]]
 
I have for network:
Code:
${color #34282C}Networking:
Up:$#0C090A ${upspeed lagg0} ${color #0C090A} - Down:$#0C090A ${downspeed lagg0}
 
fernandel
In your case it works since you have something like this in you /etc/rc.conf:

Code:
ifconfig_re0="up"
ifconfig_re1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport bxe0 laggport bxe1 10.2.1.13/24"
defaultrouter="10.2.1.1"

I'm needing to put something like this:


# netstat -nr | grep default | head -1 | awk '{print $4}'

Code:
re0

The idea is that the file can be used regardless of the network adapter name.

Something similar to this in ~/.conkyrc:

Code:
$color2$alignr${downspeedgraph ${exec netstat -nr | grep default | head -1 | awk '{print $4}'} 20,100}$color3${upspeedgraph ${exec netstat -nr | grep default | head -1 | awk '{print $4}' 20,100}

But it's not working!
 
I used a conky script from MX-Linux and Antix. I just had to change the names (eth0, wlan0) to match those on FreeBSD. Also it's smart enough to pic up ethernet and wireless, and hide the ones it can't find.

--#Wireless example##
--${color}Wireless:
--${color}essid: ${wireless_essid $template6}
--${color}IP:${color} ${addr $template6}
--${color}speed: ${color} ${wireless_bitrate $template6}
--${color}link strength: ${color} ${wireless_link_bar 7,50 $template6}
-- network templates

-- template3 = [[${color}\1 \2: $alignr${color3} ${\2speed \1}\n${color2}$alignr${\2speedgraph \1 30,170 5599cc 5599cc}]],
-- template4 = [[${if_up \1}${template3 \1 up}\n${template3 \1 down}\n${endif}]],
-- template5 = [[${template4 $template4}${template4 $template5}${template4 $template6}${template4 $template7}]],

template4 = 'eth0',
template5 = 'eth1',
template6 = 'wlan0',
template7 = 'wlan1',

Heres the entire thing. It's called MX-antiX17 and comes with MX-Linux's Conky Manager:

conky.config = { -- Standard antiX .conkyrc file written by Team antiX. -- Feel free to use. -- anticapitalista@riseup.net -- Note: delete the line above to disable automatic scaling with DPI -- on the live system. -- set to yes if you want Conky to be forked in the background background = true, short_units = true, cpu_avg_samples = 1, net_avg_samples = 1, out_to_console = false, -- X font when Xft is disabled, you can pick one with program xfontsel --font 7x12 --font 6x10 --font 7x13 font = '8x12', --font 7x12 --font *mintsmild.se* --font -*-*-*-*-*-*-34-*-*-*-*-*-*-* --font -artwiz-snap-normal-r-normal-*-*-100-*-*-p-*-iso8859-1 -- Use Xft? use_xft = true, -- Xft font when Xft is enabled --xftfont gentium:size=12 --ftfont DejaVu Sans:size=10 font = 'DejaVu Sans:bold:size=9', --xftfont DejaVu Sans:size=9 -- Create own window instead of using desktop (required in nautilus, pcmanfm and rox desktops) own_window = true, own_window_transparent = true, own_window_hints = 'undecorated,sticky,skip_taskbar', -- Text alpha when using Xft xftalpha = 1.0, --on_bottom no -- mail spool -- mail_spool $MAIL -- Update interval in seconds update_interval = 1, -- Use double buffering (reduces flicker, may not work for everyone) double_buffer = true, -- Minimum size of text area minimum_width = 5, minimum_height = 5, maximum_width = 180, -- Draw shades? draw_shades = false, -- Draw outlines? draw_outline = false, -- Draw borders around text draw_borders = false, -- Stippled borders? stippled_borders = 0, -- border margins --border_margin 10 -- border width border_width = 1, -- Default colors and also border colors default_color = 'white', default_shade_color = 'white', default_outline_color = 'white', color1 = 'ffffff', color2 = 'ffffff', color3 = 'ffffff', color4 = 'yellow', color8 = '77ccff', color9 = '5599cc', -- Text alignment, other possible values are commented -- alignment top_left alignment = 'top_right', --alignment bottom_left --alignment bottom_right -- Gap between borders of screen and text gap_x = 30, gap_y = 30, -- Add spaces to keep things from moving about? This only affects certain objects. use_spacer = 'right', -- Subtract file system buffers from used memory? no_buffers = true, -- if_up_strictness link: up | link | address if_up_strictness = 'address', -- set to yes if you want all text to be in uppercase uppercase = false, -- boinc (seti) dir -- seti_dir /opt/seti --# antiX additives examples. Add below Text## --#Battery examples## --#${color}battery: ${color}$acpiacadapter, ${battery_percent BAT1}% --#${color}battery:${color} ${battery} --${color}ACPI Battery: ${color}$battery --${battery_bar 11,0} --#Wireless example## --${color}Wireless: --${color}essid: ${wireless_essid $template6} --${color}IP:${color} ${addr $template6} --${color}speed: ${color} ${wireless_bitrate $template6} --${color}link strength: ${color} ${wireless_link_bar 7,50 $template6} own_window_argb_value = 0, own_window_argb_visual = true, own_window_colour = '000000', -- time template template0 = [[${if_match "pmfix${time %p}" == "pmfix"}${time \1}${else}${time %I:%M}${endif}]], -- battery templates template1 = [[${if_existing /sys/class/power_supply/BAT\1}\n${color}bat\1:${color3}${alignr}${battery_percent BAT\1}%\n${color1}$alignr${battery_bar 4,170 BAT\1}${endif}]], template2 = [[${template1 0}${template1 1}]], -- network templates -- template3 = [[${color}\1 \2: $alignr${color3} ${\2speed \1}\n${color2}$alignr${\2speedgraph \1 30,170 5599cc 5599cc}]], -- template4 = [[${if_up \1}${template3 \1 up}\n${template3 \1 down}\n${endif}]], -- template5 = [[${template4 $template4}${template4 $template5}${template4 $template6}${template4 $template7}]], template4 = 'eth0', template5 = 'eth1', template6 = 'wlan0', template7 = 'wlan1', }; -- fluxbox adjustment return_code = os.execute('pidof -q fluxbox') if _VERSION == 'Lua 5.1' and math.floor(return_code/256) == 0 or _VERSION ~= 'Lua 5.1' and return_code then conky.config.own_window_transparent = true conky.config.own_window_argb_visual = false end -- stuff after 'TEXT' will be formatted on screen conky.text = [[ ${color3}${alignc}MX Linux ${color8}$alignc${font DejaVu Sans:size=12}${template0 %H:%M}$font ${color}${alignc}${time %a %d %b} ${color}${alignc}Uptime: $uptime ${color}res:${alignr}${color3}${execi 600 xdpyinfo | awk '/dimensions/ { print $2}' } ${color}dpi:${alignr}${color3}${execi 600 xdpyinfo | awk '/resolution/ { sub(/x[0-9]*/,"",$2); print $2}' } ${color}cpu use:${alignr}${color3}${cpu}${color}% ${color}cpu freq:${color3}${alignr}${freq} ${color}$alignr${cpugraph cpu0 30,170 5599cc 5599cc}\ # battery ${template2} ${color}disk I/O:${alignr}${color3}${diskio} ${color}${alignr}${diskiograph 30,170 5599cc 5599cc}\ # network ${if_up $template4} ${color}$template4 up: $alignr${color3} ${upspeed $template4} ${color}$alignr${upspeedgraph $template4 30,170 5599cc 5599cc} ${color}$template4 down: $alignr${color3} ${downspeed $template4} ${color2}$alignr${downspeedgraph $template4 30,170 5599cc 5599cc}${endif}${if_up $template5} ${color}$template5 up: $alignr${color3} ${upspeed $template5} ${color}$alignr${upspeedgraph $template5 30,170 5599cc 5599cc} ${color}$template5 down: $alignr${color3} ${downspeed $template5} ${color2}$alignr${downspeedgraph $template5 30,170 5599cc 5599cc}${endif}${if_up $template6} ${color}$template6 up: $alignr${color3} ${upspeed $template6} ${color2}$alignr${upspeedgraph $template6 30,170 5599cc 5599cc} ${color}$template6 down: $alignr${color3} ${downspeed $template6} ${color2}$alignr${downspeedgraph $template6 30,170 5599cc 5599cc}${endif}${if_up $template7} ${color}$template7 up: $alignr${color3} ${upspeed $template7} ${color2}$alignr${upspeedgraph $template7 30,170 5599cc 5599cc} ${color}$template7 down: $alignr${color3} ${downspeed $template7} ${color2}$alignr${downspeedgraph $template7 30,170 5599cc 5599cc}${endif} ${color}${alignr}${color8}Used / Total ${color}mem:${alignr}$mem ${color3} /${color} $memmax ${color}swap:${alignr}$swap ${color3} /${color} $swapmax ${color}root:${alignr}${fs_used /} ${color3} /${color} ${fs_size /} ]]
 
stroudmw

I've made some progress

I create a:

Code:
...
template0 = 're0',
...
${if_up $template0}\
${color}IPv6: $alignr ${exec ifconfig $template0 | grep 'inet6' | sed '1d' | awk '{print $2}'} prefix ${exec cat /etc/rc.conf | grep ifconfig | grep 'inet6' | tail -c -4 | cut -c 1-2}
${color}IPv4: $alignr ${exec ifconfig $template0 | grep 'inet ' | awk '{print $2}'} prefix ${exec cat /etc/rc.conf | grep ifconfig | grep 'inet ' | tail -c -4 | cut -c 1-2}
$color2$alignr${downspeedgraph $template0 20,100}$color3${upspeedgraph $template0 20,100}
$color ${alignc}Down ${downspeed $template0} | Up ${upspeed $template0}
${color}${alignc}Total Down ${totaldown $template0} | Total Up ${totalup $template0}\
${endif}

With the templates I can create the variable...

And work!

But I continue investigating how to make the template find the name automatically

Code:
template1 = [[${exec netstat -nr | grep default | head -1 | awk '{print $4}'}]],

But it still doesn't work!
 
Why not ?
Code:
$hr
${color grey}Networking em0:
${color grey}UpSpeed  :$color ${upspeed em0}
${color grey}DownSpeed:$color ${downspeed em0}
${color grey}TotalUp  :$color ${totalup em0}
${color grey}TotalDown:$color ${totaldown em0}
$hr
 
Alain De Vos

That's how I had it, but I wish it was something automatic, so that it works on other computers where the network card is called differently.

With the 'templates' example I was able to simplify it and make the change in one variable instead of having to do it in several places!

Thanks everyone for the ideas and shared code. Keep investigating.
 
Back
Top