Merge pull request #871 from SamTebbs33/main
Add hide parameter to playerctl
This commit is contained in:
commit
d3de79e6b4
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
|
Widget names are: playerctl.song, playerctl.prev, playerctl.pause, playerctl.next
|
||||||
* playerctl.args: The arguments added to playerctl.
|
* 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'.
|
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!
|
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.background = True
|
||||||
|
|
||||||
|
self.__hide = util.format.asbool(self.parameter("hide", "false"));
|
||||||
|
|
||||||
self.__layout = util.format.aslist(
|
self.__layout = util.format.aslist(
|
||||||
self.parameter(
|
self.parameter(
|
||||||
"layout", "playerctl.prev, playerctl.song, playerctl.pause, playerctl.next"
|
"layout", "playerctl.prev, playerctl.song, playerctl.pause, playerctl.next"
|
||||||
|
@ -83,14 +86,20 @@ class Module(core.module.Module):
|
||||||
if isinstance(callback_options, dict):
|
if isinstance(callback_options, dict):
|
||||||
core.input.register(widget, **callback_options)
|
core.input.register(widget, **callback_options)
|
||||||
|
|
||||||
def update(self):
|
def hidden(self):
|
||||||
|
return self.__hide and self.status() == None
|
||||||
|
|
||||||
|
def status(self):
|
||||||
try:
|
try:
|
||||||
playback_status = str(util.cli.execute(self.__cmd + "status 2>&1 || true", shell = True)).strip()
|
playback_status = str(util.cli.execute(self.__cmd + "status 2>&1 || true", shell = True)).strip()
|
||||||
if playback_status == "No players found":
|
if playback_status == "No players found":
|
||||||
playback_status = None
|
return None
|
||||||
|
return playback_status
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
playback_status = None
|
return None
|
||||||
|
|
||||||
|
def update(self):
|
||||||
for widget in self.widgets():
|
for widget in self.widgets():
|
||||||
if playback_status:
|
if playback_status:
|
||||||
if widget.name == "playerctl.pause":
|
if widget.name == "playerctl.pause":
|
||||||
|
|
|
@ -1095,6 +1095,7 @@ Parameters:
|
||||||
Widget names are: playerctl.song, playerctl.prev, playerctl.pause, playerctl.next
|
Widget names are: playerctl.song, playerctl.prev, playerctl.pause, playerctl.next
|
||||||
* playerctl.args: The arguments added to playerctl.
|
* 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'.
|
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!
|
Parameters are inspired by the `spotify` module, many thanks to its developers!
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue