tonhowtf/omniget · error · anyhow::Error

este item so pode ser alterado com privilegios de administra

Error message

este item so pode ser alterado com privilegios de administrador

What it means

`set_enabled` (startup.rs, public API) refuses to modify any StartupItem whose `can_toggle` flag is false. `can_toggle` is set to false during `list()` for items that live in privileged locations (e.g. system-wide autostart directories, root-owned LaunchAgents, HKLM registry entries) which the current user lacks permission to modify. The message says the item can only be changed with administrator privileges.

Solutions

  1. Check `item.can_toggle` before calling `set_enabled` and skip/alert for non-togglable items (the UI should already disable the switch).
  2. Re-run the application with elevated privileges (sudo / Run as administrator) so privileged items can be modified — note `can_toggle` is computed per-user, so elevation may require re-listing.
  3. Modify the underlying entry manually with admin rights (edit /etc/xdg/autostart/*.desktop, LaunchDaemons plist, or HKLM Run key).
  4. If the item should be user-togglable, copy it into the user-level autostart location and toggle that copy instead.

Example fix

// before
for item in startup::list().await {
    startup::set_enabled(&item, should_enable(&item)).await?;
}

// after
for item in startup::list().await {
    if !item.can_toggle {
        eprintln!("{} requer privilegios de administrador; ignorado", item.name);
        continue;
    }
    startup::set_enabled(&item, should_enable(&item)).await?;
}
Defensive patterns

Strategy: validation

Validate before calling

if !item.can_toggle {
    eprintln!("{}: requer privilegios de administrador", item.name);
    return Ok(()); // or prompt for elevation
}
startup::set_enabled(&item, enabled).await?;

Type guard

fn togglable(item: &StartupItem) -> bool { item.can_toggle }

Try / catch

match startup::set_enabled(&item, enabled).await {
    Err(e) if e.to_string().contains("privilegios de administrador") => {
        // relaunch with elevation or show "run as admin" hint
    }
    r => { r?; }
}

Prevention

When it happens

Trigger: Calling `startup::set_enabled(&item, enabled)` for any item returned by `startup::list()` with `item.can_toggle == false` — regardless of OS (the check runs before the platform dispatch).

Common situations: Toggling system-wide autostart .desktop files on Linux (/etc/xdg/autostart), root-owned LaunchDaemons on macOS, or machine-wide Windows startup entries while running as a non-elevated user.

Understand the failure class

Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/897cc11a28ff958c. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/startup.rs:558

}

// ── API ────────────────────────────────────────────────────────────────

pub async fn list() -> Vec<StartupItem> {
    let mut items = if cfg!(target_os = "macos") {
        mac_items().await
    } else if cfg!(target_os = "windows") {
        win_items().await
    } else {
        linux_items().await
    };
    items.sort_by_key(|a| a.name.to_lowercase());
    items
}

pub async fn set_enabled(item: &StartupItem, enabled: bool) -> anyhow::Result<()> {
    if !item.can_toggle {
        return Err(anyhow!(
            "este item so pode ser alterado com privilegios de administrador"
        ));
    }
    if cfg!(target_os = "macos") {
        mac_set(item, enabled).await
    } else if cfg!(target_os = "windows") {
        win_set(item, enabled).await
    } else {
        linux_set(item, enabled).await
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn desktop() {

View on GitHub (pinned to 8600b91f42)