Skip to content

i2samp: add uninstall menu option - #397

Merged
makermelissa merged 2 commits into
adafruit:mainfrom
makermelissa-ai-assistant:i2samp-uninstall
Jun 16, 2026
Merged

i2samp: add uninstall menu option#397
makermelissa merged 2 commits into
adafruit:mainfrom
makermelissa-ai-assistant:i2samp-uninstall

Conversation

@makermelissa-ai-assistant

Copy link
Copy Markdown
Contributor

Resolves #299 — adds an uninstaller for the MAX98357 I2S amplifier driver.

i2samp.py now opens with an Install / Uninstall / Quit menu. The new uninstall path reverses everything the installer does, returning the system to its prior state:

  • Stops, disables, and removes the aplay systemd unit (daemon-reload)
  • Removes the dtoverlay=googlevoicehat-soundcard line from boot config
  • Re-enables built-in audio (un-comments dtparam=audio=on)
  • Restores any MAX98357 blacklist entries the installer commented out
  • Restores /etc/asound.conf from .old, or removes it if the installer created it from scratch

The 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:

Piece Install Uninstall OK
dtoverlay=googlevoicehat-soundcard added removed
dtparam=audio=on commented re-enabled
/etc/asound.conf created removed/restored
aplay.service installed + enabled stopped + disabled + removed
MAX98357 blacklist un-commented re-commented

Post-uninstall config.txt matches baseline (aside from one cosmetic blank line where the overlay was removed, consistent with the existing rtc.py uninstaller behavior).

Closes #299

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, restores dtparam=audio=on, restores /etc/asound.conf, and removes the aplay systemd unit.
  • Updated entrypoint UX to a top-level Install / Uninstall / Quit menu and moved common preflight checks (clear, Raspberry Pi detection) into main().
  • Added blacklist restoration steps during uninstall.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread i2samp.py Outdated
Comment on lines +69 to +70
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")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@makermelissa makermelissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@makermelissa
makermelissa merged commit 50cbc33 into adafruit:main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAX98357 Driver Uninstaller

3 participants