diff --git a/.gitarchiveinclude b/.gitarchiveinclude index f5e74dd..a4b86e8 100644 --- a/.gitarchiveinclude +++ b/.gitarchiveinclude @@ -1,6 +1,8 @@ bin/jq-arm bin/jq-arm64 bin/minui-keyboard-tg5040 +bin/minui-keyboard-rg35xxplus bin/minui-list-tg5040 +bin/minui-list-rg35xxplus bin/sdl2imgshow res/fonts/BPreplayBold.otf diff --git a/Makefile b/Makefile index 1d4724a..e17d3d1 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,35 @@ TAG ?= latest PAK_NAME := $(shell jq -r .label config.json) +PLATFORMS := tg5040 rg35xxplus +MINUI_LIST_VERSION := 0.3.0 +MINUI_KEYBOARD_VERSION := 0.2.0 + + clean: rm -f bin/jq-arm || true rm -f bin/jq-arm64 || true rm -f bin/sdl2imgshow || true - rm -f bin/minui-keyboard-tg5040 || true - rm -f bin/minui-list-tg5040 || true + rm -f bin/minui-keyboard-* || true + rm -f bin/minui-list-* || true rm -f res/fonts/BPreplayBold.otf || true -build: bin/jq-arm bin/jq-arm64 bin/minui-keyboard-tg5040 bin/minui-list-tg5040 bin/sdl2imgshow res/fonts/BPreplayBold.otf +build: $(foreach platform,$(PLATFORMS),bin/minui-keyboard-$(platform) bin/minui-list-$(platform)) bin/jq-arm bin/jq-arm64 bin/sdl2imgshow res/fonts/BPreplayBold.otf bin/jq-arm: - curl -o bin/jq-arm -sSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-armhf + curl -f -o bin/jq-arm -sSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-armhf bin/jq-arm64: - curl -o bin/jq-arm64 -sSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64 + curl -f -o bin/jq-arm64 -sSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64 -bin/minui-keyboard-tg5040: - curl -o bin/minui-keyboard-tg5040 -sSL https://github.com/josegonzalez/minui-keyboard/releases/download/0.1.0/minui-keyboard-tg5040 - chmod +x bin/minui-keyboard-tg5040 +# dynamically create the minui-keyboard target for all platforms +bin/minui-keyboard-%: + curl -f -o bin/minui-keyboard-$* -sSL https://github.com/josegonzalez/minui-keyboard/releases/download/$(MINUI_KEYBOARD_VERSION)/minui-keyboard-$* + chmod +x bin/minui-keyboard-$* -bin/minui-list-tg5040: - curl -o bin/minui-list-tg5040 -sSL https://github.com/josegonzalez/minui-list/releases/download/0.2.0/minui-list-tg5040 - chmod +x bin/minui-list-tg5040 +bin/minui-list-%: + curl -f -o bin/minui-list-$* -sSL https://github.com/josegonzalez/minui-list/releases/download/$(MINUI_LIST_VERSION)/minui-list-$* + chmod +x bin/minui-list-$* bin/sdl2imgshow: docker buildx build --platform linux/arm64 --load -f Dockerfile.sdl2imgshow --progress plain -t app/sdl2imgshow:$(TAG) . @@ -40,4 +46,4 @@ release: build res/fonts/BPreplayBold.otf: mkdir -p res/fonts - curl -sSL -o res/fonts/BPreplayBold.otf "https://raw.githubusercontent.com/shauninman/MinUI/refs/heads/main/skeleton/SYSTEM/res/BPreplayBold-unhinted.otf" + curl -f -sSL -o res/fonts/BPreplayBold.otf "https://raw.githubusercontent.com/shauninman/MinUI/refs/heads/main/skeleton/SYSTEM/res/BPreplayBold-unhinted.otf" diff --git a/launch.sh b/launch.sh index 23f2586..0e79dce 100755 --- a/launch.sh +++ b/launch.sh @@ -12,29 +12,46 @@ if uname -m | grep -q '64'; then fi main_screen() { + minui_list_file="/tmp/minui-list" + rm -f "$minui_list_file" + touch "$minui_list_file" enabled="$(cat /sys/class/net/wlan0/operstate)" configuration="Connected: false\nConnect?" ip_address="N/A" + + echo "Connected: false" >>"$minui_list_file" + echo "Connect?" >>"$minui_list_file" if [ "$enabled" = "up" ]; then ssid="$(iw dev wlan0 link | grep SSID: | cut -d':' -f2- | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')" ip_address="$(ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)" - configuration="Connected: true\nSSID: $ssid\nIP: $ip_address\nDisconnect?\nConnect to new network?" + rm -f "$minui_list_file" + touch "$minui_list_file" + echo "Connected: true" >>"$minui_list_file" + echo "SSID: $ssid" >>"$minui_list_file" + echo "IP: $ip_address" >>"$minui_list_file" + echo "Disconnect?" >>"$minui_list_file" + echo "Connect to new network?" >>"$minui_list_file" fi - echo -e "$configuration" | "$progdir/bin/minui-list-$PLATFORM" --file - --format text --header "Wifi Configuration" + "$progdir/bin/minui-list-$PLATFORM" --file "$minui_list_file" --format text --header "Wifi Configuration" } networks_screen() { show_message "Scanning for networks..." 2 DELAY=30 + + minui_list_file="/tmp/minui-list" + rm -f "$minui_list_file" + touch "$minui_list_file" for i in $(seq 1 "$DELAY"); do - networks="$(iw dev wlan0 scan | grep SSID: | cut -d':' -f2- | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | sort)" - if [ -n "$networks" ]; then + iw dev wlan0 scan | grep SSID: | cut -d':' -f2- | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | sort >>"$minui_list_file" + if [ -s "$minui_list_file" ]; then break fi sleep 1 done - echo -e "$networks" | "$progdir/bin/minui-list-$PLATFORM" --file - --format text --header "Wifi Networks" + + "$progdir/bin/minui-list-$PLATFORM" --file "$minui_list_file" --format text --header "Wifi Networks" } password_screen() { @@ -143,27 +160,43 @@ write_config() { } wifi_enable() { - SYSTEM_JSON_PATH="/mnt/UDISK/system.json" - chmod +x "$JQ" - "$JQ" '.wifi = 1' "$SYSTEM_JSON_PATH" >"/tmp/system.json.tmp" - mv "/tmp/system.json.tmp" "$SYSTEM_JSON_PATH" + echo "Preparing to enable wifi..." + if [ "$PLATFORM" = "tg5040" ]; then + SYSTEM_JSON_PATH="/mnt/UDISK/system.json" + chmod +x "$JQ" + "$JQ" '.wifi = 1' "$SYSTEM_JSON_PATH" >"/tmp/system.json.tmp" + mv "/tmp/system.json.tmp" "$SYSTEM_JSON_PATH" + fi echo "Unblocking wireless..." rfkill unblock wifi || true echo "Starting wpa_supplicant..." - /etc/init.d/wpa_supplicant stop || true - /etc/init.d/wpa_supplicant start || true - ( (udhcpc -i wlan0 -q &) &) + if [ "$PLATFORM" = "tg5040" ]; then + /etc/init.d/wpa_supplicant stop || true + /etc/init.d/wpa_supplicant start || true + ( (udhcpc -i wlan0 -q &) &) + elif [ "$PLATFORM" = "rg35xxplus" ]; then + ip link set wlan0 up + iw dev wlan0 set power_save off + + systemctl start wpa_supplicant + systemctl start udhcpd + else + show_message "Error: $PLATFORM is not a supported platform" 1>&2 + exit 1 + fi } wifi_off() { - SYSTEM_JSON_PATH="/mnt/UDISK/system.json" echo "Preparing to toggle wifi off..." + if [ "$PLATFORM" = "tg5040" ]; then + SYSTEM_JSON_PATH="/mnt/UDISK/system.json" - chmod +x "$JQ" - "$JQ" '.wifi = 0' "$SYSTEM_JSON_PATH" >"/tmp/system.json.tmp" - mv "/tmp/system.json.tmp" "$SYSTEM_JSON_PATH" + chmod +x "$JQ" + "$JQ" '.wifi = 0' "$SYSTEM_JSON_PATH" >"/tmp/system.json.tmp" + mv "/tmp/system.json.tmp" "$SYSTEM_JSON_PATH" + fi if pgrep wpa_supplicant; then echo "Stopping wpa_supplicant..." @@ -271,6 +304,29 @@ main() { export DEVICE="brick" fi + if [ ! -f "$progdir/bin/minui-keyboard-$PLATFORM" ]; then + show_message "$progdir/bin/minui-keyboard-$PLATFORM not found" 1>&2 + exit 1 + fi + if [ ! -f "$progdir/bin/minui-list-$PLATFORM" ]; then + show_message "$progdir/bin/minui-list-$PLATFORM not found" 1>&2 + exit 1 + fi + + allowed_platforms="tg5040 rg35xxplus" + if ! echo "$allowed_platforms" | grep -q "$PLATFORM"; then + show_message "$PLATFORM is not a supported platform" 1>&2 + exit 1 + fi + + if [ "$PLATFORM" = "rg35xxplus" ]; then + RGXX_MODEL="$(strings /mnt/vendor/bin/dmenu.bin | grep ^RG)" + if [ "$RGXX_MODEL" = "RG28xx" ]; then + show_message "Wifi not supported on RG28XX" 1>&2 + exit 1 + fi + fi + while true; do selection="$(main_screen)" exit_code=$?