Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec doesn't run on first iteration #112

Closed
miseran opened this issue Jul 11, 2015 · 9 comments
Closed

exec doesn't run on first iteration #112

miseran opened this issue Jul 11, 2015 · 9 comments

Comments

@miseran
Copy link

miseran commented Jul 11, 2015

Since the update to 1.10.0, the exec command and friends don't run on the very first iteration for me.

For example, with the following config file

conky.config = {
    background = false,
    out_to_console = true,
    out_to_x = false,
    update_interval = 1.0,
    total_run_times = 0,
};

conky.text = [[
==${exec echo exec}==${execi 5 echo execi}==${texeci 5 echo texeci}==
]];

I get the output

========
==exec==execi==texeci==
==exec==execi==texeci==
==exec==execi==texeci==

etc.

@willemw12
Copy link

Even worse, in cases where conky is only run once:

total_run_times = 1

(e.g. the display-loop is executed by a containing program), there is no output at all.

@ghost
Copy link

ghost commented Oct 1, 2015

I can confirm this behaviour also for use-cases where conky's output is piped into a bar like dzen. There, when restarting/reloading conky, the old/original output of the {t}exec{i} sequences is still being displayed…

@madhat2r
Copy link

madhat2r commented Oct 5, 2015

I am also having this issue...

@labichn
Copy link

labichn commented Nov 9, 2015

I can also confirm this issue. This bug prevents a number of simple use cases: a volume bar popup, for example, should be a single execbar iteration (total_run_times=1) with a duration of a second or so (update_interval=1). To get the same behavior (because of this bug) you need a very tight update interval with a large number of iterations so the initial empty bar isn't visible. I dug into this a bit but lost track of the control-flow of the callback system.

@marcpayne
Copy link
Contributor

The callback for exec (and others) is registered after all callbacks are run for the first time. In case anyone wants to investigate further, I'll try to explain what happens.

Starting from conky.cc, the following function calls take place:

update_text()
|
|--- generate_text()
     |
     |--- update_stuff() [defined in common.cc]
     |    |
     |    |--- conky::run_all_callbacks()
     |
     |--- generate_text_internal()
          |
          |--- (*obj->callbacks.print)(obj, p, p_max_size) [see print_exec() in exec.cc]
               |
               |--- conky::register_cb<exec_cb>(1, true, obj->data.s)

The ultimate purpose of conky::run_all_callbacks() is to ensure that the work() function of each registered callback is called. However, the first call to run_all_callbacks() happens before register_cb<exec_cb>, so there is no exec_cb object whose work() function we can call.

I think we need some serious refactoring to make this work as intended. It isn't straightforward to move the register_cb call somewhere more appropriate, and calling run_all_callbacks() later does not work, afaict.

@chepioq
Copy link

chepioq commented Dec 21, 2015

Hi marcpayne
Have you solve this problem ?

@marcpayne
Copy link
Contributor

No, unfortunately. I recently started training for a new job and have not had time to work on this issue. I will put in some time during the holidays and try to come up with a solution.

@marcpayne
Copy link
Contributor

I think I have a decent solution now. I decided to push the changes to my repo, but not submit a pull request yet. If anyone here is willing to test, please do and let me know how it works for you. I'll be happy to help if needed.

One thing I mentioned in my commit message is that texeci sometimes works on the first update, and sometimes doesn't. I assume that the thread doesn't always have time to complete on my system before the first set of results gets printed. Your results may vary. At least the non-threaded versions of exec all work as they should!

marcpayne added a commit to marcpayne/conky that referenced this issue Dec 30, 2015
Prior to this commit, exec_cb callbacks were registered and the results
were immediately fetched on every update interval... except the first.
Besides not working on the first update, this meant that all exec_cb
callbacks were re-registered on every update, which was not efficient.

The solution was to decouple the registration from the result retrieval
and only register on the initial startup (or config reload). Now, the
callbacks are registered when they are supposed to be, and the first-run
issue is gone.

The code is hopefully more understandable now. I consolidated several
functions in exec.cc into one, which makes the logic much easier to
follow. I also added plenty of documentation, both to the code itself
and to the manpage.

There are some nice bonuses as well:

  * execgraph works again!
  * optional execgraph parameters are now documented
  * execbar and execgauge now accept height and width parameters

Known issues:

  * technically, execgraph accepts commands with spaces, but such
    commands will need to be surrounded with double-quotes and you might
    as well forget adding optional arguments like colors, as the results
    may not be expected. Just put your spacey command into a script and
    run the script instead so that everything will just work.
  * the execgraph command comes *before* its arguments, whereas the
    execbar and execgauge commands come after their arguments.
  * texec{i} is registered on startup like everything else, but
    sometimes it will not produce output on the first interval. This is
    an intermittent issue.

Fixes the following issues:

brndnmtthws#112
brndnmtthws#153
brndnmtthws#180
@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

Closed by #192. Thanks. 👍

@lasers lasers closed this as completed Aug 3, 2018
iiey added a commit to iiey/dotfiles that referenced this issue Jul 2, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 2, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 3, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 11, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 29, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue May 2, 2020
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue May 2, 2020
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jun 17, 2021
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants