You are not logged in.
I want to display the internet speed in Mbps in system info. Can someone kindly tell what changes do I need to make in conky files and particularly in which conky file to make this happen?
Offline
^Conky follows the IEC units convention.
The variables are:
downspeed and downspeedf http://www.ifxgroup.net/conky.htm#upspeed
upspeed and upspeedf
where the output is always B; KiB; MiB etc. You will not get an output in Mbps even if you try to do so using templates (as shown in the screenshot).
So if you have a permanent speed of 1 Mbps, Conky will show you 1 MiB (if my conversion is correct).
The f causes the output of a decimal place and suppresses the letters B; KiB; MiB.
Without f, Conky writes these letters itself and you can omit the 'write to' in the configuration file.
kbit/s oder kB/s
mögliche Schreibweisen:
'bps', 'b/s' = bits per second
'Bps', 'B/s' = bytes per second
'k', 'kb', 'kbs', 'kbps', 'kb/s' = kilobits per second
'K', 'KB', 'KBs', 'KBps', 'KB/s' oder 'k', 'kB', 'kBs', 'kBps', 'kB/s' = kilobytes per second
'm', 'mb', 'mbs', 'mbps', 'mb/s' = megabits per second
'M', 'MB', 'MBs', 'MBps', 'MB/s' oder 'm', 'mB', 'mBs', 'mBps', 'mB/s' = megabytes per second
To your last question you would have to tell which Conky of BL you use.
Last edited by unklar (2022-04-18 13:23:55)
Offline
I want to display the internet speed in Mbps in system info. Can someone kindly tell what changes do I need to make in conky files and particularly in which conky file to make this happen?
I'm sure a little lua scripting could convert conky's values into something you want.
An example conky config:
width=330
conky.config = {
own_window = true,
own_window_transparent = false,
own_window_colour = '#FAFCFE',
own_window_type = 'normal',
own_window_argb_visual = false,
double_buffer = true,-- double buffering reduces flicker
-- size of text area
minimum_width = width, minimum_height = 100,
maximum_width = width,
update_interval = 1,
lua_load = 'test.lua',
lua_draw_hook_pre = 'main'
};
conky.text = '';
-- This is the test.lua script for use with Conky.
require 'cairo'
function draw_text(text,x,y,font,size,color,alpha,weight,align,maxwidth)
slant = CAIRO_FONT_SLANT_NORMAL
cairo_select_font_face (cr,font,slant,weight);
cairo_set_font_size (cr, size)
red, green, blue = hex2rgb(color)
if alpha == nil then
cairo_set_source_rgb (cr, red, green, blue)
else
cairo_set_source_rgba (cr,red, green, blue, alpha)
end
local extents = cairo_text_extents_t:create()
tolua.takeownership(extents)
cairo_text_extents(cr,text,extents)
-- cut off text until it fits the maximum width
if maxwidth then
did=0
maxwidth=tonumber(maxwidth)
while extents.width > maxwidth do
text=string.gsub(text, "[^\128-\191][\128-\191]*$", "") -- delete last char: stackoverflow.com/a/15980690
cairo_text_extents(cr,text .. '…',extents)
did=1
end
if did == 1 then text=text .. '…' end
end
if align == "right" or align == "center" then
if align == "right" then
x = x - extents.width
else
x = x/2 - extents.width/2 + extents.x_bearing
end
end
cairo_move_to (cr, x, y+size)
cairo_show_text (cr, text)
cairo_stroke (cr)
return extents.width , extents.height
end
function hex2rgb(c)
c=tonumber("0x"..c)
return ((c / 0x10000) % 0x100) / 255, ((c / 0x100) % 0x100) / 255,
(c % 0x100) / 255
end
function conky_main(...)
if conky_window == nil then
return
end
cs = cairo_xlib_surface_create (conky_window.display,conky_window.drawable,conky_window.visual,conky_window.width,conky_window.height)
cr = cairo_create (cs)
speed = tonumber(conky_parse('${downspeedf enp1s0}'))
speed = (speed * 1024 * 8) -- in bit
speed = speed / (1000 * 1000) -- in Mbit? not so sure
draw_text(speed,10,10,"sans-serif",18,"111111")
speed = tonumber(conky_parse('${upspeedf enp1s0}'))
speed = (speed * 1024 * 8) -- in bit
speed = speed / (1000 * 1000) -- in Mbit? not so sure
draw_text(speed,10,40,"sans-serif",18,"111111")
cairo_destroy (cr)
cairo_surface_destroy (cs)
cr = nil
cs = nil
end
Sorry for the vastly complex text_draw function; The important bits are way at the bottom, in conky_main.
I'm not sure exactly how the math goes here, but it is doable.
Offline
^Conky follows the IEC units convention.
The variables are:
downspeed and downspeedf http://www.ifxgroup.net/conky.htm#upspeed
upspeed and upspeedfwhere the output is always B; KiB; MiB etc. You will not get an output in Mbps even if you try to do so using templates (as shown in the screenshot).
So if you have a permanent speed of 1 Mbps, Conky will show you 1 MiB (if my conversion is correct).
The f causes the output of a decimal place and suppresses the letters B; KiB; MiB.
Without f, Conky writes these letters itself and you can omit the 'write to' in the configuration file.kbit/s oder kB/s mögliche Schreibweisen: 'bps', 'b/s' = bits per second 'Bps', 'B/s' = bytes per second 'k', 'kb', 'kbs', 'kbps', 'kb/s' = kilobits per second 'K', 'KB', 'KBs', 'KBps', 'KB/s' oder 'k', 'kB', 'kBs', 'kBps', 'kB/s' = kilobytes per second 'm', 'mb', 'mbs', 'mbps', 'mb/s' = megabits per second 'M', 'MB', 'MBs', 'MBps', 'MB/s' oder 'm', 'mB', 'mBs', 'mBps', 'mB/s' = megabytes per second
https://i.imgur.com/T3PCw8Nt.png
To your last question you would have to tell which Conky of BL you use.
Can You please elaborate what changes or script do I need to use exactly? I want make changes and add something in "default conckyrc" of Bunsenlabs lithium so that the upload and download speed of the internet is shown in system info tray.
Offline
SSD wrote:I want to display the internet speed in Mbps in system info. Can someone kindly tell what changes do I need to make in conky files and particularly in which conky file to make this happen?
I'm sure a little lua scripting could convert conky's values into something you want.
An example conky config:
width=330 conky.config = { own_window = true, own_window_transparent = false, own_window_colour = '#FAFCFE', own_window_type = 'normal', own_window_argb_visual = false, double_buffer = true,-- double buffering reduces flicker -- size of text area minimum_width = width, minimum_height = 100, maximum_width = width, update_interval = 1, lua_load = 'test.lua', lua_draw_hook_pre = 'main' }; conky.text = '';
-- This is the test.lua script for use with Conky. require 'cairo' function draw_text(text,x,y,font,size,color,alpha,weight,align,maxwidth) slant = CAIRO_FONT_SLANT_NORMAL cairo_select_font_face (cr,font,slant,weight); cairo_set_font_size (cr, size) red, green, blue = hex2rgb(color) if alpha == nil then cairo_set_source_rgb (cr, red, green, blue) else cairo_set_source_rgba (cr,red, green, blue, alpha) end local extents = cairo_text_extents_t:create() tolua.takeownership(extents) cairo_text_extents(cr,text,extents) -- cut off text until it fits the maximum width if maxwidth then did=0 maxwidth=tonumber(maxwidth) while extents.width > maxwidth do text=string.gsub(text, "[^\128-\191][\128-\191]*$", "") -- delete last char: stackoverflow.com/a/15980690 cairo_text_extents(cr,text .. '…',extents) did=1 end if did == 1 then text=text .. '…' end end if align == "right" or align == "center" then if align == "right" then x = x - extents.width else x = x/2 - extents.width/2 + extents.x_bearing end end cairo_move_to (cr, x, y+size) cairo_show_text (cr, text) cairo_stroke (cr) return extents.width , extents.height end function hex2rgb(c) c=tonumber("0x"..c) return ((c / 0x10000) % 0x100) / 255, ((c / 0x100) % 0x100) / 255, (c % 0x100) / 255 end function conky_main(...) if conky_window == nil then return end cs = cairo_xlib_surface_create (conky_window.display,conky_window.drawable,conky_window.visual,conky_window.width,conky_window.height) cr = cairo_create (cs) speed = tonumber(conky_parse('${downspeedf enp1s0}')) speed = (speed * 1024 * 8) -- in bit speed = speed / (1000 * 1000) -- in Mbit? not so sure draw_text(speed,10,10,"sans-serif",18,"111111") speed = tonumber(conky_parse('${upspeedf enp1s0}')) speed = (speed * 1024 * 8) -- in bit speed = speed / (1000 * 1000) -- in Mbit? not so sure draw_text(speed,10,40,"sans-serif",18,"111111") cairo_destroy (cr) cairo_surface_destroy (cs) cr = nil cs = nil end
Sorry for the vastly complex text_draw function; The important bits are way at the bottom, in conky_main.
I'm not sure exactly how the math goes here, but it is doable.
Do I need to paste all(both below and above parts ) script in "default conckyrc" of BL Labs lithium?
Offline
In the link unklar gave you, there are examples of what is needed to change. This is a good link with lots of relative information. http://www.ifxgroup.net/conky.htm#upspeed
Typing:
man conky
in a terminal will give you access to everything conky.
You will need to know which conky you want to change, as there are several to choose from for Bunsen Labs. Find the conky you want to change and post the code here of what you want changed and hopefully we can get it fixed up the way you would like.
Last edited by sleekmason (2022-04-20 13:44:02)
Offline
Do I need to paste all(both below and above parts ) script in "default conckyrc" of BL Labs lithium?
No, they are separate files. Save the first one to whatever.conkyrc.lua, and the other to test.lua, both in the same folder.
Then you start the conky with
conky -c /path/to/whatever.conkyrc.lua
Offline