Reintroduce lsb vars
This commit is contained in:
parent
4501cb288b
commit
ddd55b9335
@ -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/",
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user