Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Dec 29, 2024
0 parents commit 278ab50
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
49 changes: 49 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 278ab50

Please sign in to comment.