Index: channels/global_key.py ================================================================== --- channels/global_key.py +++ channels/global_key.py @@ -1,30 +1,28 @@ -# # api: streamtuner2 # title: Global keyboard shortcut # description: Allows switching between bookmarked radios via key press. # type: feature # category: ui -# version: 0.2 +# version: 0.3 # config: # { name="switch_key", type="text", value="XF86Forward", description="Global key shortcut for switching radio." }, # { name="switch_channel", type="text", value="bookmarks:favourite", description="Station list and channels to alternate in." }, # { name="switch_random", type="boolean", value=0, description="Pick random channel, instead of next." }, # priority: extra # depends: python-keybinder # # -# Binds a key to global desktop (F13 = left windows key). On keypress -# it switches the currently playing radio station to another one in -# bookmarks list. +# Binds a key to global desktop (F13 = left windows key). +# On keypress switches the currently playing radio station +# to another one from the bookmarks list. # -# Valid key names are for example F9, G, R, N -# +# Valid key names are `F9`, `G`, `R` for example. import keybinder -from config import conf +from config import * import action import random @@ -38,15 +36,16 @@ # register def __init__(self, parent): self.parent = parent + conf.add_plugin_defaults(self.meta["config"], self.module) try: for i,keyname in enumerate(conf.switch_key.split(",")): # allow multiple keys keybinder.bind(keyname, self.switch, ((-1 if i else +1))) # forward +1 or backward -1 except: - print("Key could not be registered") + __print__(dbg.ERR, "plugin global_key: Key `%s` could not be registered" % conf.switch_key) # key event def switch(self, num, *any):