You are not logged in.

#1 2019-02-01 13:10:29

S7.L
Member
Registered: 2018-09-16
Posts: 338

Hacking Inxi For Conky

Finally figured out how to get some temps through inxi into conky. Im going to try and get a  system spec conky happeneing via inxi using the tail head cut commands, so will add a few more up details up when i get it configured. Probably be a bit of a resource hog maybe but my cpu is only at 2 percent and i have about 10 programs running so pretty good for an old i7.

Your results may vary but play around with the values.

conky.text = [[

C P U + G P U   T E M P S ${hr}

Cpu: ${alignr}${execi 5 inxi -s | tail -n2 | head -c99 | cut -b 48-54}
Gpu: ${alignr}${execi 5 inxi -s | tail -n2 | head -c99 | cut -b 92-97}

Looks like

inxitempconky.png

Last edited by S7.L (2019-02-01 13:11:55)

Offline

#2 2019-02-01 14:44:19

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

Well inxi would not give a readout for the distro side of things so used another method there.
Will play around with ram next.

conky.text = [[

S Y S T E M
Linux Kernel: ${alignr}${execi 60 inxi -S | tail -n1 | head -c100 | cut -b 41-55}
Desktop:      ${alignr}${execi 60 inxi -S | tail -n1 | head -c100 | cut -b 86-94 }
Distro:       ${alignr}${execi 60 lsb_release -d | cut -f 2| tr "[:upper:]" "[:upper:]"}

C P U + G P U   T E M P S
Cpu: ${alignr}${execi 5 inxi -s | tail -n2 | head -c99 | cut -b 48-54}
Gpu: ${alignr}${execi 5 inxi -s | tail -n2 | head -c99 | cut -b 92-97}

H D D 
Root: ${alignr}${execi 60 inxi -P | tail -n3 | head -c100 | cut -b 35-44}
Home: ${alignr}${execi 60 inxi -P | tail -n2 | head -c100 | cut -b 35-45}
Swap: ${alignr}${execi 60 inxi -P | tail -n1 | head -c100 | cut -b 37-44}
${voffset 500}
]];

2019-02-02-004155_224x232_scrot.png

Offline

#3 2019-02-01 16:35:28

vasa1
Member
Registered: 2015-09-29
Posts: 173

Re: Hacking Inxi For Conky

Instead of inxi -S, try inxi -Sxx if your version of inxi has that:

$ inxi -Sxx
System:    Host: kububb Kernel: 4.15.0-45-generic x86_64 bits: 64 compiler: gcc v: 7.3.0 
           Desktop: KDE Plasma 5.12.7 tk: Qt 5.9.5 wm: kwin_x11 dm: SDDM 
           Distro: Ubuntu 18.04.1 LTS (Bionic Beaver) 
$ 

I have inxi 3.0.22. Even inxi -Sx would provide some distro info:

$ inxi -Sx
System:    Host: kububb Kernel: 4.15.0-45-generic x86_64 bits: 64 compiler: gcc v: 7.3.0 
           Desktop: KDE Plasma 5.12.7 Distro: Ubuntu 18.04.1 LTS (Bionic Beaver) 
$

Last edited by vasa1 (2019-02-01 16:37:41)


Using the Openbox (3.5.2) session of Lubuntu 14.04 LTS but very interested in BL :)

Offline

#4 2019-02-01 17:00:10

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 730

Re: Hacking Inxi For Conky

inxi -Sxxx will give  the distro, and what distro it's based on, if relevant, so I get told Bunsenlabs & Debian both.

beardy@Bunsen-Buster-SysV:~$ inxi -Sxxx
System:    Host: Bunsen-Buster-SysV Kernel: 4.19.0-1-686 i686 bits: 32 compiler: gcc v: 8.2.0 
           Desktop: Openbox 3.6.1 info: tint2 dm: LightDM 1.26.0 
           Distro: BunsenLabs GNU/Linux 9.6 (Helium) base: Debian GNU/Linux buster/sid 

Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#5 2019-02-01 18:05:45

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 2,190
Website

Re: Hacking Inxi For Conky

Excellent work, thanks for sharing.


I like my Metal like my coffee.......Black!
Resident Metalhead Poser

Offline

#6 2019-02-02 02:19:13

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,143
Website

Re: Hacking Inxi For Conky

inxi is very interesting (only tried it recently) but if all you wanted was the temperature readings then 'sensors' (from package lm-sensors) is much faster (~2 orders of magnitude):

john@helium:~$ time inxi -s
Sensors:
  System Temperatures: cpu: 29.8 C mobo: 27.8 C 
  Fan Speeds (RPM): N/A 

real	0m0.172s
user	0m0.128s
sys	0m0.036s

john@helium:~$ time sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +27.8°C  (crit = +105.0°C)
temp2:        +29.8°C  (crit = +105.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +26.0°C  (high = +80.0°C, crit = +100.0°C)
Core 0:         +21.0°C  (high = +80.0°C, crit = +100.0°C)
Core 1:         +26.0°C  (high = +80.0°C, crit = +100.0°C)
Core 2:         +23.0°C  (high = +80.0°C, crit = +100.0°C)
Core 3:         +23.0°C  (high = +80.0°C, crit = +100.0°C)

real	0m0.002s
user	0m0.000s
sys	0m0.000s

John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#7 2019-02-02 03:18:56

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 730

Re: Hacking Inxi For Conky

I really like inxi, it does have the downside of rather requiring lm-sensors & thereby screwing virtual machine users over (since VMs don't support any such sensors)   It's great on genuine (non-compaq/hewlet-packard) hardware though


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#8 2019-02-02 08:57:20

ohnonot
...again
Registered: 2015-09-29
Posts: 3,573
Website

Re: Hacking Inxi For Conky

instead of calling inxi separately many times over (incredible stress on your system every few seconds), and creating a long row of subshells (one for each pipe), i'd recommend creating one shell script that
a) calls inxi once and saves its output
b) picks out the desired bits and garnishes them with conky syntax
and then use one ${execpi /path/to/script} call in your conky.

that way it's much lighter on resources (if the shell script is done properly of course).

Last edited by ohnonot (2019-02-02 08:59:43)

Offline

#9 2019-02-02 09:32:17

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

@ vasa1, what i meant was that when trying to get a readout of Distro via inxi it does not show in conky, it shows fine in terminal just not when run via conky through commands like i have done with the others.

@ Dobbie, cheers mate.

@ johnraff, ive tried it with sensors also, i have to agree it is a bit quicker than inxi and as BB says Inxi acquires lm sensors.

@ ohnonot, yes you are right there has to be a better way of doing this via shell script, ill hopefully figure it out in due time.
One thing i cant find info on is conky execi? I mean its a bit vague for me at least in the documentation, but when you use say "execi 5" this means the command is run every 5 seconds? So if i put 60 it should be 60 seconds and 3600 is every hour?

Thanks

Offline

#10 2019-02-02 11:10:25

unklar
Member
Registered: 2015-10-31
Posts: 831

Re: Hacking Inxi For Conky

S7.L wrote:

One thing i cant find info on is conky execi? I mean its a bit vague for me at least in the documentation, but when you use say "execi 5" this means the command is run every 5 seconds? So if i put 60 it should be 60 seconds and 3600 is every hour?

exactly   wink

Offline

#11 2019-02-02 11:28:29

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

^ thanks, so therefore i could put some of those execi to 86400, once per day or whenever the conky is started.

I really dont think you can get around this b) that ohnonot mentions. No matter what shell script you put it in, time is still of the essence and conky will still call all said commands through the shell whether its in a script or not?

