You are not logged in.

#1 2014-04-13 09:37:00

Mnk
Member
Registered: 2014-04-13
Posts: 10

[SOLVED] i3bar & conky | 3 color states

I've been messing with this for days but I just can't seem to find anything that works.

I'm using conky is my input for i3bar and it works fine, until I attempt to implement one thing I thought would be simple. No matter how I try to implement it (so far).

What I'm trying to do is to give things like the battery, wifi and temperature indicators 3 color states. (Green, yellow and red depending on status)

2 states works fine, but if I try to add a third it blows up for some reason and I just can't seem to see what I'm doing wrong.


These are 2 examples:

The lines commented out are the ones that make it blow up (only once it reaches the lower threshold though).

	{ "full_text" : "RAM ${memperc}%" , "color" :
		${if_match ${memperc}>80}"\#dc322f"
#			${else}${if_match ${memperc}>50}"\#b58900"
			$else "\#268bd2"
		${endif} },
	${if_match "$battery_short"=="F"} {"full_text": "?"},
	${else}${if_match "$battery_short"<"D"} {"full_text": "? ${battery_percent}%","color":"\#859900"},
	$else {"full_text": " ? ${battery_percent}%","color":
		${if_match ${battery_percent}<20}"\#dc322f"
#		${else}${if_match ${battery_percent}<50}"\#b58900"
		$else "\#859900"
		${endif}},
	${endif}

The bar (in case that tells anything):

ZwBnlgv.png


Do I need a different approach or have I made a mistake somewhere? :x

Last edited by Mnk (2014-04-13 13:24:12)

Offline

#2 2014-04-13 12:13:09

jv2112
Member
Registered: 2011-07-23
Posts: 160

Re: [SOLVED] i3bar & conky | 3 color states

You need to list your condition first then the result set.

Working Example from mine:

{"full_text":" - Temp : ","color":"\#F1E214","separator":false,"separator_block_width":6},\
{"full_text":"${if_match ${hwmon 0 temp 1}<40}${hwmon 0 temp 1} °C ","color":"\#18F114","separator":true,"separator_block_width":6},\
{"full_text":"${else}"},\
{"full_text":"${if_match ${hwmon 0 temp 1}<55}${hwmon 0 temp 1} °C ","color":"\#F1E214","separator":true,"separator_block_width":6},\
{"full_text":"${else}"},\
{"full_text":"${if_match ${hwmon 0 temp 1}>=55}${hwmon 0 temp 1} °C ","color":"\#F50612","separator":true,"separator_block_width":6},\
{"full_text":"${else}"},\
{"full_text":"${endif}${endif}${endif}"},\

Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -

Offline

#3 2014-04-13 13:23:02

Mnk
Member
Registered: 2014-04-13
Posts: 10

Re: [SOLVED] i3bar & conky | 3 color states

It works perfectly! Thank you so much! I changed the way I change 'icon' (what you see as a '?' in the code) as well and the code looks much smoother now. Now I just have to clean up the rest as well.

${if_existing /sys/class/power_supply/AC0/online 0}
	{"full_text": " ? ","color":"\"859900","separator":false,"separator_block_width":6},\
	{"full_text": "${if_match ${battery_percent}<20}${battery_percent}%","color":"\#dc322f"},\
	{"full_text":"${else}"},\
	{"full_text":"${if_match ${battery_percent}<50}${battery_percent}%","color":"\#b58900"},\
	{"full_text":"${else}"},\
	{"full_text":"${if_match ${battery_percent}>=50}${battery_percent}%","color":"\#859900"},\
	{"full_text":"${else}"},\
	{"full_text":"${endif}${endif}${endif}"},\
${else}
	{"full_text": " ? ${battery_percent}% ","color":"\#859900"},\
${endif}

Last edited by Mnk (2014-04-13 13:24:50)

Offline

#4 2014-04-13 21:02:42

jv2112
Member
Registered: 2011-07-23
Posts: 160

Re: [SOLVED] i3bar & conky | 3 color states

Good to hear :-)


Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -

Offline

Board footer

Powered by FluxBB