tonhowtf/omniget · error · anyhow::Error
nao da para alterar este item
Error message
nao da para alterar este item
What it means
mac_set handles only specific macOS startup-item kinds (login items and a limited set of other item types); the final match arm is a catch-all that rejects anything else with this message. It means the requested enable/disable operation is not supported for that particular item kind on macOS.
Solutions
- Hide or disable the toggle in the UI for item kinds mac_set cannot change (only offer enable/disable for native login items)
- Extend mac_set with arms that unload/load launchd jobs (launchctl bootout/bootstrap) for LaunchAgent/LaunchDaemon kinds
- Return a clearer error that includes the unsupported item kind to help users understand why the toggle failed
- Ensure mac_items only reports items whose kind mac_set supports, keeping list and mutate capabilities in sync
Example fix
// before
_ => Err(anyhow!("nao da para alterar este item")),
// after: actionable message naming the kind
_ => Err(anyhow!("nao da para alterar este item (tipo: {:?}); apenas itens de login sao suportados", item.kind)), Defensive patterns
Strategy: type-guard
Validate before calling
// Only show toggles for kinds mac_set can change
const TOGGLABLE_KINDS: &[ItemKind] = &[ItemKind::LoginItem];
if !TOGGLABLE_KINDS.contains(&item.kind) {
// render as read-only instead of calling set_enabled
} Type guard
fn is_togglable(item: &StartupItem) -> bool {
matches!(item.kind, ItemKind::LoginItem)
} Try / catch
match set_enabled(item, true).await {
Ok(_) => refresh_items(),
Err(e) if e.to_string().contains("nao da para alterar este item") => {
eprintln!("Este tipo de item nao pode ser alternado pelo app");
// fall back to opening System Settings > Login Items
}
Err(e) => return Err(e),
} Prevention
- Keep mac_items and mac_set in sync: list only kinds set_enabled supports
- Disable or hide toggle UI for LaunchAgents/LaunchDaemons and other non-login-item kinds
- Include the item kind in the error message so users know what failed and why
- Offer launchctl bootout/bootstrap support if toggling launchd jobs is a requirement
When it happens
Trigger: Calling set_enabled on a startup item whose kind is not handled by mac_set's match — e.g. LaunchAgents/LaunchDaemons or other item categories that the function only knows how to list, not toggle.
Common situations: UI showing all discovered startup items (including launchd agents) with toggle switches, but only native login items are actually toggleable via System Events; users trying to disable system LaunchAgents that macOS intentionally protects; app version where listing gained new item kinds before set_enabled gained matching arms.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/c26fcc7a81488cc9.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/startup.rs:269
} else {
run(
"osascript",
&[
"-e",
&format!(
"tell application \"System Events\" to delete login item \"{}\"",
item.name.replace('"', "\\\"")
),
],
)
.await?;
removed.retain(|(n, _)| *n != item.name);
removed.push((item.name.clone(), item.path.clone()));
}
save_removed(&removed);
Ok(())
}
_ => Err(anyhow!("nao da para alterar este item")),
}
}
// ── Windows ────────────────────────────────────────────────────────────
const WIN_RUN: &[(&str, &str, &str)] = &[
(
r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run",
"run",
"user",
),
(
r"HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce",
"run-once",
"user",
),
(
r"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",View on GitHub (pinned to 8600b91f42)