b) picks out the desired bits and garnishes them with conky syntax

Offline

#12 2019-02-03 11:32:07

ohnonot
...again
Registered: 2015-09-29
Posts: 3,573
Website

Re: Hacking Inxi For Conky

inxi's big advantage is that you can quickly call it from a terminal and get some useful output when troubleshooting.
aurtomatically parsing its output in conky over and over does not seem like its intended use case to me.
afaik inxi relies on system utilities and files present on your machine; for conky i think it would be better to access this information directly.

about the shell script that produces conky syntax:
i have been doing this for years and it works great and i firmly believe that it greatly reduces conky's impact on resources (well not conky itself, but the commands it calls over and over again can be quite greedy. you might not notice if your conky calls sed a dozen times every few seconds, but you will if it's inxi).
keep in mind that you will need execp or execpi for this to work.
i think the documentation tells you how it works quite well.
the most up-to-date i believe is the conky man page, or the github wiki.

here's a very simple example:

the script:

#!/bin/dash
# read cpu temperature from /sys and color it when it gets too hot

warn=50
max=65
crit=80

cd /sys/devices/platform/coretemp.0/hwmon/*/
# $1, on my hardware, needs to be temp2 or temp3 to represent core 0 or core 1.
read temp <$1_input
read templabel <$1_label

temp=${temp%000}

if [ "$temp" -ge "$crit" ] ; then
		echo -n "\${color8}"
	elif  [ "$temp" -ge "$max" ] ; then
	echo -n "\${color7}"
	elif [ "$temp" -ge "$warn" ] ; then
		echo -n "\${color6}"
fi
echo -n "$templabel\${alignr}${temp}°C"

a corresponding snippet from the conkyrc:

${execp ~/.config/conky/sys/cpu-conky-temp.sh temp2}

Offline

#13 2019-02-03 12:03:44

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

^ Ok i see what you mean, nice script by the way, i like how you configured the warn, max, critical.

With execp, what intervals does that conky command run the script?

Offline

#14 2019-02-03 12:34:38

ohnonot
...again
Registered: 2015-09-29
Posts: 3,573
Website

Re: Hacking Inxi For Conky

S7.L wrote:

With execp, what intervals does that conky command run the script?

3s

Offline

#15 2019-02-03 12:39:54

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

ohnonot wrote:
S7.L wrote:

With execp, what intervals does that conky command run the script?

3s

That is what is vague to me in the man page. You have used execp but no update interval and the man page says this..

execp command
              Executes  a  shell  command  and  displays  the output in conky.
              Warning: this takes a lot more resources than  other  variables.
              I'd  recommend  coding  wanted  behaviour in C/C++ and posting a
              patch. This differs from $exec in that it parses the  output  of
              the command, so you can insert things like ${color red}hi!${col‐
              or} in your script  and  have  it  correctly  parsed  by  Conky.
              Caveats:  Conky  parses and evaluates the output of $execp every
              time Conky loops, and then destroys all the objects. If you  try
              to  use anything like $execi within an $execp statement, it will
              functionally run at the same interval that the $execp  statement
              runs, as it is created and destroyed at every interval.

Offline

#16 2019-02-03 12:58:13

ohnonot
...again
Registered: 2015-09-29
Posts: 3,573
Website

Re: Hacking Inxi For Conky

execp does not use its own update interval.
nothing vague about it:

parses and evaluates the output of $execp every
              time Conky loops

are you confused by this:

If you  try
              to  use anything like $execi within an $execp statement, it will
              functionally run at the same interval that the $execp  statement
              runs, as it is created and destroyed at every interval.

???
this applies only to execi statements inside the output meant for an execp statement. you can forget about it for the time being.

in any case, p stands for parse, i stands for interval.
hence execpi also exists.

Offline

#17 2019-02-03 13:12:44

unklar
Member
Registered: 2015-10-31
Posts: 831

Re: Hacking Inxi For Conky

@S7.L

I quote from the german mageia-conky-(wiki) wink , 2009 created by @searchOne (suitable translation you have to choose yourself)

====Arbeiten mit Externen Programmen====

Im Conky-Wiki wurden schon einige Beispiele aufgeführt, wie Externe Programme (Shell Skripte, Python Skripte usw.) in Conky eingebunden werden können. Es gibt insgesamt 12 verschiedene Variablen mit denen das geschehen kann. Hier zuerst eine kleine Übersicht der möglichen Befehle:
 
//$exec// – Kommando - Führt einen Shell-Befehl aus und zeigt das Ergebniss an.
//$execbar// – Dasselbe wie $exec, nur mit einer Anzeige als Bar wenn der Rückgabewert zwischen 0-100 ist.
//$execgauge// – Dasselbe wie $exec, nur mit einer Anzeige als Bar wenn der Rückgabewert zwischen 0-100 ist. Die Gauge-Anzeige kann über die Option //default_gauge_size// gesteuert werden.
//$execgraph// –  Optionen: „normal“|“log“, Höhe/Länge, Farbe Kurvenanstieg 1, Farbe Kurvenanstieg 2, Skalierung -  Dasselbe wie $exec, nur mit einem Diagramm als Anzeige, verwendet eine Logarithmik-Skala. Die Größe für Diagramme kann über die Option //default_graph_size// gesteuert werden.

//$execi// – Intervall Kommando – Führt einen Shell-Befehl in einem bestimmten Zeitabstand aus, Angaben in Sekunden. Der Wert kann nicht kleiner sein, als die Option //update_intervall// von Conky.
//$execibar// – siehe $execi/$execbar
//$execigauge// – siehe $execi/$execgauge
//$execigraph// – siehe $execi/$execgraph

//$execp// – Kommando -  Dasselbe wie $exec, nur mit der Möglichkeit in den Befehlsketten Ausgaben mit Farben oder Fonts zu Dekorieren.
//$execpi// – Intervall Kommando – siehe $execp/$execi

//$texeci// – Intervall Kommando – Dasselbe wie $execi mit dem Unterschied, dass //$texeci// für Befehle verwendet werden sollte, die einen sehr großen Zeit-Intervall haben.

//$pre_exec// – Kommando – Führt ein Shell-Skript vor allem anderen aus, bevor Conky etwas anzeigt.  

Nun noch einige Beispiele:
     ${execibar 10 ~/.conky/amarok2.py progress}
Dieses Beispiel (aus Audioanzeigen entnommen) startet mit //$execibar// alle 10 Sekunden ein Skript zur Graphischen Anzeige eines Fortschrittsbalken für Amarok.
     ${exec ~/conky-thunder.sh 1 name}:${texeci 300 ~/conky-thunder.sh 1 new}
Das nächste Beispiel (aus E-Mail Abfragen entnommen) zeigt eine schöne Kombination von //$exec// und //$texeci//. Im ersten Aufruf mit //$exec// wird nur der Name des E-Mail Postfaches abgefragt, erst der zweite Aufruf mit //$texeci// führt eine Intervall-Abfrage (300 Sekunden) aus, die prüft, ob neue E-Mails im Postfach vorhanden sind.
     ${pre_exec ~/conkycal.sh semana}
     ${pre_exec ~/conkycal.sh pasado}${pre_exec ~/conkycal.sh hoy}
     ${pre_exec ~/conkycal.sh  futuro}
Das obige Beispiel (aus Kalender entnommen) startet mit dem //$pre_exec// Befehl, die Skripte für einen Kalender, und die Ausgabe vor allen anderen Befehlen.

Offline

#18 2019-02-03 13:14:10

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

@ ohnonot, yes but lets say your conky has an interval of 1 then the execp is introduced with the command, how does it make 3 seconds? Is your conky looping every 3 seconds is it? So execp just executes and parses information relying on conkies loop?

Last edited by S7.L (2019-02-03 13:16:06)

Offline

#19 2019-02-03 13:22:39

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Hacking Inxi For Conky

thanks unklar, i dont speak or understand german but ill run it through a translator.

Offline

Board footer

Powered by FluxBB