]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/config/__init__.py
lxc: Mount /dev/shm which might host XDG_RUNTIME_DIR
[waydroid.git] / tools / config / __init__.py
1 # Copyright 2021 Oliver Smith
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 import os
4 import pwd
5
6 #
7 # Exported functions
8 #
9 from tools.config.load import load, load_session, load_channels
10 from tools.config.save import save, save_session
11
12 #
13 # Exported variables (internal configuration)
14 #
15 version = "1.3.3"
16 tools_src = os.path.normpath(os.path.realpath(__file__) + "/../../..")
17
18 # Keys saved in the config file (mostly what we ask in 'waydroid init')
19 config_keys = ["arch",
20 "images_path",
21 "vendor_type",
22 "system_datetime",
23 "vendor_datetime",
24 "suspend_action"]
25
26 session_config_keys = ["user_name",
27 "user_id",
28 "group_id",
29 "host_user",
30 "xdg_data_home",
31 "waydroid_data",
32 "xdg_runtime_dir",
33 "wayland_display",
34 "pulse_runtime_path",
35 "state",
36 "lcd_density"]
37
38 # Config file/commandline default values
39 # $WORK gets replaced with the actual value for args.work (which may be
40 # overridden on the commandline)
41 defaults = {
42 "arch": "arm64",
43 "work": "/var/lib/waydroid",
44 "vendor_type": "MAINLINE",
45 "system_datetime": "0",
46 "vendor_datetime": "0",
47 "preinstalled_images_paths": [
48 "/etc/waydroid-extra/images",
49 "/usr/share/waydroid-extra/images",
50 ],
51 "suspend_action": "freeze"
52 }
53 defaults["images_path"] = defaults["work"] + "/images"
54 defaults["rootfs"] = defaults["work"] + "/rootfs"
55 defaults["data"] = defaults["work"] + "/data"
56 defaults["lxc"] = defaults["work"] + "/lxc"
57 defaults["host_perms"] = defaults["work"] + "/host-permissions"
58
59 session_defaults = {
60 "user_name": pwd.getpwuid(os.getuid()).pw_name,
61 "user_id": str(os.getuid()),
62 "group_id": str(os.getgid()),
63 "host_user": os.path.expanduser("~"),
64 "xdg_data_home": str(os.environ.get('XDG_DATA_HOME', os.path.expanduser("~") + "/.local/share")),
65 "xdg_runtime_dir": str(os.environ.get('XDG_RUNTIME_DIR')),
66 "wayland_display": str(os.environ.get('WAYLAND_DISPLAY')),
67 "pulse_runtime_path": str(os.environ.get('PULSE_RUNTIME_PATH')),
68 "state": "STOPPED",
69 "lcd_density": "0"
70 }
71 session_defaults["config_path"] = defaults["work"] + "/session.cfg"
72 session_defaults["waydroid_data"] = session_defaults["xdg_data_home"] + \
73 "/waydroid/data"
74 if session_defaults["pulse_runtime_path"] == "None":
75 session_defaults["pulse_runtime_path"] = session_defaults["xdg_runtime_dir"] + "/pulse"
76
77 channels_defaults = {
78 "config_path": "/usr/share/waydroid-extra/channels.cfg",
79 "system_channel": "https://ota.waydro.id/system",
80 "vendor_channel": "https://ota.waydro.id/vendor",
81 "rom_type": "lineage",
82 "system_type": "VANILLA"
83 }
84 channels_config_keys = ["system_channel",
85 "vendor_channel",
86 "rom_type",
87 "system_type"]