data: Generate dash/app-grid defaults from text files
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>
This commit is contained in:

committed by
Marge Bot

parent
33354c718f
commit
38c6293f4f
40
meson/generate-app-list.py
Executable file
40
meson/generate-app-list.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/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)
|
Reference in New Issue
Block a user