SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-04-01 17:58:48

johnnytruant
Member
From: Norwich, UK
Registered: 2010-04-01
Posts: 48

help with dynamic colours in conky/lua

So, I've been tinkering around with londonali1010's ring meters for conky.  purdy.  see here if you don't know the rings

Then, thinks I, it would be nice if my cpu monitor changed colour depending on the frequency scaling settings.

So.  time to learn some Lua.

I have a variable which changes value for colour based on cpu frequency (my freq options are 1600, 1060 and 800)

    fstr=tonumber(conky_parse('freq'))
    print(fstr)
    if fstr == 800 then
        cpucolor=0xffff00
    else
        cpucolor=0xff0000
    end

and that's all fine.  Yellow for 800Mhz, red for anything else.  Eventually, I'll put in orange for 1060, but for now it'll do.  I've put it in the correct place so it runs each time conky updates - previously ran once when the script loaded.

what I can't get it to do is change the value of fg_colour in Ali's settings_table table for each time conky_ring_stats runs.

{
        name='cpu',
        arg='cpu0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=cpucolor,
        fg_alpha=0.8,
        x=941, y=65,
        radius=41,
        thickness=11,
        start_angle=0,
        end_angle=180
    }

I've tried:

fg_colour=_G[cpucolor]

no joy.

Any tips/guidance would be much appreciated.  Lua seems nice.

Offline

Be excellent to each other!

#2 2010-04-01 18:58:53

johnnytruant
Member
From: Norwich, UK
Registered: 2010-04-01
Posts: 48

Re: help with dynamic colours in conky/lua

As always when I've spent ages bashing away at something, I've solved it myself within no time of posting on a forum about it.  smile

fstr=tonumber(conky_parse('${freq}','')fstr)
    if fstr == 800 then
        settings_table[2]['fg_colour']=0xffff00
    else
        settings_table[2]['fg_colour']=0xff0000
    end

Was all it took.  the cpu settings in settings_table are in the second position, what I (being a php/bash-ist) would address as settings_table[1]

it appears Lua counts from 1, not 0.  Not what I was expecting, but there you go.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo