Skip to content

Start at login silently breaks when macOS loses the registration; the app never re-registers (and #445's migration call was accidentally removed) #1328

Closed

Description

@public-daniel

OS

macOS 26.2 (25C56)

LinearMouse

0.11.3

Describe the bug

LinearMouse stopped launching at login on my machine (it had been working before). Rather than just re-toggle the setting, I dug into why — and I think the findings explain the recurring "start at login stopped working" reports (#441, #902) that previously went stale without a root cause.

Machine evidence: macOS's background-item database had no record of LinearMouse at all — sfltool dumpbtm returns zero matches for com.lujjjh.LinearMouse (no SMAppService.mainApp record, no legacy helper record, for any user), while other apps' login-item records are present. The app itself runs fine when launched manually, is installed in /Applications, and is not quarantined.

Reading the source, two things stand out:

1. "Start at login" state is a live mirror of SMAppService.mainApp.status, so a lost registration is silent and permanent.

LinearMouse uses the now-archived sindresorhus/LaunchAtLogin v5.0.0, whose isEnabled getter simply returns SMAppService.mainApp.status == .enabled. The user's intent is never persisted anywhere. macOS is known to occasionally drop background-item registrations (e.g. when the BTM database is reset/rebuilt, which can happen across OS updates). When that happens:

  • LinearMouse never launches at login again;
  • the "Start at login" toggle silently reads as off;
  • nothing ever re-registers, because the app has no memory that the user enabled it.

(register() failures are also only visible in os.log, so an enable that fails looks identical to one that succeeded until the next reboot.)

2. The macOS 13 migration call added in #445 was later removed, apparently accidentally.

#445 added LaunchAtLogin.migrateIfNeeded() to AppDelegate.applicationDidFinishLaunching. Commit 5437d88 ("Fix window title visibility built on new Xcode", #835 — an unrelated change) removed that line; the removal shipped in v0.10.1 and the call hasn't existed since (the import LaunchAtLogin in AppDelegate.swift is now unused). Users coming from a legacy pre-macOS 13 registration are never migrated, and the unregisterLegacy() cleanup never runs.

To reproduce

The registration loss itself is hard to trigger deterministically (it appears tied to BTM database resets during some macOS upgrades), but the resulting broken state is easy to verify on an affected machine:

sfltool dumpbtm | grep -ci linearmouse   # → 0, despite Start at login having been enabled

Expected behavior

If the user enabled "Start at login", LinearMouse should notice on launch that the registration is missing and re-register (surfacing SMAppService.Status.requiresApproval if macOS wants confirmation in System Settings → Login Items).

Anything else?

Proposed fix — I'd be happy to send a PR if this direction is welcome:

  1. Persist the user's launch-at-login intent as a Defaults key (the project already uses Defaults).
  2. On app launch, if intent is enabled but SMAppService.mainApp.status != .enabled, call register() again, and surface .requiresApproval to the user instead of failing silently.
  3. Restore the migrateIfNeeded() call (or equivalent logic) removed in 5437d88.
  4. Longer term, consider replacing the archived LaunchAtLogin package with a small internal SMAppService-based manager, keeping a legacy path only for macOS 11–12 (per the 11.0 deployment target).

Workaround for anyone hitting this today — a user LaunchAgent (keep the in-app "Start at login" toggle off so the two mechanisms don't race):

<!-- ~/Library/LaunchAgents/com.lujjjh.LinearMouse.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>AssociatedBundleIdentifiers</key>
	<string>com.lujjjh.LinearMouse</string>
	<key>Label</key>
	<string>com.lujjjh.LinearMouse</string>
	<key>LimitLoadToSessionType</key>
	<string>Aqua</string>
	<key>ProcessType</key>
	<string>Interactive</string>
	<key>Program</key>
	<string>/Applications/LinearMouse.app/Contents/MacOS/LinearMouse</string>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.lujjjh.LinearMouse.plist

Full disclosure: this investigation and write-up are a human + Claude (Anthropic's AI assistant) collaboration. The evidence comes from a real affected machine and the code/commit references were checked against this repository, but I apologize in advance if any of the analysis misses the mark or if AI-assisted reports aren't welcome here — happy to amend or close if so. LinearMouse has been genuinely useful to me for years; this is just an attempt to give something back after the workaround fixed my setup.

Activity

  1. added a commit that references this issue on Aug 8, 2026
    0790b4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions