Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
addons/game-day: setup from a computer, README and the add-ons table row
Justin Newman9b6537cba9f5
diff --git a/addons/README.md b/addons/README.mdindex ad9825bbc..9059c58a0 100644--- a/addons/README.md+++ b/addons/README.md@@ -35,6 +35,7 @@ the core bigger or change how it behaves. You install an add-on only if you want| [Digital Rain](digital-rain/) | A Matrix-style screensaver: mirrored katakana and digits falling in green trails with bright heads, drawn on the TV with no network; the card starts it at once | [@dennis-oleary](https://github.com/dennis-oleary) | NVIDIA SHIELD Android TV Pro 2019 (Android TV 11) | None | <img src="digital-rain/screenshot.jpg" width="240" alt="Digital Rain on a TV"> || [Bluetooth Toggle](bluetooth-toggle/) | For Android 12 and older (13 and newer do not let apps switch Bluetooth). A one-press Bluetooth switch: the tile turns Bluetooth off or on, a small panel says which, and Pair accessory is one press away | [@justin-newman](https://github.com/justin-newman) | Hisense 75U75N (hengshan), Google TV 12 | Bluetooth (`BLUETOOTH_CONNECT`) | <img src="bluetooth-toggle/screenshot.jpg" width="240" alt="Bluetooth Toggle on a TV"> || [TV Inspector](tv-inspector/) | What the remote sends (key name, key code, scan code, device) and what the TV can play: display modes, HDR, video decoders, audio outputs and formats, input devices; every line also in logcat for a `tv.json` or a bug report | [@shaharukhs](https://github.com/shaharukhs) | Sansui TV (Skyworth eleonas, MediaTek MT9676), Android TV 14 | None | <img src="tv-inspector/screenshot.jpg" width="240" alt="TV Inspector on a TV"> |+| [Game Day](game-day/) | Each team's next game on Home, counted down ("Puck drop in 2h 18m", then "Live now"), from calendar links you add: any team, any sport, no scores; one turn per team, rotating, with the theme's F1 weekend | [@justin-newman](https://github.com/justin-newman) | Not yet tested on a TV | `INTERNET` (your calendar links only) | <img src="game-day/screenshot.jpg" width="240" alt="Game Day on a TV"> |A widget, an info tile, a storage or smart-home card: if it can live as its own small app, it can livehere. See the rules below.diff --git a/addons/game-day/README.md b/addons/game-day/README.mdnew file mode 100644index 000000000..423ef34a5--- /dev/null+++ b/addons/game-day/README.md@@ -0,0 +1,105 @@+# Game Day++Your teams' next games on Home, counted down, from calendars you already have. For the+[Clean Your TV](../../README.md) launcher it declares a [module card](../../docs/modules.md) ("Game Day", where+OK opens its settings) and, with the launcher's `game_day` key, hands Home each team's next game: the panel under+the clock shows "Minnesota Wild at Dallas Stars" and "Puck drop in 2h 18m", then "Live now" while it is on, and+rotates between your teams every 30 seconds. On any other Android TV home it is an ordinary app with its settings.++++- **Any team, any sport, from your own calendars.** Game Day reads calendar subscription links: Stanza, a team's+ own "add to calendar" feed, Google Calendar's "Secret address in iCal format", a fixture site you may use for+ personal use. One link per team. It ships with no schedule source of its own (see below).+- **One turn per team.** Each calendar's next entry within a week takes one turn; a game in two of your calendars+ (following both teams) shows once. Nothing within a week: the panel is hidden.+- **No scores.** There is no live data: "Live now" runs from the calendar's start to its end (or a typical game+ length), and no score, period or inning is ever shown, so nothing is spoiled.+- **The word for the sport.** Each calendar is set to a sport, which sets the word in front of the countdown:++| Sport | Word |+|---|---|+| American football, Rugby, Soccer | Kickoff |+| Australian rules football | First bounce |+| Badminton, Pickleball, Table tennis, Tennis, Volleyball | First serve |+| Baseball, Softball | First pitch |+| Basketball | Tip-off |+| Boxing, MMA | Opening bell |+| Cricket | First ball |+| Curling | First stone |+| Darts | Game on |+| Field hockey | Push-back |+| Gaelic football, Hurling | Throw-in |+| Golf | Tee time |+| Handball | Throw-off |+| Hockey | Puck drop |+| Horse racing | Post time |+| Lacrosse | Face-off |+| Motor racing, flag start (NASCAR, IndyCar, sports cars) | Green flag |+| Motor racing, light start (F1, F2, F3, MotoGP, Formula E) | Lights out |+| Pro wrestling | Bell time |+| Rowing, Sailing | Start gun |+| Cycling, Esports, Other | Starts |++ A calendar entry that is not a game (a draft, a welcome note) shows its own title with "Starts". In racing and+ the other individual sports, practice, qualifying and shootout sessions say "Starts" and the main event gets the+ word.++## Why no schedule source is built in++Free sports data with live scores is not available on terms that allow an app like this: the league sites and+the well-known unofficial feeds forbid automated collection, and the services that allow it need each person to+sign up for a key. Calendars you subscribe to are meant to be fetched by calendar apps, and Game Day is one, for+your own calendars on your own TV. Only you know which calendars you may use; Game Day fetches nothing else.++## Setting it up++With the remote: open Game Day, **Add a calendar**, and type or paste the link, a name, the sport and a colour (36,+in three shades). Long links, like Google's secret address, are tedious to type with a remote, which is why there+is also a script.++From a computer: copy `calendars.example.txt` to `calendars.txt` (git-ignored: the links are secrets), put one+calendar per line as `sport | name | link`, optionally `| colour`, and run++```bash+TV_HOST=<tv ip> addons/game-day/setup.sh # Windows: addons\game-day\setup.ps1 -TvHost <tv ip>+```++It replaces the list on the TV and prints how each calendar loaded. Links are never printed or shown in full: the+settings show `calendar.google.com/…`.++On Home, set the launcher's `game_day` key to `io.github.justinnewman.gameday` in `config.xml` or a theme (see+[`docs/switches.md`](../../docs/switches.md)). With your theme's F1 panel (`race_calendar`) on as well, the F1+weekend joins the rotation as one turn. Use either that or an F1 calendar here, not both, or the weekend shows+twice.++## Build and install++JDK 17 and Android SDK platform 34 with build-tools 34.0.0, as for the launcher:++```bash+cd addons/game-day && ./gradlew assembleRelease+TV_HOST=<tv ip> ../../tools/venv/bin/python -I ../../tools/tv.py --push app/build/outputs/apk/release/app-release.apk /data/local/tmp/addon.apk+TV_HOST=<tv ip> ../../tools/venv/bin/python -I ../../tools/tv.py 'pm install -r /data/local/tmp/addon.apk; rm -f /data/local/tmp/addon.apk'+```++Press Home: the launcher asks once whether to show the card.++## Permissions++| Permission | Why |+|---|---|+| `INTERNET` | Only to fetch the calendar links you add, at most once a day each. Nothing else goes online. |++No account, no telemetry, no ads, no background service: a calendar is fetched only when Home or the settings ask+for the games and its copy is over a day old, and a failed fetch keeps the last good copy. What Home reads (who+plays, when, the colour) is shared through a read-only provider that never holds a link; the setup script's way in+needs `WRITE_SECURE_SETTINGS`, which only the ADB shell has. Nothing is backed up.++## Tested on++Not yet tested on a TV.++## Maintainer++[@justin-newman](https://github.com/justin-newman)diff --git a/addons/game-day/calendars.example.txt b/addons/game-day/calendars.example.txtnew file mode 100644index 000000000..00aca2553--- /dev/null+++ b/addons/game-day/calendars.example.txt@@ -0,0 +1,14 @@+# Copy this file to calendars.txt (it stays on your computer: calendars.txt is git-ignored, because calendar links+# are often secrets) and run setup.sh or setup.ps1.+#+# sport | name | link | colour (optional)+#+# sport: one of the sports in README.md (Hockey, Basketball, Baseball, Soccer, American football, Motor racing,+# light start, ...); it sets the word in front of the countdown ("Puck drop in 2h 18m").+# name: only for Game Day's list, up to 40 characters.+# link: the calendar's subscription link: https://, http:// or webcal://.+# colour: one of the 36, such as "Green, dark" or "Amber, light"; left out, Game Day picks an unused one.++Hockey | Minnesota Wild | https://example.com/…/minnesota-wild.ics+Soccer | Utah Royals | webcal://example.com/…/utah-royals.ics | Amber, medium+Basketball | Utah Jazz | https://example.com/…/utah-jazz.icsdiff --git a/addons/game-day/setup.ps1 b/addons/game-day/setup.ps1new file mode 100644index 000000000..5b26e2149--- /dev/null+++ b/addons/game-day/setup.ps1@@ -0,0 +1,53 @@+# Windows version of setup.sh: send Game Day its calendars from a computer, instead of typing long links with the+# remote. One calendar per line in calendars.txt beside this script (or the file you name): "sport | name | link",+# optionally "| colour". It replaces the list on the TV, waits while the TV fetches each calendar, and prints how+# each one loaded. Links are never printed. Install the add-on first (README.md).+#+# Usage: addons\game-day\setup.ps1 -TvHost 192.168.1.50 # calendars.txt from this folder+# addons\game-day\setup.ps1 -TvHost 192.168.1.50 D:\my-teams.txt # any calendars file+param(+ [Parameter(Position = 0)][string]$Calendars,+ [string]$TvHost = $env:TV_HOST+)+$ErrorActionPreference = 'Stop'+if (-not $TvHost) { throw 'pass -TvHost <tv ip> or set $env:TV_HOST' }+$env:TV_HOST = $TvHost+if (-not $Calendars) { $Calendars = Join-Path $PSScriptRoot 'calendars.txt' }+if (-not (Test-Path $Calendars -PathType Leaf)) { throw "no calendars file $Calendars (copy calendars.example.txt to calendars.txt and edit it)" }+$Calendars = (Resolve-Path $Calendars).Path+Set-Location (Join-Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) 'tools')+$py = 'venv\Scripts\python.exe'+if (-not (Test-Path $py)) { throw 'run: python -m venv tools\venv; tools\venv\Scripts\python.exe -m pip install -r tools\requirements.txt' }+$pkg = 'io.github.justinnewman.gameday'+$uri = "content://$pkg.files"+$tmp = '/data/local/tmp/gameday-calendars.txt'+function Tv([string]$cmd) { & $py -I tv.py $cmd; if ($LASTEXITCODE) { throw "tv.py failed: $cmd" } }++if (-not ((Tv "pm path $pkg; true") -match 'package:')) { throw 'Game Day is not on the TV: build and install it first (README.md)' }+Write-Host 'Game Day is installed.'+& $py -I b64push.py $Calendars $tmp | Out-Null+if ($LASTEXITCODE) { throw 'sending the calendars failed' }+Tv "content write --uri $uri/calendars.txt < $tmp; rm -f $tmp" | Out-Null++Write-Host 'Checking the calendars on the TV:'+$lines = @()+for ($i = 0; $i -lt 45; $i++) {+ Start-Sleep -Seconds 2+ $lines = @((Tv "content read --uri $uri/result.txt 2>/dev/null; true") -split "`r?`n" | Where-Object { $_ -ne '' })+ if ($lines.Count -gt 0 -and $lines[-1] -eq 'done') { break }+}+if ($lines.Count -eq 0 -or $lines[-1] -ne 'done') { throw 'the TV did not finish in 90 seconds: open Game Day on the TV to see each calendar' }++$failed = $false+$sent = 0+$bad = $false+foreach ($line in $lines) {+ $f = $line -split '\|', 5+ switch ($f[0]) {+ 'ok' { Write-Host (' {0,-22} {1,-14} ' -f $f[1], $f[2]) -NoNewline; Write-Host 'ok' -ForegroundColor Green -NoNewline; Write-Host " $($f[3]) $(if ($f[3] -eq '1') { 'entry' } else { 'entries' }), next $($f[4])"; $sent++ }+ 'fail' { Write-Host (' {0,-22} {1,-14} ' -f $f[1], $f[2]) -NoNewline; Write-Host $f[3] -ForegroundColor Red; $sent++; $failed = $true }+ 'error' { Write-Host (' ' + ($line -replace '^error\|[^|]*\|', '')) -ForegroundColor Red; $failed = $true; $bad = $true }+ }+}+if ($bad) { Write-Host 'Nothing changed on the TV.' } else { Write-Host "Sent $sent calendars to the TV. Links are not printed." }+if ($failed) { exit 1 }diff --git a/addons/game-day/setup.sh b/addons/game-day/setup.shnew file mode 100644index 000000000..8a9083f24--- /dev/null+++ b/addons/game-day/setup.sh@@ -0,0 +1,61 @@+#!/usr/bin/env bash+# Send Game Day its calendars from a computer, instead of typing long links with the remote. One calendar per line+# in calendars.txt beside this script (or the file you name): "sport | name | link", optionally "| colour". It+# replaces the list on the TV, waits while the TV fetches each calendar, and prints how each one loaded. Links are+# never printed. Install the add-on first (README.md).+#+# Usage: TV_HOST=192.168.1.50 addons/game-day/setup.sh # calendars.txt from this folder+# TV_HOST=192.168.1.50 addons/game-day/setup.sh ~/my-teams.txt # any calendars file+set -euo pipefail+HERE="$(cd "$(dirname "$0")" && (pwd -W 2>/dev/null || pwd))"+ARG="${1:-}"+case "$ARG" in+ "") FILE="$HERE/calendars.txt" ;;+ /*|?:*) FILE="$ARG" ;;+ *) FILE="$(pwd -W 2>/dev/null || pwd)/$ARG" ;;+esac+[ -f "$FILE" ] || { echo "no calendars file $FILE (copy calendars.example.txt to calendars.txt and edit it)" >&2; exit 1; }+cd "$(dirname "$0")/../../tools"+: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.1.50 $0}"+PY=venv/bin/python+[ -x "$PY" ] || PY=venv/Scripts/python.exe+[ -x "$PY" ] || { echo "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt" >&2; exit 1; }+export MSYS_NO_PATHCONV=1+PKG=io.github.justinnewman.gameday+URI=content://$PKG.files+TMP=/data/local/tmp/gameday-calendars.txt+tv() { "$PY" -I tv.py "$@"; }++tv "pm path $PKG; true" | grep -q package: || { echo "Game Day is not on the TV: build and install it first (README.md)" >&2; exit 1; }+echo "Game Day is installed."+# Git Bash: the venv's Windows Python needs a Windows path for the file.+"$PY" -I b64push.py "$(cygpath -w "$FILE" 2>/dev/null || printf '%s' "$FILE")" "$TMP" | grep -q md5 \+ || { echo "sending the calendars failed" >&2; exit 1; }+tv "content write --uri $URI/calendars.txt < $TMP; rm -f $TMP" >/dev/null++echo "Checking the calendars on the TV:"+RESULT=+for _ in $(seq 1 45); do+ sleep 2+ RESULT="$(tv "content read --uri $URI/result.txt 2>/dev/null; true" | tr -d '\r')"+ [ "${RESULT##*$'\n'}" = done ] && break+done+[ "${RESULT##*$'\n'}" = done ] || { echo "the TV did not finish in 90 seconds: open Game Day on the TV to see each calendar" >&2; exit 1; }++STATUS=0+N=0+while IFS= read -r LINE; do+ IFS='|' read -r KIND A B C D <<< "$LINE"+ case "$KIND" in+ ok) E=entries; [ "$C" = 1 ] && E=entry+ printf ' %-22s %-14s \033[32mok\033[0m %s %s, next %s\n' "$A" "$B" "$C" "$E" "$D"; N=$((N + 1)) ;;+ fail) printf ' %-22s %-14s \033[31m%s\033[0m\n' "$A" "$B" "$C"; N=$((N + 1)); STATUS=1 ;;+ error) printf ' \033[31m%s\033[0m\n' "${LINE#error|*|}"; STATUS=1 ;;+ esac+done <<< "$RESULT"+if grep -q '^error|' <<< "$RESULT"; then+ echo "Nothing changed on the TV."+else+ echo "Sent $N calendars to the TV. Links are not printed."+fi+exit "$STATUS"