conky icon indicating copy to clipboard operation
conky copied to clipboard

Specific interval (execi/execibar) not taken into account

Open l0f4r0 opened this issue 5 years ago • 4 comments

Issue

I have 3 seconds as update_interval. For some specific commands, I want this update to be less frequent so I'm using execi/execibar. However, no matter which new interval I choose, it's not taken into account and refresh still happens each 3 seconds.. Did I miss something please?

Information

I have Debian 10 (kernel 5.4.8-1~bpo10+1), Xfce 4.12.5 and conky 1.10.8.

conky.config = {
    double_buffer = true,
    alignment = 'middle_right',
    background = true,
    border_inner_margin = 20,
    border_width = 1,
    cpu_avg_samples = 4,
    default_color = 'white',
    default_outline_color = 'white',
    default_shade_color = 'white',
    color0 = '999999',
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'DejaVu Sans Mono:size=12',
    gap_x = 15,
    gap_y = 0,
    minimum_height = 5,
    minimum_width = 500,
    net_avg_samples = 4,
    no_buffers = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,
    own_window = true,
    own_window_transparent = true,
    own_window_class = 'Conky',
    own_window_type = 'dock',
    own_window_hints = 'below',
    stippled_borders = 0,
    update_interval = 3.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = false,
    show_graph_range = false
}

conky.text = [[
\
${color0}Sound volume:${color} \
${if_match ${execi 30 amixer -c 0 get Master | grep -oE '[0-9]+%' | sed 's/%//'} <= 5}\
${execbar echo "0"}
${else}\
${if_match ${execi 30 amixer -c 0 get Master | grep -oE '[0-9]+%' | sed 's/%//'} >= 95}\
${execbar echo "100"}
${else}\
${execibar 30 amixer -c 0 get Master | grep -oE '[0-9]+%' | sed 's/%//'}
${endif}\
${endif}\
\
${color0}Brightness:${color} ${execibar 30 echo "scale=3;$(cat /sys/class/backlight/intel_backlight/actual_brightness)/$(cat /sys/class/backlight/intel_backlight/max_brightness)*100" | bc | sed -E 's/([0-9]+)\.[0-9]+/\1/'}

l0f4r0 avatar Feb 02 '20 07:02 l0f4r0

It works after rebooting :) Does somebody know why it didn't even after a simple conky conf reloading?

l0f4r0 avatar Feb 02 '20 09:02 l0f4r0

Does somebody know why it didn't even after a simple conky conf reloading?

Non-ideal code? Also, 1.10.8 is years ago. I'd try the latest one, but I fear you might face same issue... and maybe more issues too. Also, there is https://github.com/brndnmtthws/conky/issues/870.

lasers avatar Feb 02 '20 10:02 lasers

I can confirm this issue. I have got update_interval = 3.0 in my config file and several exec variables: ${execpi 15 ...}, ${execi 15 ...} and two ${execpi 12 ...}. They actually run every 3, 3, 3, 6 seconds instead of prescribed intervals.

I checked #870 which says that this issue should be fixed, but alas. I'm running version 1.11.6 from Ubuntu 21.10 which is newer than mentioned there.

I supposed that if ${execi} and ${execpi} run too frequently, why not change their intervals? I performed several tests and here are my findings. It seems that the resulting frequency depends not only on intervals, but it also depends on the number of ${execi}/${execpi}/${texeci}/${texecpi} variables used in the config file. When I commented out all such variables in my config except one, it run as intended. As soon as I uncommented some other execi vars, they started running more frequently. For example, with 3 ${execi}/${execpi} scripts activated, with intervals set to 30/30/30, they run every 9, 9, 12, 9, 9, 12, ... seconds. 9 + 9 + 12 gives 30 indeed, but each script actually runs three times during this interval. When I set intervals of all these scripts to 39/39/39 seconds, they run every 12, 15, 12, 12, 15, 12, ... seconds. Again, 12 + 15 + 12 = 39 (obviously, each interval should be divisible by 3, which is my update_interval).

So as walkaround I can propose such method until the fix is found: pick an interval which will match the desired frequency. This interval should be divisible by update_interval value and should be the same for all ${execi}/${execpi}/${texeci}/${texecpi} scripts used in the config, otherwise they will run with uneven intervals.

To achieve the desired interval of 12 sec for my 4 scripts, I set interval parameter 4 * 12 = 48 for each of them and it worked. And as 12 is multiple of 3, they run with even intervals. The next proper interval is 15 seconds and in my case intervals should be set to 4 * 15 = 60.

Possibly my findings will help to find the cause of this issue.

whtyger avatar Aug 30 '22 08:08 whtyger

I would personally rewrite this part to use some sort of scheduler and refactor existing rendering code so it's independent of execi updates. People might want to run commands that affect the system state in some way more frequently than update_interval, which is why I'd change this behavior so that execi isn't limited by it. Of course, everyone is already used to the current behavior and whoever decides to make such a change should ideally also help out with issues people will inevitably open.

In either case (update_interval limited or not), there's libraries for scheduling and it's better to use those than implement this from scratch as scheduling isn't a trivial problem to solve correctly, esp. given that we want to support FreeBSD and MacOS. Here's some cross platform ones:

execi timing also shouldn't be counted towards update/render time, and each execi variable should be keeping track of when it was last updated (implied if using a scheduling library). Their execution also needs to be orchestrated so that they execute in order of appearance within conky.text if their interval is the same, as executed commands might have some external state conky isn't aware of.


DELETED OFF TOPIC SUMMARY

@Lowrida commented they believe this issue deserves more attention (in a less polite manner). I asked them to be more polite about asking such things and explained how such remarks don't help someone trying to work on the issue (and are distracting/unhelpful).

Caellian avatar Jun 24 '24 00:06 Caellian