I am currently working on adding conky in Jammy64. Since this version of conky uses Lua rather than the previous conkyrc's syntax, I have updated the conkyrc to the newer syntax.
Also, since Lua is a real programming language rather than simple conky stuff, we can do much more with it than we can with older conky. So, I've also updated the 'Filesystems' and 'NET' sections of conkyrc which earlier was simply a static list of mounts / net devices to a newer one not requiring that sort of code.
I present this conkyrc to you so that you can help in improving it. The mounted filesystems and network devices which are UP are found when conky starts up. The filesystems one can be made to update every time conky is updated, but this will require an additional bit of processing each time conky updates (I ask your opinion on whether this should be done).
Limitations:
-
This version does not include the weather stuff.
-
The Puppy's GUI to edit conky settings, as is in Fossa64, might not work out of the box on this conkyrc.
-
I have not been able to successfully get a transparent background for it in Jammy64.
-
Devices that are mounted at some path containing spaces (very rare in Puppy) might not work.
Additional commands required by this version are:
-
ip
-
lsblk
-
awk
-
grep
Here is the conkyrc:
Code: Select all
-- This is an update of older conkyrc found in Fossa64 to Conky's new Lua syntax.
-- Configs are save in `conky.config`; the text to be displayed is stored in `conky.text`
-- Lua uses `--` as comments. Comment out any line to disable that config.
-- Inside `conky.text`, the comments still are used with `#`.
-- Conky documentation can be found here:
-- Variables (in text) = https://conky.cc/variables
-- Config Settings = https://conky.cc/config_settings
-- Lua API = https://conky.cc/lua
------------------------------------------------------------------
-- show_mounts : template for filesystem
-- usage : see https://unix.stackexchange.com/a/768938/540879
function conky_show_mounts()
-- Run the following lsblk command to get the device names and their mounted locations (except loop devices)
local command = "lsblk --raw --noheadings -o NAME,MOUNTPOINT -e7 | awk '$1~/[[:digit:]]/ && $2 != \"\"' | grep -v -i 'swap'"
-- print(command) -- Uncomment to debug
-- Execute the command and capture the output
local handle = io.popen(command)
local output = handle:read("*a")
handle:close()
local result = "" -- The final result will be concatenated to this string
-- Process the output in Lua
for line in output:gmatch("[^\r\n]+") do
local mount_name, mount_point = line:match('(%S+)%s*(%S*)')
-- print(mount_name) -- uncomment to debug
-- print(mount_point) -- uncomment to debug
-- Add this mount {name, point} to result
if mount_name and mount_point then -- our cmd also outputs devnames which don't have mountpoints; ignore them
result = result .. "\n${color2}" .. mount_name .. " ${fs_used " .. mount_point .. "} / ${fs_size " ..
mount_point .. "} ${alignr}${color1}${fs_bar 10,120 " .. mount_point .. "}"
end
end
return result
end
------------------------------------------------------------------
-- conky_show_netdevs : template for network
-- usage : see https://unix.stackexchange.com/a/768938/540879
function conky_show_netdevs()
local netdevs_handle = io.popen("ip -o link show up | grep -v lo | grep -v -i 'state down' | awk '{print $2}' | cut -d':' -f1")
local result = ""
for netdev in netdevs_handle:lines() do
result = result .. "\nIP (${color1}" .. netdev .. "${color2}): ${alignr}${addr " .. netdev .. "}\n" ..
"${color2}Up: ${color2}${upspeed " .. netdev .. "}/s${color1}${alignr}${upspeedgraph " .. netdev .. " 10,170}\n" ..
"${color2}Down: ${color2}${downspeed " .. netdev .. "}/s${color1}${alignr}${downspeedgraph " .. netdev .. " 10,170}\n" ..
"${color2}Total Down: ${color2}${totaldown " .. netdev .. "}${alignr}Total Up: ${totalup " .. netdev .. "}\n"
end
netdevs_handle:close()
if result ~= "" then
return result
else
return "\n"
end
end
------------------------------------------------------------------
conky.config = {
use_xft = true, -- use xft?
font = 'DejaVuSans:size=9', -- font name
xftalpha = 1,
uppercase = false, -- all text in uppercase?
pad_percents = 0,
text_buffer_size = 2048,
override_utf8_locale = true, -- Force UTF8? note that UTF8 support required XFT
use_spacer = 'none', -- Add spaces to keep things from moving about? This only affects certain objects.
update_interval = 1, -- Update interval in seconds
double_buffer = true, -- Use double buffering (reduces flicker, may not work for everyone)
total_run_times = 0, -- This is the number of times Conky will update before quitting. Set to zero to run forever.
-- background = true, -- Run in background (same as running conky &)
-- Create own window instead of using desktop (required in nautilus)
own_window = true,
own_window_class = 'Conky',
own_window_transparent = true,
own_window_argb_visual = true,
own_window_argb_value = 255,
own_window_type = 'desktop',
own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
-- Minimum size of text area
minimum_height = 50,
minimum_width = 280,
draw_shades = false, -- draw shades?
draw_outline = false, -- draw outlines?
draw_borders = false, -- draw borders around text?
draw_graph_borders = false, -- draw borders around graphs
stippled_borders = 0, -- stripled borders?
imlib_cache_size = 0, -- Imlib2 image cache size, in bytes. Increase this value if you use $image lots. Set to 0 to disable the image cache.
-- Gap between borders of screen and text. Same thing as passing -x at command line
gap_x = 90,
gap_y = 5,
alignment = 'middle_right', -- alignment on {y_axis}_{x_axis}
cpu_avg_samples = 2, -- number of cpu samples to average. set to 1 to disable averaging
net_avg_samples = 2, -- number of net samples to average. set to 1 to disable averaging
no_buffers = true, -- Subtract file system buffers from used memory?
default_color = 'e0e0e0',
default_shade_color = '000000',
default_outline_color = '000000',
temperature_unit = 'celsius',
color1 = 'ff55ff', -- heading's color
color2 = 'ffffff', -- normal text's color
-- weather1 = 'liverpool', -- @todo
};
conky.text = [[
${color1}System ${hr 2}
${color2}${nodename}
#${color}${pre_exec cat /etc/DISTRO_SPECS | grep DISTRO_NAME | cut -d'"' -f2} # ${pre_exec} is deprecated in newer conky, use `execi [SOME BIG VALUE]` instead
${color2}${texeci 36000 cat /etc/DISTRO_SPECS | grep DISTRO_NAME | cut -d'"' -f2}
${color2}${sysname} ${kernel}
${color2}Uptime ${uptime}
${color1}Processes ${hr 2}
${color1}${alignr}CPU% used
${color2}${top name 1}${alignr}${top cpu 1} %
${color2}${top name 2}${alignr}${top cpu 2} %
${color2}${top name 3}${alignr}${top cpu 3} %
${color2}${top name 4}${alignr}${top cpu 4} %
#${color2}${top name 5}${alignr}${top cpu 5} %
#${color2}${top name 6}${alignr}${top cpu 6} %
#${color2}${top name 7}${alignr}${top cpu 7} %
${color1}${alignr}Mem used
${color2}${top_mem name 1}${alignr}${top_mem mem_res 1}
${color2}${top_mem name 2}${alignr}${top_mem mem_res 2}
${color2}${top_mem name 3}${alignr}${top_mem mem_res 3}
${color2}${top_mem name 4}${alignr}${top_mem mem_res 4}
#${color2}${top_mem name 5}${alignr}${top_mem mem_res 5}
#${color2}${top_mem name 6}${alignr}${top_mem mem_res 6}
#${color2}${top_mem name 7}${alignr}${top_mem mem_res 7}
${color1}Resources ${hr 2}
#${hwmon 3 temp 1}
${color2}CPU0: ${cpu cpu0}%${alignr}${color1}${cpubar cpu0 10,120}
#${color2}CPU1: ${cpu cpu1}%${alignr}${color1}${cpubar cpu1 10,120}
#${color2}CPU2: ${cpu cpu2}%${alignr}${color1}${cpubar cpu2 10,120}
#${color2}CPU3: ${cpu cpu3}%${alignr}${color1}${cpubar cpu3 10,120}
#${color2}CPU4: ${cpu cpu4}%${alignr}${color1}${cpubar cpu4 10,120}
#${color2}CPU5: ${cpu cpu5}%${alignr}${color1}${cpubar cpu5 10,120}
#${color2}CPU6: ${cpu cpu6}%${alignr}${color1}${cpubar cpu6 10,120}
${color2}Mem: ${mem} / ${memmax}
${memperc}% ${alignr}${color1}${membar 10,120}
${color2}Swap: ${swap} / ${swapmax}
${swapperc}% ${alignr}${color1}${alignr}${swapbar 10,120}
#${color2}Bat: ${battery} ${alignr}${color1}${battery_bar 10,120}
${color1}File Systems ${hr 2}]]
conky.text = conky.text .. conky_show_mounts() -- thanks to https://unix.stackexchange.com/a/768938/540879!
conky.text = conky.text .. [[
${color1}NET: ${hr 2}${color2}]]
conky.text = conky.text .. conky_show_netdevs() -- thanks to https://unix.stackexchange.com/a/768938/540879!
conky.text = conky.text .. [[EXT: ${alignr} ${texeci 3600 wget -O - -q icanhazip.com}
####don't write below this line as used for conky gui weather
${color1}${voffset 2}${hr 2}
#
#
#
]]
Here is a screenshot: