Skip to content

Commit

Permalink
FIX: Respects config without cpu usage and temp.
Browse files Browse the repository at this point in the history
Respects i3status config without cpu usage and temperature.
Support python 3.
  • Loading branch information
danil committed Dec 19, 2014
1 parent c1c6931 commit bef4c94
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions i3-dzen-bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,25 @@ def get_color(t):


while True:
line = raw_input()
cpu_usage = CPU_PATTERN.search(line).groups()[0]
origin_cpu_text = CPU_PATTERN.search(line).group()
new_cpu_text = get_color(int(cpu_usage)) + origin_cpu_text

line = line.replace(origin_cpu_text, new_cpu_text)

temperature = TEMP_PATTERN.search(line).groups()[0]
origin_temp_text = TEMP_PATTERN.search(line).group()
new_temp_text = get_color(int(temperature)) + origin_temp_text

line = line.replace(origin_temp_text, new_temp_text)

# Fix Python 2.x.
try: input = raw_input
except NameError: pass

line = input()

cpu_usage_matches = CPU_PATTERN.search(line)
if cpu_usage_matches is not None:
cpu_usage = cpu_usage_matches.groups()[0]
origin_cpu_text = cpu_usage_matches.group()
new_cpu_text = get_color(int(cpu_usage)) + origin_cpu_text
line = line.replace(origin_cpu_text, new_cpu_text)

temperature_matches = TEMP_PATTERN.search(line)
if temperature_matches is not None:
temperature = temperature_matches.groups()[0]
origin_temp_text = temperature_matches.group()
new_temp_text = get_color(int(temperature)) + origin_temp_text
line = line.replace(origin_temp_text, new_temp_text)

for k, v in REPLACE_ITEM:
line = line.replace(k, v)
Expand Down

0 comments on commit bef4c94

Please sign in to comment.