diff --git a/src/content/docs/features/os-info.mdx b/src/content/docs/features/os-info.mdx index d49f66dc21..58594db502 100644 --- a/src/content/docs/features/os-info.mdx +++ b/src/content/docs/features/os-info.mdx @@ -3,11 +3,103 @@ title: OS Information description: Read information about the operating system. --- -import Stub from '@components/Stub.astro'; import PluginLinks from '@components/PluginLinks.astro'; +import { Tabs, TabItem } from '@astrojs/starlight/components'; +import CommandTabs from '@components/CommandTabs.astro'; - - Based on https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/os - +Read information about the operating system using the OS Information plugin. + +## Setup + +Install the OS Information plugin to get started. + + + + + 1. Use your project's package manager to add the dependency: + + + + 2. Modify `lib.rs` to initialize the plugin: + + {/* TODO: Revise once https://github.com/tauri-apps/tauri/issues/7696 is in */} + + ```rust + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_os::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + + + + 1. Run `cargo add tauri-plugin-os` to add the plugin to the project's dependencies in `Cargo.toml`. + + 2. Modify `lib.rs` to initialize the plugin: + + ```rust + // lib.rs + #[cfg_attr(mobile, tauri::mobile_entry_point)] + pub fn run() { + tauri::Builder::default() + // Initialize the plugin + .plugin(tauri_plugin_os::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); + } + ``` + + 3. If you'd like to use in JavaScript then install the npm package as well: + + + + + + + +## Usage + +With this plugin you can query multiple information from current operational system. See all available functions in the [JavaScript API](/2/reference/js/os/) or [Rust API](https://docs.rs/tauri-plugin-os/) references. + +{/* TODO: Link to which language to use, frontend vs. backend guide when it's made */} + +#### Example: OS Platform + +`platform` returns a string describing the specific operating system in use. The value is set at compile time. Possible values are `linux`, `macos`, `ios`, `freebsd`, `dragonfly`, `netbsd`, `openbsd`, `solaris`, `android`, `windows`. + + + + +```js +import { platform } from '@tauri-apps/plugin-os'; + +const platform = await platform(); +console.log(platform); +// Prints "windows" to the console +``` + + + + +```rust +let platform = tauri_plugin_os::platform(); +println!("Platform: {}", platform); +// Prints "windows" to the terminal +``` + + +