From 278ab5034b76fcd9c3e1a3f06df5a2bcba263315 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 29 Dec 2024 02:35:51 -0500 Subject: [PATCH] Initial commit --- LICENSE | 21 +++++++++++++++++++++ README.md | 10 ++++++++++ launch.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 launch.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..df4fac6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Jose Diaz-Gonzalez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f6b597 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# trimui-brick-fn-editor.pak + +A TrimUI Brick app wrapping the built-in Function Key Editor app. + +## Installation + +1. Mount your TrimUI Brick SD card. +2. Create a folder in your SD card with the full-path of `/Tools/tg3040/FN Editor.pak`. +3. Copy `launch.sh` to that folder, ensuring it is still executable. +4. Unmount your SD Card and insert it into your TrimUI Brick. diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..da651f9 --- /dev/null +++ b/launch.sh @@ -0,0 +1,49 @@ +#!/bin/sh +echo "$0" "$@" +progdir="$(dirname "$0")" +cd "$progdir" || exit 1 +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$progdir" +echo 1 >/tmp/stay_awake +trap "rm -f /tmp/stay_awake" EXIT INT TERM HUP QUIT + +wifi_off() { + echo "Preparping to toggle wifi off..." + + if pgrep wpa_supplicant; then + echo "Stopping wpa_supplicant..." + killall -9 wpa_supplicant || true + fi + + status="$(cat /sys/class/net/wlan0/carrier)" + if [ "$status" = 1 ]; then + echo "Marking wlan0 interface down..." + ifconfig wlan0 down || true + fi + + if [ ! -f /sys/class/rfkill/rfkill0/state ]; then + echo "Blocking wireless..." + echo 0 >/sys/class/rfkill/rfkill0/state || true + fi +} + +wifi_on() { + echo "Preparing to toggle wifi on..." + + echo "Unblocking wireless..." + echo 1 >/sys/class/rfkill/rfkill0/state || true + + echo "Starting wpa_supplicant..." + wpa_supplicant -B -D nl80211 -iwlan0 -c /etc/wifi/wpa_supplicant.conf -O /etc/wifi/sockets || true + ( (udhcpc -i wlan0 &) &) +} + +if pgrep wpa_supplicant; then + wifi_off +else + wifi_on +fi + +echo "Done toggling wifi!" +echo "" +echo "Sleeping for 2 seconds." +sleep 2