From 2b113f73581d8c7eafb5a757d477045f3c2778ff Mon Sep 17 00:00:00 2001 From: Bart Kleijngeld Date: Thu, 9 Sep 2021 14:01:50 +0200 Subject: [PATCH] Added backwards compatibility with older configs --- bin/miniplayer | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/miniplayer b/bin/miniplayer index d55ef09..1d7e496 100755 --- a/bin/miniplayer +++ b/bin/miniplayer @@ -11,6 +11,7 @@ import configparser import ueberzug.lib.v0 as ueberzug from PIL import Image, ImageDraw + # Get config config = configparser.ConfigParser() config.read(os.path.expanduser("~/.config/miniplayer/config")) @@ -51,6 +52,23 @@ default_bindings = {">": "next_track", if "keybindings" not in config.sections(): config["keybindings"] = default_bindings +# Ensure compatibility with older configs +deprecated_field_notice = ("The config option `{field}` under the `player` " + "section is deprecated and will be removed in the " + "future. Use the config option `{field}` under the " + "`art` section instead.") +deprecated_fields_present = False +for field in ["music_directory", "image_method"]: + if config.has_option("player", field): + deprecated_fields_present = True + print(deprecated_field_notice.format(field=field)) + + if not config.has_option("art", field): + config["art"][field] = config["player"][field] + +if deprecated_fields_present: + input("(Press to continue) ...") + # Load configured keybindings keybindings = config["keybindings"]