Skip to content

fix(macos): scope the app-running check and killall to the current user - #73

Open
Explosion5000 wants to merge 1 commit into
verygoodplugins:mainfrom
Explosion5000:fix/per-user-app-check
Open

fix(macos): scope the app-running check and killall to the current user#73
Explosion5000 wants to merge 1 commit into
verygoodplugins:mainfrom
Explosion5000:fix/per-user-app-check

Conversation

@Explosion5000

Copy link
Copy Markdown

Problem

On a Mac with more than one login signed in (fast user switching), each login runs its own copy of the Elgato app against its own ProfilesV3. is_stream_deck_app_running() uses pgrep -x "Stream Deck", which matches every user's instance. So a streamdeck_write_page with auto_quit_app=True from user A fails with "The Elgato Stream Deck app could not be stopped" whenever user B's app is up: the AppleScript quit and killall only reach A's own process, B's keeps running, and the check never clears.

B's instance cannot overwrite A's profiles (different home directory), so it should not count.

Fix

Pass -u <uid> to both pgrep and killall so only the caller's own instance is detected or stopped. os.getuid() is used rather than $USER so it holds under sudo -u and launchd.

Test

Adds a test asserting the pgrep invocation carries -u <current uid>. The real function is bound at import time so the autouse fixture that mocks is_stream_deck_app_running does not short-circuit it. Full suite passes.

Reproduced on macOS 26 with two console logins and a Stream Deck +.

🤖 Generated with Claude Code

https://claude.ai/code/session_016A7CesoQLJuJqDtb4benvw

On a Mac with several logins (fast user switching) each login runs its
own copy of the Stream Deck app against its own ProfilesV3. pgrep -x
matched every user's instance, so a write from user A was refused as
"could not be stopped" whenever user B's app was up, even though B's
instance cannot touch A's profiles and A cannot quit it.

Pass -u <uid> to pgrep and killall so only the caller's own instance
counts as running or gets stopped.
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.

1 participant