diff --git a/data/preferences.json b/data/preferences.json index 47cb70f..6eb6743 100644 --- a/data/preferences.json +++ b/data/preferences.json @@ -1,5 +1,4 @@ { - "system": "Manjaro Gellivara 17", "default_locale": "en", "autostart_path": "~/.config/autostart/manjaro-hello.desktop", "data_path": "/usr/share/manjaro-hello/data/", diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py index f3c0a13..0a5b2ea 100644 --- a/src/manjaro_hello.py +++ b/src/manjaro_hello.py @@ -40,7 +40,7 @@ class Hello(): self.window = self.builder.get_object("window") # Subtitle of headerbar - self.builder.get_object("headerbar").props.subtitle = self.preferences["system"] + self.builder.get_object("headerbar").props.subtitle = ' '.join(get_lsb_infos()) # Load images if os.path.isfile(self.preferences["logo_path"]): @@ -289,6 +289,26 @@ def write_json(path, content): except OSError as error: print(error) +def get_lsb_infos(): + """Read informations from the lsb-release file. + :return: args from lsb-release file + :rtype: dict""" + lsb = {} + try: + with open("/etc/lsb-release") as f: + for line in f: + if "=" in line: + var, arg = line.rstrip().split("=") + if var.startswith("DISTRIB_"): + var = var[8:] + if arg.startswith("\"") and arg.endswith("\""): + arg = arg[1:-1] + if arg: + lsb[var] = arg + except OSError as error: + print(error) + return lsb["CODENAME"], lsb["RELEASE"] + if __name__ == "__main__": Hello()