brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

Nested if_match? #531

Closed DanyGee closed 6 years ago

DanyGee commented 6 years ago

I would like my conky configs (in one file) to launch according to time.

For time <= 06 AND time >=20 - config with colors for the night. else config with colors for the day.

For now I have something like this, but it does not seem to work:

${if_match "{time %H}" <= "06"}${if_match "{time %H}" >= "20"}
night config
${else}
day config
${endif}${endif}

Conky does show nothing in this case.

conky -v conky 1.10.1 compiled Wed Jan 6 17:11:44 UTC 2016 for Linux 3.19.0-43-generic x86_64

Compiled in features:

System config file: /etc/conky/conky.conf Package library path: /usr/lib/conky

General:

dbriba commented 6 years ago

Try this ${if_match ${time %H} <= 06}${if_match ${time %H} >= 20} night config ${else} day config ${endif}${endif}

DanyGee commented 6 years ago

Try this ${if_match ${time %H} <= 06}${if_match ${time %H} >= 20} night config ${else} day config ${endif}${endif}

Didn't work after 00:00 - stopped showing config.

dbriba commented 6 years ago

Sorry but that don't work properly I have alway no response or "day config" This line make better : ${if_match ${time %H} <=06}${else}${if_match ${time %H} >=20} night config ${else} day config ${endif}${endif}

DanyGee commented 6 years ago

${if_match ${time %H} <=06}${else}${if_match ${time %H} >=20} night config ${else} day config ${endif}${endif}

This code only shows day config. If I change the hour span to >=6 and <=20 - it shows nothing again. Tonight I'll test something like this:

${if_match ${time %H} >= 6}${if_match ${time %H} <= 19}
day config
${else}
${if_match ${time %H} >= 20}${if_match ${time %H} <= 5}
night config
${endif}${endif}${endif}${endif}

The 00:00 hour seems to cause problems here...

dbriba commented 6 years ago

I test your last code, but that don't work well. I think it's not possible to chain more two if_match. But I think this code work :

${if_match ${time %H} <=06}
night config
${endif}\
${if_match ${time %H} >=20}
night config
${endif}\
${if_match ${time %H} >=07}
day config
${endif}\
${if_match ${time %H} ==00}
night config
${endif}
dbriba commented 6 years ago

And I see what your code don't work there are ${if_match ${time %H} <= 19} (day config) and ${if_match ${time %H} <= 5}(night config) that is not possible.

dbriba commented 6 years ago

sorry but my last code don't work in every cases. And I know why. There is an incoherence between ${if_match ${time %H} >=07}(day config) and ${if_match ${time %H} >=20} (night config). And I don't know how solve that...

dbriba commented 6 years ago

Try this code, that work for me : ${if_match ${time %H} <= 06}night config ${else}${if_match ${time %H} >= 19}night config ${else}day config ${endif}${endif}

DanyGee commented 6 years ago

Try this code, that work for me : ${if_match ${time %H} <= 06}night config ${else}${if_match ${time %H} >= 19}night config ${else}day config ${endif}${endif}

Thx dbriba, this finally works as it should :+1: bitmoji