LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-28-2011, 08:37 PM   #1
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
Conky: calculations, loops, and substitutions


My conky writes the data to a file and display it in the terminal window. I have three questions regarding conky working in such a configuration:

1. Is it possible to round up the numbers with the decimal fractions using conky when the decimal part is equal or greater 0.5?

2. Is it possible to use loops such as “if ... then ... else ... fi” using conky?

3. Is it possible to substitute the characters _ and # used by conky to display a bar with the other characters?
 
Old 11-29-2011, 01:02 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

Honestly, you can pretty much find your answers within the conky documentation itself. Have a look here - http://conky.sourceforge.net/docs.html and http://conky.sourceforge.net/variables.html

To help answer your questions though -

1. Yes, using decimal padding in your config file.
2. There are many if-then-else loops you can use, have a look at the variables page I included above for the possibilities, since it is way to much to type and explain, especially when the documentation can explain it better.
3. You should be able to escape characters with a backslash \

Cheers,

Josh
 
Old 11-30-2011, 02:37 AM   #3
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
corp769,

I inspected the documentation carefully before I asked my three questions so these questions weren’t the result of my laziness but of my helplessness. You directed me with your answers back to the documentation. I’m sorry. In that case that doesn’t help at all. Let me explain that in a more extended form.

1. The numbers with the decimal fractions

As for my first question I had in mind such numbers with the decimal fractions as produced by the following conky entries:

Code:
${top cpu 1} ${top name 1}
${top cpu 2} ${top name 2}
or:

Code:
${downspeed eth0}
${upspeed eth0}
The first two entries can display something like:

Code:
2.83 X
0.70 kworker/0:1
The following two entries can display something like:

Code:
6.56K
1.67K
I’d like to round up the numbers when the decimal fraction is greater or equal 0.5 as follows:

Code:
3 X
1 kworker/0:1
and:

Code:
7K
2K
Instead of downspeed and upspeed conky objects one can use downspeedf and upspeedf objects but these objects are unusable from my point of view because they use KiB unit only with one decimal while I need B, KiB, MiB, GiB etc. units without any decimal.

As for the other possibilities of changing decimal fractions that are described in the documentation there is a pad_percents object but it concerns merely percents.

I’m sorry but I don’t see in the given documentation the clue how can I round up the numbers with the decimal fractions.

2. Loops such as if ... then ... else ...

As for my second question I had in mind loops as the following:

Code:
IF THE RESULT OF ${downspeed eth0}
IS GREATER OR EQUAL THAN THE RESULT OF ${upspeed eth0}
THEN PRINT ${downspeed eth0}
ELSE PRINT ${upspeed eth0}
So let’s assume downspeed is equal 6.56K and upspeed is equal 1.67K. In such a case the above loop should display the downspeed value. In the opposite situation – when the upspeed is greater than the downspeed – the loop should display the upspeed value.

I’m still sorry but I can’t find any clue concerning such a loop on the variables page.

3. Characters substitution

As for my third question the hint “You should be able to escape characters with a backslash \” is irrelevant. Maybe it’s my fault because I was laconic asking that question. I’m sorry.

Now I ask the same question once again in a more precise manner.

I customized conky configuration to write the data to a file and don’t display anything on the desktop or on the console.

Conky bar objects such as:

Code:
${cpubar 4}
or:

Code:
$battery_bar
print to the file something like that:

Code:
###_______
In the above example three hashes (#) mean “from 25 to 34 percent” and seven underscores (_) mean “the empty rest of the bar”.

Because I don’t like hashes and underscores I’d like to force conky to use exclamation marks (!) instead of hashes and dots (.) instead of underscores when it prints a bar as I illustrated that in the following example:

Code:
!!!.......
I’m aware it’s possible to achieve that modifying the source code of conky but I’d like to achieve that using the appropriate configuration file.
 
Old 11-30-2011, 02:55 AM   #4
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Original Poster
Rep: Reputation: 234Reputation: 234Reputation: 234
My current ~/.conkyrc file configuration settings look like:

Code:
overwrite_file /tmp/.conky.tmp
temperature_unit celsius

out_to_x no
background no
cpu_avg_samples 2
net_avg_samples 2
no_buffers yes
out_to_stderr no
update_interval 3.0
uppercase no
use_spacer none
out_to_console no
extra_newline no
short_units
Maybe it’ll help you to answer my questions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
conky question: passing conky-variable to shell-script zlin50 Linux - Software 2 12-29-2012 06:47 PM
code substitutions Loarn Programming 2 07-14-2011 06:07 PM
LXer: Conky Colors Makes Your Conky Beautiful In Seconds (Version 3.20 Released) LXer Syndicated Linux News 0 08-01-2010 11:21 AM
Conky on Suse 10.0 - *** buffer overflow detected *** conky terminated Slidex Linux - Software 1 03-17-2006 11:50 AM
sed? -- making substitutions scabies Linux - Software 1 12-21-2003 11:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration