[modules/playerctl] add 'hide' parameter
This commit is contained in:
parent
d1ae8f277f
commit
771e7482d7
2 changed files with 13 additions and 3 deletions
|
@ -12,6 +12,7 @@ Parameters:
|
|||
Widget names are: playerctl.song, playerctl.prev, playerctl.pause, playerctl.next
|
||||
* playerctl.args: The arguments added to playerctl.
|
||||
You can check 'playerctl --help' or `its README <https://github.com/altdesktop/playerctl#using-the-cli>`_. For example, it could be '-p vlc,%any'.
|
||||
* playerctl.hide: Hide the widgets when no players are found. Defaults to "false".
|
||||
|
||||
Parameters are inspired by the `spotify` module, many thanks to its developers!
|
||||
|
||||
|
@ -32,6 +33,8 @@ class Module(core.module.Module):
|
|||
|
||||
self.background = True
|
||||
|
||||
self.__hide = util.format.asbool(self.parameter("hide", "false"));
|
||||
|
||||
self.__layout = util.format.aslist(
|
||||
self.parameter(
|
||||
"layout", "playerctl.prev, playerctl.song, playerctl.pause, playerctl.next"
|
||||
|
@ -83,14 +86,20 @@ class Module(core.module.Module):
|
|||
if isinstance(callback_options, dict):
|
||||
core.input.register(widget, **callback_options)
|
||||
|
||||
def update(self):
|
||||
def hidden(self):
|
||||
return self.__hide and self.status() == None
|
||||
|
||||
def status(self):
|
||||
try:
|
||||
playback_status = str(util.cli.execute(self.__cmd + "status 2>&1 || true", shell = True)).strip()
|
||||
if playback_status == "No players found":
|
||||
playback_status = None
|
||||
return None
|
||||
return playback_status
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
playback_status = None
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
for widget in self.widgets():
|
||||
if playback_status:
|
||||
if widget.name == "playerctl.pause":
|
||||
|
|
|
@ -1095,6 +1095,7 @@ Parameters:
|
|||
Widget names are: playerctl.song, playerctl.prev, playerctl.pause, playerctl.next
|
||||
* playerctl.args: The arguments added to playerctl.
|
||||
You can check 'playerctl --help' or `its readme <https://github.com/altdesktop/playerctl#using-the-cli>`_. For example, it could be '-p vlc,%any'.
|
||||
* playerctl.hide: Hide the widgets when no players are found. Defaults to "false".
|
||||
|
||||
Parameters are inspired by the `spotify` module, many thanks to its developers!
|
||||
|
||||
|
|
Loading…
Reference in a new issue