diff --git a/README.md b/README.md index b506449..c349da8 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,7 @@ ## Installation -[Here](https://github.com/golota60/idasen-tray-controller/releases/) you can find all the releases and associated files you should download. Here's a quick explanation which version is for what system: - -- `windows-x64.zip` - contains `.exe` and `.msi` files - compiled for windows 64-bit system. -- `linux-x64.zip` - contains `.deb` and `.AppImage - compiled for linux 64-bit system. -- `aarch64-apple-darwin.zip` - contains `.dmg`, `.app` and `.sh`(for debugging) - compiled for apple silicon. -- `x86_64-apple-darwin.zip` - contains `.dmg`, `.app` and `.sh`(for debugging) - compiled for apple with intel-based processors. -- `universal-apple-darwin.zip` - contains `.dmg`, `.app` and `.sh`(for debugging) - compiled for any macOS system. Around 2x bigger than a dedicated build. +[Here](https://github.com/golota60/idasen-tray-controller/releases/) you can find all the releases and associated files you should download. ## Usage @@ -102,12 +96,13 @@ Roadmap(w/o order): - [x] Better desk moving behavior(currently it moves weirdly, due to usage of external lib) - [x] More information inside README + potential problems - [ ] Better tests -- [ ] Run on system startup +- [x] Run on system startup - [x] Display a setup screen instead of automatic connection for better UX - [x] Allow for config reset from inside the app -- [ ] Add options(TBD which ones) -- [ ] Automatic update prompts(?) -- [ ] Automatic deploys & changelog on CI +- [ ] Add options(low/high perf mode, system startup toggle) +- [ ] ~Automatic update prompts(?)~ who would want their desk manager app to connect to the internet +- [x] Automatic deploys +- [ ] low/high perf mode Known issues: diff --git a/package.json b/package.json index 467bd9c..4b8e5a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "idasen-tray-controller", "private": true, - "version": "0.0.1", + "version": "0.0.2", "type": "module", "license": "MIT", "scripts": { @@ -18,6 +18,7 @@ "clsx": "^1.2.1", "react": "^18.2.0", "react-dom": "^18.2.0", + "tauri-plugin-autostart-api": "https://github.com/tauri-apps/tauri-plugin-autostart", "use-simple-async": "^1.4.0" }, "devDependencies": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5214b2d..595ef16 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -89,6 +89,17 @@ dependencies = [ "url", ] +[[package]] +name = "auto-launch" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5904a4d734f0235edf29aab320a14899f3e090446e594ff96508a6215f76f89c" +dependencies = [ + "dirs", + "thiserror", + "winreg", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -650,6 +661,15 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -660,6 +680,17 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1268,7 +1299,7 @@ dependencies = [ [[package]] name = "idasen-tray-controller" -version = "0.0.0" +version = "0.0.2" dependencies = [ "btleplug 0.10.4", "idasen", @@ -1278,6 +1309,7 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-autostart", "thiserror", "tokio", "tokio-stream", @@ -3077,6 +3109,19 @@ dependencies = [ "tauri-utils", ] +[[package]] +name = "tauri-plugin-autostart" +version = "0.1.0" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#265acf745435dabe78321ff7cf1e0af92df566e2" +dependencies = [ + "auto-launch", + "log", + "serde", + "serde_json", + "tauri", + "thiserror", +] + [[package]] name = "tauri-runtime" version = "0.12.1" @@ -3962,6 +4007,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "winres" version = "0.1.12" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e174554..5c450a4 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "idasen-tray-controller" -version = "0.0.0" +version = "0.0.2" description = "An app to control IKEA Idasen desk" authors = ["you"] license = "MIT" @@ -25,6 +25,7 @@ indicatif = "0.16.2" thiserror = "1.0.30" tokio-stream = "0.1.8" uuid = "1.3.0" +tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b6d9c1f..0544204 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,6 +3,7 @@ windows_subsystem = "windows" )] +use tauri_plugin_autostart::MacosLauncher; use std::sync::Mutex; use btleplug::platform::Peripheral as PlatformPeripheral; @@ -128,6 +129,7 @@ fn main() { let tray = SystemTray::new().with_menu(tray); tauri::Builder::default() + .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, None)) .system_tray(tray) .manage(SharedDesk(None.into())) .setup(move |app| { diff --git a/src/AboutPage.tsx b/src/AboutPage.tsx index a5a0792..910020c 100644 --- a/src/AboutPage.tsx +++ b/src/AboutPage.tsx @@ -1,11 +1,25 @@ import clsx from "clsx"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { relaunch } from "@tauri-apps/api/process"; +import useSimpleAsync from "use-simple-async"; +import { enable, isEnabled, disable } from "tauri-plugin-autostart-api"; import Button from "./generic/Button"; import { removeConfig } from "./rustUtils"; const AboutPage = () => { const [prompt] = useState(); + const [isAutostartEnabled, setAutostartEnabled] = useState< + boolean | undefined + >(); + + const [upstreamAutostart] = useSimpleAsync(isEnabled); + + useEffect(() => { + if (isAutostartEnabled === undefined) { + setAutostartEnabled(upstreamAutostart); + } + }, [isAutostartEnabled, upstreamAutostart]); + return ( <>
@@ -22,6 +36,25 @@ const AboutPage = () => { > Reset config & restart the app +
+ { + if (isAutostartEnabled) { + disable(); + setAutostartEnabled(false); + } else { + enable(); + setAutostartEnabled(true); + } + }} + /> + +

{prompt}

diff --git a/yarn.lock b/yarn.lock index b98cf9e..e927646 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2647,6 +2647,12 @@ tailwindcss@^3.2.4: quick-lru "^5.1.1" resolve "^1.22.1" +"tauri-plugin-autostart-api@https://github.com/tauri-apps/tauri-plugin-autostart": + version "0.0.0" + resolved "https://github.com/tauri-apps/tauri-plugin-autostart#0c8e3ad92e00e7b0aed60fc8a639e77407105253" + dependencies: + "@tauri-apps/api" "^1.2.0" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"