Reintroduce lsb vars

merge-requests/64/head
Hugo Posnic 2017-06-16 16:30:08 +02:00
parent 4501cb288b
commit ddd55b9335
2 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,4 @@
{ {
"system": "Manjaro Gellivara 17",
"default_locale": "en", "default_locale": "en",
"autostart_path": "~/.config/autostart/manjaro-hello.desktop", "autostart_path": "~/.config/autostart/manjaro-hello.desktop",
"data_path": "/usr/share/manjaro-hello/data/", "data_path": "/usr/share/manjaro-hello/data/",

View File

@ -40,7 +40,7 @@ class Hello():
self.window = self.builder.get_object("window") self.window = self.builder.get_object("window")
# Subtitle of headerbar # 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 # Load images
if os.path.isfile(self.preferences["logo_path"]): if os.path.isfile(self.preferences["logo_path"]):
@ -289,6 +289,26 @@ def write_json(path, content):
except OSError as error: except OSError as error:
print(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__": if __name__ == "__main__":
Hello() Hello()