commit
fd1eb6e790
4 changed files with 113 additions and 1 deletions
97
bumblebee_status/modules/contrib/blugon.py
Normal file
97
bumblebee_status/modules/contrib/blugon.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
"""Displays temperature of blugon and Controls it.
|
||||
|
||||
Use wheel up and down to change temperature, middle click to toggle and right click to reset temprature.
|
||||
|
||||
Default Values:
|
||||
* Minimum temperature: 1000 (red)
|
||||
* Maximum temperature: 20000 (blue)
|
||||
* Default temperature: 6600
|
||||
|
||||
Requires the following executable:
|
||||
* blugon
|
||||
|
||||
Parameters:
|
||||
* blugon.step: The amount of increase/decrease on scroll (default: 200)
|
||||
|
||||
contributed by `DTan13 <https://github.com/DTan13>`
|
||||
"""
|
||||
|
||||
import core.module
|
||||
import core.widget
|
||||
|
||||
import util.cli
|
||||
import util.format
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class Module(core.module.Module):
|
||||
def __init__(self, config, theme):
|
||||
super().__init__(config, theme, core.widget.Widget(self.full_text))
|
||||
self.__state = True
|
||||
self.__default = 6600
|
||||
self.__step = (
|
||||
util.format.asint(self.parameter("step")) if self.parameter("step") else 200
|
||||
)
|
||||
self.__max, self.__min = 20000, 1000
|
||||
|
||||
file = open(os.path.expanduser("~/.config/blugon/current"))
|
||||
self.__current = int(float(file.read()))
|
||||
|
||||
events = [
|
||||
{
|
||||
"type": "toggle",
|
||||
"action": self.toggle,
|
||||
"button": core.input.MIDDLE_MOUSE,
|
||||
},
|
||||
{
|
||||
"type": "blue",
|
||||
"action": self.blue,
|
||||
"button": core.input.WHEEL_UP,
|
||||
},
|
||||
{
|
||||
"type": "red",
|
||||
"action": self.red,
|
||||
"button": core.input.WHEEL_DOWN,
|
||||
},
|
||||
{
|
||||
"type": "reset",
|
||||
"action": self.reset,
|
||||
"button": core.input.RIGHT_MOUSE,
|
||||
},
|
||||
]
|
||||
|
||||
for event in events:
|
||||
core.input.register(self, button=event["button"], cmd=event["action"])
|
||||
|
||||
def set_temp(self):
|
||||
temp = self.__current if self.__state else self.__default
|
||||
util.cli.execute("blugon --setcurrent={}".format(temp))
|
||||
|
||||
def full_text(self, widget):
|
||||
return self.__current if self.__state else self.__default
|
||||
|
||||
def state(self, widget):
|
||||
if not self.__state:
|
||||
return ["critical"]
|
||||
|
||||
def toggle(self, event):
|
||||
self.__state = not self.__state
|
||||
self.set_temp()
|
||||
|
||||
def reset(self, event):
|
||||
self.__current = 6600
|
||||
self.set_temp()
|
||||
|
||||
def blue(self, event):
|
||||
if self.__state and (self.__current < self.__max):
|
||||
self.__current += self.__step
|
||||
self.set_temp()
|
||||
|
||||
def red(self, event):
|
||||
if self.__state and (self.__current > self.__min):
|
||||
self.__current -= self.__step
|
||||
self.set_temp()
|
||||
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
|
@ -94,6 +94,12 @@ class Module(core.module.Module):
|
|||
"cmd": "mpc toggle" + self._hostcmd,
|
||||
}
|
||||
widget.full_text(self.description)
|
||||
elif widget_name == "mpd.toggle":
|
||||
widget_map[widget] = {
|
||||
"button": core.input.LEFT_MOUSE,
|
||||
"cmd": "mpc toggle" + self._hostcmd,
|
||||
}
|
||||
widget.full_text(self.toggle)
|
||||
elif widget_name == "mpd.next":
|
||||
widget_map[widget] = {
|
||||
"button": core.input.LEFT_MOUSE,
|
||||
|
@ -127,6 +133,9 @@ class Module(core.module.Module):
|
|||
def description(self, widget):
|
||||
return string.Formatter().vformat(self._fmt, (), self._tags)
|
||||
|
||||
def toggle(self, widget):
|
||||
return str(util.cli.execute("mpc status %currenttime%/%totaltime%", ignore_errors=True)).strip()
|
||||
|
||||
def update(self):
|
||||
self._load_song()
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ Parameters:
|
|||
* title.max : Maximum character length for title before truncating. Defaults to 64.
|
||||
* title.placeholder : Placeholder text to be placed if title was truncated. Defaults to '...'.
|
||||
* title.scroll : Boolean flag for scrolling title. Defaults to False
|
||||
* title.short : Boolean flag for short title. Defaults to False
|
||||
|
||||
|
||||
contributed by `UltimatePancake <https://github.com/UltimatePancake>`_ - many thanks!
|
||||
|
@ -35,6 +36,7 @@ class Module(core.module.Module):
|
|||
|
||||
# parsing of parameters
|
||||
self.__scroll = util.format.asbool(self.parameter("scroll", False))
|
||||
self.__short = util.format.asbool(self.parameter("short", False))
|
||||
self.__max = int(self.parameter("max", 64))
|
||||
self.__placeholder = self.parameter("placeholder", "...")
|
||||
self.__title = ""
|
||||
|
@ -66,7 +68,9 @@ class Module(core.module.Module):
|
|||
def __pollTitle(self):
|
||||
"""Updating current title."""
|
||||
try:
|
||||
self.__full_title = self.__i3.get_tree().find_focused().name
|
||||
focused = self.__i3.get_tree().find_focused().name
|
||||
self.__full_title = focused.split(
|
||||
"-")[-1].strip() if self.__short else focused
|
||||
except:
|
||||
self.__full_title = no_title
|
||||
if self.__full_title is None:
|
||||
|
|
2
tests/modules/contrib/test_blugon.py
Normal file
2
tests/modules/contrib/test_blugon.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
def test_load_module():
|
||||
__import__("modules.contrib.zpool")
|
Loading…
Reference in a new issue