tauri-plugin-macos-permissions

Crates.iotauri-plugin-macos-permissions
lib.rstauri-plugin-macos-permissions
version2.0.4
sourcesrc
created_at2024-11-18 04:40:35.336589
updated_at2024-11-23 14:10:32.180346
descriptionAccessibility and full disk access for macOS can be checked and requested.
homepage
repositoryhttps://github.com/ayangweb/tauri-plugin-macos-permissions
max_upload_size
id1451770
size101,831
ayang (ayangweb)

documentation

README

tauri-plugin-macos-permissions

This plugin only works on tauri v2, if you need the v1 plugin, feel free to submit a PR!

Check and request macOS permissions to accessibility and full disk access.

https://github.com/user-attachments/assets/547a920c-29ef-4cd4-bba7-3e58c3f3bcd0

Install

cargo add tauri-plugin-macos-permissions

You can install the JavaScript Guest bindings using your preferred JavaScript package manager:

pnpm add tauri-plugin-macos-permissions-api

Usage

src-tauri/src/lib.rs

pub fn run() {
    tauri::Builder::default()
+       .plugin(tauri_plugin_macos_permissions::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

src-tauri/capabilities/default.json

{
    ...
    "permissions": [
        ...
+       "macos-permissions:default"
    ]
}

Afterwards all the plugin's APIs are available through the JavaScript guest bindings:

import { checkAccessibilityPermissions } from "tauri-plugin-macos-permissions-api";

const authorized = await checkAccessibilityPermissions();
console.log(authorized); // true

Methods

Method Description
checkAccessibilityPermissions Check Accessibility Permissions.
requestAccessibilityPermissions Request Accessibility Permissions.
checkFullDiskAccessPermissions Check Full Disk Access Permissions.
requestFullDiskAccessPermissions Request Full Disk Access Permissions.

Example

git clone https://github.com/ayangweb/tauri-plugin-macos-permissions.git
pnpm install

pnpm build

cd examples/tauri-app

pnpm install

pnpm tauri dev
Commit count: 26

cargo fmt