def test_text_battery_error(monkeypatch): with monkeypatch.context() as m: m.setattr(battery, "load_battery", DummyErrorBattery) batt = Battery() text = batt.poll() assert text == "Error: err"
def test_text_battery_empty(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.EMPTY, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Empty" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(show_short_text=False) text = batt.poll() assert text == "x 50% 0:28 15.00 W" loaded_bat = BatteryStatus( state=BatteryState.UNKNOWN, percent=0., power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Empty"
def test_text_battery_discharging(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "V 50% 0:28 15.00 W"
def test_text_battery_unknown(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.UNKNOWN, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "? 50% 0:28 15.00 W"
def __init__(self, **config): _Battery.__init__(self, **config) self.add_defaults(BatteryIcon.defaults) if self.theme_path: self.length_type = bar.STATIC self.length = 0 self.surfaces = {} self.current_icon = 'battery_full' self.icons = dict([ (x, '{0}.png'.format(x)) for x in ('battery_20', 'battery_30', 'battery_50', 'battery_60', 'battery_80', 'battery_90', 'battery_charging_20', 'battery_charging_30', 'battery_charging_50', 'battery_charging_60', 'battery_charging_80', 'battery_charging_90', 'battery_charging_full', 'battery_full') ]) self.icons.update(self.custom_icons)
def init_widgets(): prompt = "{0}@{1}: ".format(os.environ["USER"], hostname) widgets = [ Prompt(prompt=prompt, font="DejaVu Sans Mono", padding=10, background=GREY), TextBox(text="◤ ", fontsize=45, padding=-8, foreground=GREY, background=DARK_GREY), CurrentLayoutIcon(scale=0.6, padding=-4), TextBox(text=" ", padding=2), GroupBox(fontsize=8, padding=4, borderwidth=1, urgent_border=DARK_BLUE, disable_drag=True, highlight_method="block", this_screen_border=DARK_BLUE, other_screen_border=DARK_ORANGE, this_current_screen_border=BLUE, other_current_screen_border=ORANGE), TextBox(text="◤", fontsize=45, padding=-1, foreground=DARK_GREY, background=GREY), TaskList(borderwidth=0, highlight_method="block", background=GREY, border=DARK_GREY, urgent_border=DARK_BLUE), Systray(background=GREY), TextBox(text="◤", fontsize=45, padding=-1, foreground=GREY, background=DARK_GREY), TextBox(text=" ⚠", foreground=BLUE, fontsize=18), Notify(), TextBox(text=" ⌚", foreground=BLUE, fontsize=18), Clock(format="%A %d-%m-%Y %H:%M") ] if hostname in ("spud", "saiga"): widgets[-2:-2] = [ TextBox(text=" ↯", foreground=BLUE, fontsize=14), Battery(update_delay=2) ] if DEBUG: widgets += [Sep(), CurrentLayout()] return widgets
def test_text_battery_full(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.FULL, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Full" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(show_short_text=False) text = batt.poll() assert text == "= 50% 0:28 15.00 W"
def test_text_battery_hidden(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(hide_threshold=0.6) text = batt.poll() assert text != "" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(hide_threshold=0.4) text = batt.poll() assert text == ""
def init_widgets(): widgets = [ CurrentLayoutIcon(scale=0.6, padding=8), GroupBox(fontsize=8, padding=4, borderwidth=1, urgent_border=DARK_BLUE, disable_drag=True, highlight_method="block", this_screen_border=DARK_BLUE, other_screen_border=DARK_ORANGE, this_current_screen_border=BLUE, other_current_screen_border=ORANGE), TextBox(text="◤", fontsize=45, padding=-1, foreground=DARK_GREY, background=GREY), TaskList(borderwidth=0, highlight_method="block", background=GREY, border=DARK_GREY, urgent_border=DARK_BLUE, markup_floating="<i>{}</i>", markup_minimized="<s>{}</s>"), Systray(background=GREY), TextBox(text="◤", fontsize=45, padding=-1, foreground=GREY, background=DARK_GREY), Notify(fmt=" 🔥 {} "), PulseVolume(fmt=" {}", emoji=True, volume_app="pavucontrol"), PulseVolume(volume_app="pavucontrol"), Clock(format=" ⏱ %H:%M <span color='#666'>%A %d-%m-%Y</span> ") ] if os.path.isdir("/sys/module/battery"): widgets.insert(-1, Battery(format=" {char} {percent:2.0%} ", charge_char="⚡", discharge_char="🔋", full_char="⚡", unknown_char="⚡", empty_char="⁉️ ", update_interval=2, show_short_text=False, default_text="")) widgets.insert(-1, Battery(fmt="<span color='#666'>{}</span> ", format="{hour:d}:{min:02d}", update_interval=2, show_short_text=True, default_text="")) if DEBUG: widgets += [Sep(), CurrentLayout()] return widgets
def init_widgets(): prompt = "{0}@{1}: ".format(os.environ["USER"], hostname) widgets = [ Prompt(prompt=prompt, font="DejaVu Sans Mono", padding=10, background=GREY), TextBox(text="◤ ", fontsize=45, padding=-8, foreground=GREY, background=DARK_GREY), CurrentLayoutIcon(scale=0.6, padding=-4), Spacer(width=10), GroupBox(fontsize=8, padding=4, borderwidth=1, urgent_border=DARK_BLUE, disable_drag=True, highlight_method="block", this_screen_border=DARK_BLUE, other_screen_border=DARK_ORANGE, this_current_screen_border=BLUE, other_current_screen_border=ORANGE), TextBox(text="◤", fontsize=45, padding=-1, foreground=DARK_GREY, background=GREY), TaskList(borderwidth=0, highlight_method="block", background=GREY, border=DARK_GREY, urgent_border=DARK_BLUE), Systray(background=GREY), TextBox(text="◤", fontsize=45, padding=-1, foreground=GREY, background=DARK_GREY), Notify(fmt=" 🔥 {}"), Clock(fmt=" ⌚ {}", format="%A %d-%m-%Y %H:%M") ] if os.path.isdir("/sys/module/battery"): widgets.insert(-1, Battery(fmt=" ⚡️ {}", update_delay=2)) if DEBUG: widgets += [Sep(), CurrentLayout()] return widgets
def init_widgets(self) -> list: """Inits and returns the widgets for primary monitor.""" return [ Spacer(**self._widget_settings["spacer"]), TextBox(**self._widget_settings["launcher"]), Spacer(**self._widget_settings["spacer"]), GroupBox(**self._widget_settings["group_box"]), CurrentLayoutIcon(**self._widget_settings["current_layout_icon"]), Spacer(**self._widget_settings["spacer"]), WindowName(**self._widget_settings["window_name"]), Spacer(**self._widget_settings["spacer_stretch"]), Systray(**self._widget_settings["systray"]), Spacer(**self._widget_settings["spacer"]), PulseVolume(**self._widget_settings["pulse_volume"]), Clock(**self._widget_settings["calendar"]), Clock(**self._widget_settings["clock"]), Battery(**self._widget_settings["battery"]) if self.theme_config.widgets["show_battery"] else Spacer( **self._widget_settings["spacer"]), QuickExit(**self._widget_settings["quick_exit"]), Spacer(**self._widget_settings["spacer"]), ]
Image( filename=expanduser("~/.config/qtile/icons/p4.png"), margin=0, background=bar_colors[0], ), Image( filename=expanduser("~/.config/qtile/icons/battery.png"), background=bar_colors[2], margin=1, ), Battery( charge_char="AC", discharge_char="", low_foreground=bar_colors[1], low_percentage=0.2, format= "{char} {percent:2.0%} ({hour:d}:{min:02d}) {watt:.2f} W", update_interval=30, background=bar_colors[2], foreground=bar_colors[0], ), Image( filename=expanduser("~/.config/qtile/icons/p5.png"), margin=0, background=bar_colors[0], ), Image( filename=expanduser("~/.config/qtile/icons/brightness.png"), background=bar_colors[3], margin=2, ),