-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathrun_desktop.sh
More file actions
executable file
·83 lines (69 loc) · 2.37 KB
/
run_desktop.sh
File metadata and controls
executable file
·83 lines (69 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
scriptdir=$(cd "$(dirname "$0")" && pwd -P)
script="$1"
if [ -f "$script" ]; then
script="$(cd "$(dirname "$script")" && pwd -P)/$(basename "$script")"
fi
echo "Usage:"
echo "$0 # with no arguments just starts it up normally"
echo "$0 scriptfile.py # doesn't initialize anything, just runs scriptfile.py directly"
echo "$0 appname # starts the app by appname, for example: com.example.helloworld"
#export SDL_WINDOW_FULLSCREEN=true
#export HEAPSIZE=8M # default, same a PSRAM on many ESP32-S3 boards
export HEAPSIZE=16M # on desktop, a bit more is warranted (different C library etc)
#export HEAPSIZE=64M # fine for fullscreen 1280x720 slides
os_name=$(uname -s)
if [ "$os_name" = "Darwin" ]; then
echo "Running on macOS"
binary="$scriptdir"/../lvgl_micropython/build/lvgl_micropy_macOS
else
echo "Running on $os_name"
binary="$scriptdir"/../lvgl_micropython/build/lvgl_micropy_unix
fi
binary="$(cd "$(dirname "$binary")" && pwd -P)/$(basename "$binary")"
chmod +x "$binary"
pushd "$scriptdir"/../internal_filesystem/
if [ -f "$script" ]; then
echo "Running script $script"
"$binary" -v -i "$script"
else
CONFIG_FILE="data/com.micropythonos.settings/config.json"
set_autostart_config() {
local mode="$1"
local early_value="$2"
mkdir -p "$(dirname "$CONFIG_FILE")"
python3 - "$CONFIG_FILE" "$mode" "$early_value" <<'PY'
import json
import os
import sys
path = sys.argv[1]
mode = sys.argv[2]
early_value = sys.argv[3]
config = {}
if os.path.exists(path):
try:
with open(path, "r", encoding="utf-8") as f:
loaded = json.load(f)
if isinstance(loaded, dict):
config = loaded
except Exception:
config = {}
if mode == "set":
config["auto_start_app_early"] = early_value
elif mode == "clear":
config.pop("auto_start_app_early", None)
config.pop("auto_start_app", None)
with open(path, "w", encoding="utf-8") as f:
json.dump(config, f, separators=(",", ":"))
PY
}
if [ -n "$script" ]; then
echo "run_desktop.sh: running app $script"
set_autostart_config "set" "$script"
else
echo "Clearing auto_start_app_early and auto_start_app in config file"
set_autostart_config "clear" ""
fi
"$binary" -X heapsize=$HEAPSIZE -v -i -m main # internal_filesystem/main.py is frozen in and can't be changed at runtime
fi
popd