Skip to content

Commit

Permalink
Merge remote-tracking branch 'tych0/master'
Browse files Browse the repository at this point in the history
Conflicts:
	libqtile/widget/battery.py
  • Loading branch information
paradoxxxzero committed Dec 31, 2011
2 parents c6145d2 + b40bfb2 commit 047b79e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 16 additions & 0 deletions libqtile/manager.py
Expand Up @@ -1652,6 +1652,22 @@ def cmd_togroup(self, prompt="group: ", widget="prompt"):

mb.startInput(prompt, self.moveToGroup, "group")

def cmd_switchgroup(self, prompt="group: ", widget="prompt"):
def f(group):
if group:
try:
self.groupMap[group].cmd_toscreen()
except KeyError:
self.log.add("No group named '%s' present." % group)
pass

mb = self.widgetMap.get(widget)
if not mb:
self.log.add("No widget named '%s' present." % widget)
return

mb.startInput(prompt, f, "group")

def cmd_spawncmd(self, prompt="spawn: ", widget="prompt"):
"""
Spawn a command using a prompt widget, with tab-completion.
Expand Down
11 changes: 9 additions & 2 deletions libqtile/widget/battery.py
Expand Up @@ -19,6 +19,7 @@ class Battery(base._TextBox):
("padding", None, "Battery widget padding. Calculated if None."),
("background", "000000", "Background colour"),
("foreground", "ffffff", "Foreground colour"),
("low_foreground", "FF0000", "font when battery is low"),
("format", "{char} {percent:2.0%} {hour:d}:{min:02d}",
"Display format"),
("battery_name", "BAT0", "ACPI name of a battery, usually BAT0"),
Expand All @@ -36,8 +37,9 @@ class Battery(base._TextBox):
" is discharging")
)

def __init__(self, width=bar.CALCULATED, **config):
def __init__(self, low_percentage=0.10, width=bar.CALCULATED, **config):
base._TextBox.__init__(self, "BAT", **config)
self.low_percentage = low_percentage

def _configure(self, qtile, bar):
base._TextBox._configure(self, qtile, bar)
Expand All @@ -59,8 +61,13 @@ def _get_info(self):

hour = int(time)
min = int(time * 60) % 60
percent = now / full
if stat == DISCHARGING and percent < self.low_percentage:
self.layout.colour = self.low_foreground
else:
self.layout.colour = self.foreground
return self.format.format(char=char,
percent=now / full,
percent=percent,
hour=hour, min=min)

def update(self):
Expand Down

0 comments on commit 047b79e

Please sign in to comment.