You are not logged in.
Hello All,
I am not a good developer and trying to use Conky. Followed up this document: https://wiki.archlinux.org/title/Conky/Tips_and_tricks
Prepared a simple Lua script; updates.lua:
conky.config = {
alignment = 'top_right',
background = false,
double_buffer = true,
out_to_console = false,
stippled_borders = 2,
border_outer_margin = 20,
border_width = 1,
max_user_text = 16384,
color1 = 'CCAB8D',
default_color = 'white',
default_outline_color = 'white',
default_shade_color = 'white',
draw_borders = false,
draw_outline = false,
draw_shades = false,
gap_x = 600,
gap_y = 20,
own_window = true,
own_window_type = 'desktop',
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
own_window_transparent = true,
use_xft = true,
xftalpha = 0.8,
font = 'Roboto Mono:size=10',
};
conky.text = [[
${color1}Updates
$hr
${color1}Total Packages: ${color}${execi 600 checkupdates | wc -l}
${color}${execi 600 checkupdates | awk 'NR<=50'}
]];It provides an error:
conky -c /home/d066y/.conky/myconky/updates.conf
conky: desktop window (6400003) is subwindow of root window (21c)
conky: window type - desktop
conky: drawing to created window (0x8a00001)
conky: drawing to double buffer
==> ERROR: Cannot fetch updatesIt shows one of them at a time but not both. If I use just one of them in the script, it works. But not together.
I know it is not critical, but just annoying.
P.S: I have just realized if I stop and start it a few times, it works too. But it does not work when I reboot the computer. I need to stop and start it a few times.
Last edited by d066y (2023-05-09 15:06:27)
Offline
Try:
${color}${execi 3600 checkupdates | awk 'NR<=50'} Offline
checkupdates is rather slow and requires network IO, I assume you also run into some quota because of the double-invocation.
Try
…
${color1}Total Packages: ${color}${execi 600 checkupdates | tee >(head -50) | wc -l}
…But since this is extended bash syntax and I'm not sure conky will execute that "right", you might have to
execi 600 bash -c 'checkupdates | tee >(head -50) | wc -l'instead.
The alternative approach would be a script that downloads the result in a temporary file *once* and use that file multiple times (eg. if you want different colors or fonts)
Offline
@Morlock
I tried a long waiting before, and it didn`t work.
@seth
Both options provide the total number but not the list. But no fetch error because I run the command just once. And as you stated, it hits the quota.
Never mind, I need the see update packages. The number is irrelevant.
Thanks anyway
Offline
You could do this with a single awk script:
${color1}Total Packages: ${color}${execi 600 checkupdates | awk 'NR<=50{lines[NR]=$0} END{print NR;for(i in lines)print lines[i]}'}Putting the total at the end would be simpler (no need for the lines array). With execpi you can have the script output ${color} things as well.
Offline
Sed would be much simpler and a single process:
checkupdates | sed -n '1,50p;$='Oops, if you want the total packages at the top:
${color1}Total Packages: ${color}${execi 600 checkupdates | sed -n '1h;2,50H;${=;g;p}'}busybox sed is better ... it works fine without any of those semicolons ( '1h2,50H${=gp}' ). Gnu's sed has semi-colon cancer.
Last edited by Trilby (2023-05-09 14:15:07)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
${color1}Total Packages: ${color}${execi 600 checkupdates | awk 'NR<=50{lines[NR]=$0} END{print NR;for(i in lines)print lines[i]}'}This works flawlessly. Thank you @Raynman
Offline
${color1}Total Packages: ${color}${execi 600 checkupdates | sed -n '1h;2,50H;${=;g;p}'}And this one too (: Thank you @Trilby
Thank you all guys
Offline
FYI awk can also do it without the loop; this basically translates the approach used in sed into awk:
checkupdates | awk 'NR < 51 { a=a"\n"$0 } END { print NR, a; }'"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline