From 6ca9b405ce4320a88a0268c6ca4701b4b9ce5e07 Mon Sep 17 00:00:00 2001 From: Tristan Ferrua Date: Sun, 31 Jan 2021 00:10:40 +0000 Subject: [PATCH] Added a configuration option for mpd host and port. --- bin/miniplayer | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/miniplayer b/bin/miniplayer index cd10e8a..d2a3bd9 100755 --- a/bin/miniplayer +++ b/bin/miniplayer @@ -19,18 +19,28 @@ if "player" not in config.sections(): "font_height": 24 } -playerconfig = config["player"] +if "mpd" not in config.sections(): + config["mpd"] = {"host": "localhost", + "port": "6600" + } + +player_config = config["player"] +mpd_config = config["mpd"] # Image ratio # Change this to match the (width, height) of your font. -IMAGERATIO = (playerconfig.getint("font_width", 11), - playerconfig.getint("font_height", 24) +IMAGERATIO = (player_config.getint("font_width", 11), + player_config.getint("font_height", 24) ) # Music directory -MUSICDIR = playerconfig.get("music_directory", "~/Music") +MUSICDIR = player_config.get("music_directory", "~/Music") MUSICDIR = os.path.expanduser(MUSICDIR) +# MPD config +MPDHOST = mpd_config.get("host", "localhost") +MPDPORT = mpd_config.getint("port", 6600) + def albumArtSize(album_space, window_width): """ @@ -67,7 +77,7 @@ class Player: # MPD init self.client = MPDClient() - self.client.connect("localhost", 6600) + self.client.connect(MPDHOST, MPDPORT) self.last_song = None