HokieGeek / dotfiles

My linux config files
0 stars 0 forks source link

Create script that generates conky config for number of CPUs #53

Closed HokieGeek closed 10 years ago

HokieGeek commented 10 years ago

So it will need to generate something along these lines:

${if_match ${cpu cpu1} >= 85}^fg(\#FF0000)${endif}\
${if_match ${cpu cpu1} < 10} ${endif}${cpu cpu1}%^fg(\#FFFFFF) \
${if_match ${cpu cpu2} >= 85}^fg(\#FF0000)${endif}\
${if_match ${cpu cpu2} < 10} ${endif}${cpu cpu2}%^fg(\#FFFFFF) \
${if_match ${cpu cpu3} >= 85}^fg(\#FF0000)${endif}\
${if_match ${cpu cpu3} < 10} ${endif}${cpu cpu3}%^fg(\#FFFFFF) \
${if_match ${cpu cpu4} >= 85}^fg(\#FF0000)${endif}\
${if_match ${cpu cpu4} < 10} ${endif}${cpu cpu4}%^fg(\#FFFFFF) \
HokieGeek commented 10 years ago
#!/usr/bin/python
import subprocess

numCpus = subprocess.check_output("grep -c 'processor' /proc/cpuinfo", shell=True)

for cpu in range(numCpus)
    print("${if_match ${cpu cpu%d} >= 85}^fg(\\#FF0000)${endif}\\", cpu, end="")
    print("${if_match ${cpu cpu%d} < 10} ${endif}${cpu cpu%d}%^fg(\\#FFFFFF) \\", cpu, cpu, end="")

And then, in conky:

${execp $HOME/.conky/bin/cpuinfo.py}
HokieGeek commented 10 years ago

Remove the end-of-line backslashes, idiot