
Defining default apps as serialized GVariants isn't very human-friendly, which likely contributes to the fact that the lists are in parts horribly outdated (Books! Cheese! Screenshot! gedit!). Instead, generate the lists at build time from simple text files, which should be much easier to update. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3632>
41 lines
927 B
Python
Executable File
41 lines
927 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
|
|
def read_app_ids(path) -> str:
|
|
ids = []
|
|
with open(path, "r") as file:
|
|
for line in file:
|
|
# strip comments
|
|
line, _, _ = line.partition('#');
|
|
line = line.strip()
|
|
if len(line) > 0:
|
|
ids.append(line)
|
|
return ids
|
|
|
|
def print_as_array(ids):
|
|
mapped_ids = list(map(lambda i: f" '{i}'", ids))
|
|
print('[')
|
|
print(',\n'.join(mapped_ids))
|
|
print(']')
|
|
|
|
def print_as_pages(ids):
|
|
mapped_ids = []
|
|
for i, id in enumerate(ids):
|
|
mapped_ids.append(f" '{id}': <{{'position': <{i}>}}>")
|
|
|
|
print('[{')
|
|
print(',\n'.join(mapped_ids))
|
|
print('}]')
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--pages', action='store_true')
|
|
parser.add_argument('file')
|
|
args = parser.parse_args()
|
|
|
|
ids = read_app_ids(args.file)
|
|
if args.pages:
|
|
print_as_pages(ids)
|
|
else:
|
|
print_as_array(ids)
|