Skip to content

Commit

Permalink
fix: Start hidden when run on windows start
Browse files Browse the repository at this point in the history
fix #6
  • Loading branch information
dubisdev committed Jan 28, 2024
1 parent 71e7a41 commit a7593fe
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
70 changes: 68 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.5", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.5", features = ["clipboard-write-text", "global-shortcut-all", "notification-all", "process-exit", "shell-open", "system-tray", "updater", "window-close", "window-create", "window-hide", "window-set-focus", "window-set-size", "window-show", "window-start-dragging", "window-unminimize"] }
tauri = { version = "1.5", features = [ "cli", "clipboard-write-text", "global-shortcut-all", "notification-all", "process-exit", "shell-open", "system-tray", "updater", "window-close", "window-create", "window-hide", "window-set-focus", "window-set-size", "window-show", "window-start-dragging", "window-unminimize"] }
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec![""]),
Some(vec!["--hidden"]),
))
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
app.emit_all("single-instance", Payload { args: argv, cwd })
Expand Down
8 changes: 8 additions & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
"systemTray": {
"iconPath": "icons/app-icon.png"
},
"cli": {
"args": [
{
"name": "hidden",
"short": "h"
}
]
},
"allowlist": {
"globalShortcut": {
"all": true
Expand Down
11 changes: 10 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App";

import { getMatches } from "@tauri-apps/api/cli";
import { getCurrent } from "@tauri-apps/api/window";
import "./index.css";

// Start hidden if the arg is present (e.g. when the auto-launcher starts the app)
getMatches().then((matches) => {
const shouldHide = matches.args.hidden.value
if (shouldHide) {
getCurrent().hide()
}
})

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
Expand Down

0 comments on commit a7593fe

Please sign in to comment.