i2samp: add uninstall menu option - #397
Conversation
Adds an Install/Uninstall/Quit menu to i2samp.py. The new uninstall path reverses everything the installer does: stops and removes the aplay systemd unit, removes the googlevoicehat-soundcard overlay, re-enables built-in audio, restores any commented-out MAX98357 blacklist entries, and restores or removes /etc/asound.conf. Closes adafruit#299
There was a problem hiding this comment.
Pull request overview
Adds an uninstall workflow to i2samp.py so users can cleanly remove the MAX98357 I2S amplifier driver configuration and return the system to its prior audio setup (install/uninstall/quit menu, idempotent cleanup, boot config restore).
Changes:
- Added an
uninstall()path that removes the overlay entry, restoresdtparam=audio=on, restores/etc/asound.conf, and removes theaplaysystemd unit. - Updated entrypoint UX to a top-level Install / Uninstall / Quit menu and moved common preflight checks (
clear, Raspberry Pi detection) intomain(). - Added blacklist restoration steps during uninstall.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| shell.pattern_replace(BLACKLIST, "^#blacklist[[:space:]]*snd_soc_max98357a_i2c.*", "blacklist snd_soc_max98357a_i2c") | ||
| shell.pattern_replace(BLACKLIST, "^#blacklist[[:space:]]*snd_soc_max98357a.*", "blacklist snd_soc_max98357a") |
There was a problem hiding this comment.
Good catch. Tightened the uninstall blacklist-restore patterns to match only the exact normalized forms the installer produces (^#blacklist snd_soc_max98357a$ and ^#blacklist snd_soc_max98357a_i2c$), dropping the broad .* so uninstall no longer un-comments user-managed lines that were already commented out before install. Fixed in f1846ac.
Only un-comment the exact normalized forms the installer produces (#blacklist snd_soc_max98357a[_i2c]) instead of broad .* patterns, so uninstall never touches lines the user commented out themselves before install. Keeps the uninstall truly reversible. Addresses Copilot review feedback.
Resolves #299 — adds an uninstaller for the MAX98357 I2S amplifier driver.
i2samp.pynow opens with an Install / Uninstall / Quit menu. The new uninstall path reverses everything the installer does, returning the system to its prior state:aplaysystemd unit (daemon-reload)dtoverlay=googlevoicehat-soundcardline from boot configdtparam=audio=on)blacklistentries the installer commented out/etc/asound.conffrom.old, or removes it if the installer created it from scratchThe uninstall is idempotent and non-destructive — it only un-comments blacklist lines that exist and only removes config it owns.
Hardware tested
Verified on a Pi 5 (Debian Trixie) with a full install → uninstall cycle, diffed against a captured baseline of
config.txt:dtoverlay=googlevoicehat-soundcarddtparam=audio=on/etc/asound.confaplay.servicePost-uninstall
config.txtmatches baseline (aside from one cosmetic blank line where the overlay was removed, consistent with the existingrtc.pyuninstaller behavior).Closes #299