Conky: if_match compare fails if locale uses "," as decimal mark

Created on 15 Jul 2013  ·  19Comments  ·  Source: brndnmtthws/conky

From my log:

conky: Bad arguments: '0,0 ' and ' 10.0'
conky: compare failed for expression '0,0 < 10.0'

These compares are all similar to this one:

${if_match ${downspeedf enp2s0} < 100.0}

The compare still fails if the argument is written with ",". Explicitly setting conky's locale to en_US.UTF-8 works for now.

(This didn't happen in 1.9.0.)

bug

All 19 comments

I have the same problem.

Same here, can you tell please how to set a specific LOCALE for conky?

You preface the command with eg.

LC_ALL=C conky

Thanks, however it turns out comparing is failing in general with fraction numbers:

conky: compare failed for expression ' 12,61 >= 10 '

${if_match ${top cpu 1} >= 10 }${color red}\
${else}${color}\
${endif}\

Sorry my fault, the locale was not set it worked now. I use following startup script now:

#!/bin/bash

export LANG=en_US.UTF-8
export LC_ALL=C

sleep 5 && conky

Side note: It looks like it is in algebra.cc: enum arg_type get_arg_type. I recommend to use a locale aware number parser.

Is this issue still outstanding in the current version of Conky? If so, please update the issue. Otherwise, the issue will be closed in 2 weeks.

@lasers Can you have a look ?

@su8 I tried. Not familiar with locale. Tried Italy. Didn't get commas to display. Maybe I did it wrong.

@su8 I tried git bisect here to 1.9.0. Earlier tags does not contain cmake stuffs. :-(

US.

0B // False
56.9K // True
16.9K // False
544B // False
74.9K // True
88.4K // True
13.9K // False

DK.

conky: Bad arguments: '0,0' and '50.0'
conky: compare failed for expression '0,0>50.0'
0B // True
conky: Bad arguments: '0,0' and '50.0'
conky: compare failed for expression '0,3>50.0'
307B // True
^Cconky: Bad arguments: '0,3' and '50.0'
conky: compare failed for expression '0,3>50.0'
350B // True

@su8 Just in case you missed the latest comment, I can test this now.

Can you test this:

diff --git a/src/algebra.cc b/src/algebra.cc
index 66dfd2d6..4e1d36e2 100644
--- a/src/algebra.cc
+++ b/src/algebra.cc
@@ -155,7 +155,7 @@ enum arg_type get_arg_type(const char *arg) {
   if (p == e + 1) {
     return ARG_LONG;
   }
-  if (*p == '.') {
+  if (*p == '.' || *p == ',') {
     p++;
     while (p <= e) {
       if (isdigit((unsigned char)*p) == 0) {

It works. The numbers get printed with comma too. Lazy copied the example above.

56,9K // True
16,9K // False
544B // False
74,9K // True
88,4K // True
13,9K // False

This happens in the master too. Hmm. Actually, I think this is okay as-is. Duh.

Open up a pull request with this change as I'm lazy to do it :hamburger:

You're not lazy. I'm lasers lazier. I'm wondering about something. If this contains a comma, should you not swap characters around first?

  • If comma detected...

    • Replace period with uniq char

    • Replace comma with a period

    • Replace uniq char with comma

    • Compare

Does that make sense or am I thinking too much?

That's the current country standard, why changing it to other ?

Idk. Noob here. I'll make a pull request at your request. What is if (*p == '.') { for?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

txtsd picture txtsd  ·  4Comments

Airblader picture Airblader  ·  4Comments

bunder2015 picture bunder2015  ·  4Comments

bad-interpreter picture bad-interpreter  ·  4Comments

leahneukirchen picture leahneukirchen  ·  3Comments