diff --git a/py3status/constants.py b/py3status/constants.py index a0375ccd36..0a03a9b75a 100644 --- a/py3status/constants.py +++ b/py3status/constants.py @@ -225,10 +225,22 @@ "new": ["coin_market"], "msg": "Module {old} is no longer available due to unmaintained APIs. You can try a different module {new}.", }, + "clementine": { + "new": ["playerctl"], + "msg": "Module {old} has been replaced with a module {new}.", + }, + "gpmdp": { + "new": ["playerctl"], + "msg": "Module {old} has been replaced with a module {new}.", + }, "nvidia_temp": { "new": ["nvidia_smi"], "msg": "Module {old} has been replaced with a module {new}.", }, + "player_control": { + "new": ["playerctl"], + "msg": "Module {old} has been replaced with a module {new}.", + }, "scratchpad_async": { "new": ["scratchpad"], "msg": "Module {old} has been replaced with a consolidated module {new}.", diff --git a/py3status/modules/clementine.py b/py3status/modules/clementine.py deleted file mode 100644 index 268a200663..0000000000 --- a/py3status/modules/clementine.py +++ /dev/null @@ -1,85 +0,0 @@ -""" -Display song currently playing in Clementine. - -Configuration parameters: - cache_timeout: refresh interval for this module (default 5) - format: display format for this module (default '♫ {current}') - -Format placeholders: - {current} currently playing - -Requires: - clementine: a modern music player and library organizer - qdbus: a communication-interface for qt-based applications - (may be part of qt5-tools) - -@author Francois LASSERRE -@license GNU GPL https://www.gnu.org/licenses/gpl.html - -SAMPLE OUTPUT -{'full_text': '♫ Music For Programming - Hivemind'} -""" - -CMD = "qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata" -STRING_NOT_INSTALLED = "not installed" -INTERNET_RADIO = "Internet Radio" - - -class Py3status: - """ """ - - # available configuration parameters - cache_timeout = 5 - format = "♫ {current}" - - def post_config_hook(self): - if not self.py3.check_commands("clementine"): - raise Exception(STRING_NOT_INSTALLED) - - def clementine(self): - artist = lines = now_playing = title = "" - internet_radio = False - - try: - metadata = self.py3.command_output(CMD) - lines = filter(None, metadata.splitlines()) - except self.py3.CommandError: - return { - "cached_until": self.py3.time_in(self.cache_timeout), - "full_text": "", - } - - for item in lines: - if "artist" in item: - artist = item[14:] - if "title" in item: - title = item[13:] - - if ".mp3" in title or ".wav" in title: - title = title[:-4] - if "http" in title: - title = "" - internet_radio = True - - if artist and title: - now_playing = f"{artist} - {title}" - elif artist: - now_playing = artist - elif title: - now_playing = title - elif internet_radio: - now_playing = INTERNET_RADIO - - return { - "cached_until": self.py3.time_in(self.cache_timeout), - "full_text": self.py3.safe_format(self.format, {"current": now_playing}), - } - - -if __name__ == "__main__": - """ - Run module in test mode. - """ - from py3status.module_test import module_test - - module_test(Py3status) diff --git a/py3status/modules/gpmdp.py b/py3status/modules/gpmdp.py deleted file mode 100644 index f982d34761..0000000000 --- a/py3status/modules/gpmdp.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -Display song currently playing in Google Play Music Desktop Player. - -Configuration parameters: - cache_timeout: refresh interval for this module (default 5) - format: specify the items and ordering of the data in the status bar. - These area 1:1 match to gpmdp-remote's options - (default '♫ {info}') - -Format placeholders: - {info} Print info about now playing song - {title} Print current song title - {artist} Print current song artist - {album} Print current song album - {album_art} Print current song album art URL - {time_current} Print current song time in milliseconds - {time_total} Print total song time in milliseconds - {status} Print whether GPMDP is paused or playing - {current} Print now playing song in "artist - song" format - - -Requires: - gpmdp: https://www.googleplaymusicdesktopplayer.com/ - gpmdp-remote: https://github.com/iandrewt/gpmdp-remote - -@author Aaron Fields https://twitter.com/spirotot -@license BSD - -SAMPLE OUTPUT -{'full_text': '♫ Now Playing: The Show Goes On by Lupe Fiasco'} -""" - - -class Py3status: - """ """ - - # available configuration parameters - cache_timeout = 5 - format = "♫ {info}" - - def gpmdp(self): - def _run_cmd(cmd): - return self.py3.command_output(["gpmdp-remote", cmd]).strip() - - full_text = "" - if _run_cmd("status") == "Playing": - cmds = [ - "info", - "title", - "artist", - "album", - "status", - "current", - "time_total", - "time_current", - "album_art", - ] - data = {} - for cmd in cmds: - if self.py3.format_contains(self.format, f"{cmd}"): - data[cmd] = _run_cmd(cmd) - full_text = self.py3.safe_format(self.format, data) - - return { - "cached_until": self.py3.time_in(self.cache_timeout), - "full_text": full_text, - } - - -if __name__ == "__main__": - """ - Run module in test mode. - """ - from py3status.module_test import module_test - - module_test(Py3status) diff --git a/py3status/modules/player_control.py b/py3status/modules/player_control.py deleted file mode 100644 index 78e1b6bd19..0000000000 --- a/py3status/modules/player_control.py +++ /dev/null @@ -1,191 +0,0 @@ -""" -Control Audacious or VLC media player. - -Provides an icon to control simple functions of audio/video players: - - start (left click) - - stop (left click) - - pause (middle click) - -Configuration parameters: - cache_timeout: how often to update in seconds (default 10) - debug: enable verbose logging (bool) (default False) - format: format of the output (default "{icon}") - pause_icon: (default '❚❚') - play_icon: (default '▶') - stop_icon: (default '◼') - supported_players: supported players (str) (comma separated list) - (default 'audacious,vlc') - volume_tick: percentage volume change on mouse wheel (int) (positive number - or None to disable it) (default 1) - -Format placeholders: - {icon} an icon to control music/video players - -@author Federico Ceratto , rixx -@license BSD - -SAMPLE OUTPUT -{'full_text': u'\u25b6'} - -stop -{'full_text': u'\u25fc'} - -pause -{'full_text': u'\u275a\u275a'} -""" -# Any contributor to this module should add his/her name to the @author -# line, comma separated. - -from pathlib import Path - -try: - import dbus - - dbus_available = True -except: # noqa e722 // (ImportError, ModuleNotFoundError): # (py2, assumed py3) - dbus_available = False - - -class Py3status: - """ """ - - # available configuration parameters - cache_timeout = 10 - debug = False - format = "{icon}" - pause_icon = "❚❚" - play_icon = "▶" - stop_icon = "◼" - supported_players = "audacious,vlc" - volume_tick = 1 - - def post_config_hook(self): - self.status = "stop" - self.icon = self.play_icon - - def on_click(self, event): - """ """ - buttons = (None, "left", "middle", "right", "up", "down") - try: - button = buttons[event["button"]] - except IndexError: - return - - if button in ("up", "down"): - if self.volume_tick is None: - return - - self._change_volume(button == "up") - return - - if self.status == "play": - if button == "left": - self._stop() - - elif button == "middle": - self._pause() - - elif self.status == "stop": - if button == "left": - self._play() - - elif self.status == "pause": - if button in ("left", "right"): - self._play() - - def _run(self, command): - if self.debug: - self.py3.log(f"running {command}") - self.py3.command_run(command) - - def _play(self): - self.status = "play" - self.icon = self.stop_icon - player_name = self._detect_running_player() - if player_name == "audacious": - self._run(["audacious", "-p"]) - elif player_name == "vlc": - player = self._get_vlc() - if player: - player.Play() - - def _stop(self): - self.status = "stop" - self.icon = self.play_icon - player_name = self._detect_running_player() - if player_name == "audacious": - self._run(["audacious", "-s"]) - elif player_name == "vlc": - player = self._get_vlc() - if player: - player.Stop() - - def _pause(self): - self.status = "pause" - self.icon = self.pause_icon - player_name = self._detect_running_player() - if player_name == "audacious": - self._run(["audacious", "-u"]) - elif player_name == "vlc": - player = self._get_vlc() - if player: - player.Pause() - - def _change_volume(self, increase): - """Change volume using amixer""" - sign = "+" if increase else "-" - delta = f"{self.volume_tick}%{sign}" - self._run(["amixer", "-q", "sset", "Master", delta]) - - def _detect_running_player(self): - """Detect running player process, if any""" - supported_players = self.supported_players.split(",") - running_players = [] - for pid in Path("/proc").iterdir(): - if not pid.name.isdigit(): - continue - try: - player_name = (pid / "comm").read_bytes().decode().rstrip() - except: # noqa e722 - # (IOError, FileNotFoundError): # (assumed py2, assumed py3) - continue - - if player_name in supported_players: - running_players.append(player_name) - - # Pick which player to use based on the order in self.supported_players - for player_name in supported_players: - if player_name in running_players: - if self.debug: - self.py3.log(f"found player: {player_name}") - - # those players need the dbus module - if player_name == "vlc" and not dbus_available: - self.py3.log(f"{player_name} requires the dbus python module") - return None - - return player_name - - return None - - def _get_vlc(self): - mpris = "org.mpris.MediaPlayer2" - mpris_slash = "/" + mpris.replace(".", "/") - bus = dbus.SessionBus() - proxy = bus.get_object(mpris + ".vlc", mpris_slash) - return dbus.Interface(proxy, dbus_interface=mpris + ".Player") - - def player_control(self): - return dict( - full_text=self.py3.safe_format(self.format, {"icon": self.icon}), - cached_until=self.py3.time_in(self.cache_timeout), - ) - - -if __name__ == "__main__": - """ - Run module in test mode. - """ - from py3status.module_test import module_test - - module_test(Py3status)