My attempt at making a buildable version of cinny-desktop-system-tray (use "git am cinny-desktop-system-tray.patch" to use for yourself)
cinny-desktop-system-tray.patch
edited
1From 84cd4ddc0b584c970f2c270a5f0693573caee4bb Mon Sep 17 00:00:00 2001
2From: Eli <eli@fereira.net>
3Date: Fri, 13 Mar 2026 06:24:42 -0400
4Subject: [PATCH] upgrade to v4.11.2
5
6---
7 .SRCINFO | 12 +-
8 PKGBUILD | 17 ++-
9 disable_updater.patch | 69 +++++++++
10 single_instance_support.patch | 105 +++++++++-----
11 system_tray_item.patch | 263 ++++++++++++++++++----------------
12 5 files changed, 294 insertions(+), 172 deletions(-)
13 create mode 100644 disable_updater.patch
14
15diff --git a/.SRCINFO b/.SRCINFO
16index edd38ad..674fed3 100644
17--- a/.SRCINFO
18+++ b/.SRCINFO
19@@ -1,6 +1,6 @@
20 pkgbase = cinny-desktop-system-tray
21 pkgdesc = Yet another matrix client - with support for system tray minimization
22- pkgver = 4.10.5
23+ pkgver = 4.11.2
24 pkgrel = 1
25 url = https://cinny.in/
26 arch = x86_64
27@@ -18,11 +18,13 @@ pkgbase = cinny-desktop-system-tray
28 depends = webkit2gtk
29 conflicts = cinny-desktop
30 conflicts = cinny-desktop-bin
31- source = cinny-desktop-4.10.5.zip::https://github.com/cinnyapp/cinny-desktop/releases/download/v4.10.5/cinny-desktop-v4.10.5.zip
32+ source = cinny-desktop-4.11.2.zip::https://github.com/cinnyapp/cinny-desktop/releases/download/v4.11.2/cinny-desktop-v4.11.2.zip
33 source = system_tray_item.patch
34 source = single_instance_support.patch
35- sha256sums = 14d93e5ed81d09eb089f709d8c590020d6da8f26bfdb05acc61ad080f28a2b78
36- sha256sums = d19eecf46baf3db986b5072dc32da1786e7474bcd7d7c702327d7cdc40639ab7
37- sha256sums = d584556e92cea4f1d450827681a6a40a4b720840f6ce9da9f1489ab64db59fb0
38+ source = disable_updater.patch
39+ sha256sums = 26bc01f7f30b20f471d72c9cf1b139f16b53c077eb6d576125404af21e10faa8
40+ sha256sums = 67ed1d1286a11163b644b2aa0a1b7bda6597162e4f8e7513a216b37ae2cc5431
41+ sha256sums = 913dcdaec82401e4a637cb25a9e353d691b22e2fd3ec38a7f7580f94748338fb
42+ sha256sums = 221f885e4c3f43e3316541ec57eab91a66ea550501441a1f936978a2170f8603
43
44 pkgname = cinny-desktop-system-tray
45diff --git a/PKGBUILD b/PKGBUILD
46index f6a7e36..4a27a4b 100644
47--- a/PKGBUILD
48+++ b/PKGBUILD
49@@ -3,7 +3,7 @@
50 #
51 # This file is copied from the 'cinny-desktop' package (https://aur.archlinux.org/packages/cinny-desktop) and modified to include the system tray patches.
52 pkgname='cinny-desktop-system-tray'
53-pkgver='4.10.5'
54+pkgver='4.11.2'
55 pkgrel='1'
56 pkgdesc='Yet another matrix client - with support for system tray minimization'
57 arch=('x86_64')
58@@ -14,14 +14,17 @@ depends=('gst-plugins-good' 'gtk3' 'libappindicator-gtk3' 'librsvg' 'libvips' 'o
59 makedepends=('nodejs' 'npm' 'rust')
60 source=("cinny-desktop-${pkgver}.zip::https://github.com/cinnyapp/cinny-desktop/releases/download/v${pkgver}/cinny-desktop-v${pkgver}.zip"
61 "system_tray_item.patch"
62- "single_instance_support.patch")
63-sha256sums=('14d93e5ed81d09eb089f709d8c590020d6da8f26bfdb05acc61ad080f28a2b78'
64- 'd19eecf46baf3db986b5072dc32da1786e7474bcd7d7c702327d7cdc40639ab7'
65- 'd584556e92cea4f1d450827681a6a40a4b720840f6ce9da9f1489ab64db59fb0')
66+ "single_instance_support.patch"
67+ "disable_updater.patch")
68+sha256sums=('26bc01f7f30b20f471d72c9cf1b139f16b53c077eb6d576125404af21e10faa8'
69+ '67ed1d1286a11163b644b2aa0a1b7bda6597162e4f8e7513a216b37ae2cc5431'
70+ '913dcdaec82401e4a637cb25a9e353d691b22e2fd3ec38a7f7580f94748338fb'
71+ '221f885e4c3f43e3316541ec57eab91a66ea550501441a1f936978a2170f8603')
72
73 prepare() {
74 patch -d cinny-desktop -Np1 -i ../system_tray_item.patch || true
75- patch -d cinny-desktop -Np1 -i ../single_instance_support.patch
76+ patch -d cinny-desktop -Np1 -i ../single_instance_support.patch || true
77+ patch -d cinny-desktop -Np1 -i ../disable_updater.patch
78
79 cargo update -p tauri --manifest-path cinny-desktop/src-tauri/Cargo.toml
80 cargo update -p tauri-plugin-single-instance --manifest-path cinny-desktop/src-tauri/Cargo.toml
81@@ -31,7 +34,7 @@ build() {
82 cd cinny-desktop
83 cd ./cinny && npm --legacy-peer-deps ci
84 cd .. && npm ci
85- NODE_OPTIONS=--max_old_space_size=4096 npm run tauri build -- --bundles deb
86+ NODE_OPTIONS=--max_old_space_size=8096 npm run tauri build -- --bundles deb
87 }
88
89 package() {
90diff --git a/disable_updater.patch b/disable_updater.patch
91new file mode 100644
92index 0000000..9f64b2f
93--- /dev/null
94+++ b/disable_updater.patch
95@@ -0,0 +1,69 @@
96+From cbd03abbd607511ea5d0ef34ab1ae467a9df3983 Mon Sep 17 00:00:00 2001
97+From: Eli <eli@fereira.net>
98+Date: Fri, 13 Mar 2026 06:17:54 -0400
99+Subject: [PATCH] disable updater
100+
101+---
102+ package.json | 3 +--
103+ src-tauri/Cargo.toml | 1 -
104+ src-tauri/tauri.conf.json | 11 +----------
105+ 3 files changed, 2 insertions(+), 13 deletions(-)
106+
107+diff --git a/package.json b/package.json
108+index c532878..d267d07 100644
109+--- a/package.json
110++++ b/package.json
111+@@ -23,8 +23,7 @@
112+ "@tauri-apps/plugin-notification": "2.3.0",
113+ "@tauri-apps/plugin-os": "2.3.0",
114+ "@tauri-apps/plugin-process": "2.3.0",
115+- "@tauri-apps/plugin-shell": "2.3.0",
116+- "@tauri-apps/plugin-updater": "2.9.0"
117++ "@tauri-apps/plugin-shell": "2.3.0"
118+ },
119+ "devDependencies": {
120+ "@actions/github": "6.0.0",
121+diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
122+index 84ce460..f3c2d6e 100644
123+--- a/src-tauri/Cargo.toml
124++++ b/src-tauri/Cargo.toml
125+@@ -40,7 +40,6 @@ custom-protocol = [ "tauri/custom-protocol" ]
126+ [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
127+ tauri-plugin-global-shortcut = "2"
128+ tauri-plugin-single-instance = "2"
129+-tauri-plugin-updater = "2"
130+
131+ [lib]
132+ name = "app_lib"
133+diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
134+index 9c906b4..40cef42 100644
135+--- a/src-tauri/tauri.conf.json
136++++ b/src-tauri/tauri.conf.json
137+@@ -36,8 +36,7 @@
138+ "deb": {
139+ "depends": []
140+ }
141+- },
142+- "createUpdaterArtifacts": "v1Compatible"
143++ }
144+ },
145+ "build": {
146+ "beforeBuildCommand": "cd cinny && npm run build",
147+@@ -49,14 +48,6 @@
148+ "mainBinaryName": "cinny",
149+ "version": "4.11.2",
150+ "identifier": "in.cinny.app",
151+- "plugins": {
152+- "updater": {
153+- "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE2NDc3NDBGMTAzNTk1NUYKUldSZmxUVVFEM1JIRnRuMjVRTkFOQ21lUFI5KzRMU0s4OWtBS1RNRUVCNE9LcE9GcExNZ2M2NHoK",
154+- "endpoints": [
155+- "https://github.com/cinnyapp/cinny-desktop/releases/download/tauri/release.json"
156+- ]
157+- }
158+- },
159+ "app": {
160+ "security": {
161+ "csp": "default-src 'self' blob: data: filesystem: ws: wss: http: https: tauri:; script-src 'self' 'unsafe-eval' 'unsafe-inline' blob: data: filesystem: ws: wss: http: https: tauri:; img-src 'self' data: blob: filesystem: http: https:; connect-src 'self' ipc: ws: wss: http: https: http://ipc.localhost"
162+--
163+2.53.0
164+
165diff --git a/single_instance_support.patch b/single_instance_support.patch
166index 0069385..a1f8444 100644
167--- a/single_instance_support.patch
168+++ b/single_instance_support.patch
169@@ -1,53 +1,88 @@
170-From ababdf4ae3f10f94241f14c1c87a2f6ba05d7557 Mon Sep 17 00:00:00 2001
171-From: bytedream <me@bytedream.dev>
172-Date: Wed, 29 Oct 2025 15:40:28 +0100
173-Subject: [PATCH] add single instance support
174+From 92377631573395498381e6bf72c541f00639d4ab Mon Sep 17 00:00:00 2001
175+From: Eli <eli@fereira.net>
176+Date: Fri, 13 Mar 2026 06:15:57 -0400
177+Subject: [PATCH] single instance support
178
179 ---
180- src-tauri/Cargo.toml | 1 +
181- src-tauri/src/main.rs | 10 +++++++++-
182- 2 files changed, 10 insertions(+), 1 deletion(-)
183+ src-tauri/Cargo.lock | 16 ++++++++++++++++
184+ src-tauri/Cargo.toml | 1 +
185+ src-tauri/src/lib.rs | 10 +++++++++-
186+ 3 files changed, 26 insertions(+), 1 deletion(-)
187
188+diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
189+index e92d534..eb0b1ce 100644
190+--- a/src-tauri/Cargo.lock
191++++ b/src-tauri/Cargo.lock
192+@@ -564,6 +564,7 @@ dependencies = [
193+ "tauri-plugin-os",
194+ "tauri-plugin-process",
195+ "tauri-plugin-shell",
196++ "tauri-plugin-single-instance",
197+ "tauri-plugin-updater",
198+ "tauri-plugin-window-state",
199+ ]
200+@@ -4733,6 +4734,21 @@ dependencies = [
201+ "tokio",
202+ ]
203+
204++[[package]]
205++name = "tauri-plugin-single-instance"
206++version = "2.2.0"
207++source = "registry+https://github.com/rust-lang/crates.io-index"
208++checksum = "0f36019ee9832dc99e4450bb55a21cfad8633b19c2c18bd17c7741939b070ede"
209++dependencies = [
210++ "serde",
211++ "serde_json",
212++ "tauri",
213++ "thiserror 2.0.15",
214++ "tracing",
215++ "windows-sys 0.59.0",
216++ "zbus",
217++]
218++
219+ [[package]]
220+ name = "tauri-plugin-updater"
221+ version = "2.9.0"
222 diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
223-index 371df47..bc354dd 100644
224+index f347e35..84ce460 100644
225 --- a/src-tauri/Cargo.toml
226 +++ b/src-tauri/Cargo.toml
227-@@ -19,6 +19,7 @@ serde_json = "1.0.109"
228- serde = { version = "1.0.193", features = ["derive"] }
229- tauri = { version = "1.8.0", features = ["api-all", "devtools", "system-tray", "updater"] }
230- tauri-plugin-localhost = "0.1.0"
231-+tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
232- tauri-plugin-window-state = "0.1.1"
233+@@ -39,6 +39,7 @@ custom-protocol = [ "tauri/custom-protocol" ]
234
235- [features]
236-diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
237-index 0682873..02733d8 100644
238---- a/src-tauri/src/main.rs
239-+++ b/src-tauri/src/main.rs
240-@@ -7,7 +7,7 @@
241- mod menu;
242- mod tray;
243+ [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
244+ tauri-plugin-global-shortcut = "2"
245++tauri-plugin-single-instance = "2"
246+ tauri-plugin-updater = "2"
247
248--use tauri::{utils::config::AppUrl, WindowUrl};
249-+use tauri::{utils::config::AppUrl, Manager, WindowUrl};
250+ [lib]
251+diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
252+index 27f6198..6d218f8 100644
253+--- a/src-tauri/src/lib.rs
254++++ b/src-tauri/src/lib.rs
255+@@ -6,7 +6,7 @@
256+ // mod menu;
257+ mod tray;
258
259- fn main() {
260- let port = 44548;
261-@@ -29,6 +29,14 @@ fn main() {
262+-use tauri::{webview::WebviewWindowBuilder, WebviewUrl};
263++use tauri::{webview::WebviewWindowBuilder, WebviewUrl, Manager};
264
265+ pub fn run() {
266+ let port: u16 = 44548;
267+@@ -21,6 +21,14 @@ pub fn run() {
268 builder
269 .plugin(tauri_plugin_localhost::Builder::new(port).build())
270+ .plugin(tauri_plugin_window_state::Builder::default().build())
271 + .plugin(tauri_plugin_single_instance::init(|app, _, _| {
272-+ let window = app.get_window("main").unwrap();
273-+ let tray_handle = match app.tray_handle_by_id(tray::TRAY_LABEL) {
274-+ Some(h) => h,
275++ let window = app.get_webview_window("main").unwrap();
276++ let icon = match app.tray_by_id(tray::TRAY_LABEL) {
277++ Some(x) => x,
278 + None => return,
279 + };
280-+ tray::toggle_window_state(window, tray_handle)
281++ tray::toggle_shown(&window, &icon);
282 + }))
283- .plugin(tauri_plugin_window_state::Builder::default().build())
284- .on_window_event(tray::window_event_handler)
285- .run(context)
286+ .setup(move |app| {
287+ let url = format!("http://localhost:{}", port).parse().unwrap();
288+ let window_url = WebviewUrl::External(url);
289 --
290-2.51.2
291+2.53.0
292
293diff --git a/system_tray_item.patch b/system_tray_item.patch
294index 78ce23d..d0c2ff3 100644
295--- a/system_tray_item.patch
296+++ b/system_tray_item.patch
297@@ -1,168 +1,181 @@
298-From c1e4cdcb68c40e723c2f58c3ed319c506e03122c Mon Sep 17 00:00:00 2001
299-From: bytedream <me@bytedream.dev>
300-Date: Wed, 29 Oct 2025 15:37:57 +0100
301-Subject: [PATCH] add system tray item
302+From 5fa68716fa5ff5cb1cd9dff7344c00d4a64ca38f Mon Sep 17 00:00:00 2001
303+From: Eli <eli@fereira.net>
304+Date: Fri, 13 Mar 2026 06:13:53 -0400
305+Subject: [PATCH] add systray features
306
307 ---
308- src-tauri/Cargo.toml | 2 +-
309- src-tauri/build.rs | 2 +-
310- src-tauri/src/main.rs | 6 +++
311- src-tauri/src/tray.rs | 77 +++++++++++++++++++++++++++++++++++++++
312- src-tauri/tauri.conf.json | 5 +++
313- 5 files changed, 90 insertions(+), 2 deletions(-)
314+ src-tauri/Cargo.toml | 2 +-
315+ src-tauri/src/lib.rs | 3 ++
316+ src-tauri/src/main.rs | 4 +-
317+ src-tauri/src/tray.rs | 107 ++++++++++++++++++++++++++++++++++++++++++
318+ 4 files changed, 113 insertions(+), 3 deletions(-)
319 create mode 100644 src-tauri/src/tray.rs
320
321 diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
322-index 16d846a..371df47 100644
323+index 0b05989..f347e35 100644
324 --- a/src-tauri/Cargo.toml
325 +++ b/src-tauri/Cargo.toml
326-@@ -17,7 +17,7 @@ tauri-build = { version = "1.5.5", features = [] }
327+@@ -17,7 +17,7 @@ tauri-build = { version = "2", features = [] }
328 [dependencies]
329 serde_json = "1.0.109"
330 serde = { version = "1.0.193", features = ["derive"] }
331--tauri = { version = "1.8.0", features = ["api-all", "devtools", "updater"] }
332-+tauri = { version = "1.8.0", features = ["api-all", "devtools", "system-tray", "updater"] }
333- tauri-plugin-localhost = "0.1.0"
334- tauri-plugin-window-state = "0.1.1"
335+-tauri = { version = "2", features = [ "devtools"] }
336++tauri = { version = "2", features = [ "devtools", "tray-icon" ] }
337+ tauri-plugin-localhost = "2"
338+ tauri-plugin-window-state = "2"
339+ tauri-plugin-clipboard-manager = "2"
340+diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
341+index 7162e5b..27f6198 100644
342+--- a/src-tauri/src/lib.rs
343++++ b/src-tauri/src/lib.rs
344+@@ -4,6 +4,7 @@
345+ )]
346
347-diff --git a/src-tauri/build.rs b/src-tauri/build.rs
348-index 795b9b7..d860e1e 100644
349---- a/src-tauri/build.rs
350-+++ b/src-tauri/build.rs
351-@@ -1,3 +1,3 @@
352- fn main() {
353-- tauri_build::build()
354-+ tauri_build::build()
355- }
356-diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
357-index 4231f30..0682873 100644
358---- a/src-tauri/src/main.rs
359-+++ b/src-tauri/src/main.rs
360-@@ -5,6 +5,7 @@
361-
362- #[cfg(target_os = "macos")]
363- mod menu;
364+ // mod menu;
365 +mod tray;
366
367- use tauri::{utils::config::AppUrl, WindowUrl};
368+ use tauri::{webview::WebviewWindowBuilder, WebviewUrl};
369
370-@@ -19,12 +20,17 @@ fn main() {
371- context.config_mut().build.dev_path = AppUrl::Url(window_url.clone());
372- let builder = tauri::Builder::default();
373-
374-+ let builder = builder
375-+ .system_tray(tray::system_tray())
376-+ .on_system_tray_event(tray::system_tray_handler);
377-+
378- #[cfg(target_os = "macos")]
379- let builder = builder.menu(menu::menu());
380-
381- builder
382- .plugin(tauri_plugin_localhost::Builder::new(port).build())
383- .plugin(tauri_plugin_window_state::Builder::default().build())
384-+ .on_window_event(tray::window_event_handler)
385+@@ -23,11 +24,13 @@ pub fn run() {
386+ .setup(move |app| {
387+ let url = format!("http://localhost:{}", port).parse().unwrap();
388+ let window_url = WebviewUrl::External(url);
389++ tray::build_tray(&app)?;
390+ WebviewWindowBuilder::new(app, "main".to_string(), window_url)
391+ .title("Cinny")
392+ .build()?;
393+ Ok(())
394+ })
395++ .on_window_event(tray::window_handler)
396 .run(context)
397- .expect("error while building tauri application")
398+ .expect("error while building tauri application");
399 }
400+diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
401+index cea0b30..c672c6a 100644
402+--- a/src-tauri/src/main.rs
403++++ b/src-tauri/src/main.rs
404+@@ -1,5 +1,5 @@
405+ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
406+
407+ fn main() {
408+- app_lib::run();
409+-}
410+\ No newline at end of file
411++ app_lib::run();
412++}
413 diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs
414 new file mode 100644
415-index 0000000..7dd5f72
416+index 0000000..ac90012
417 --- /dev/null
418 +++ b/src-tauri/src/tray.rs
419-@@ -0,0 +1,77 @@
420+@@ -0,0 +1,107 @@
421 +use tauri::{
422-+ CustomMenuItem, GlobalWindowEvent, Manager, SystemTray, SystemTrayEvent, SystemTrayHandle,
423-+ SystemTrayMenu, SystemTrayMenuItem, Window, WindowEvent,
424++ menu::{MenuBuilder, MenuEvent, MenuItem},
425++ tray::{TrayIcon, TrayIconBuilder, TrayIconEvent},
426++ App, AppHandle, Error, Manager, WebviewWindow, Window, WindowEvent,
427 +};
428 +
429 +pub const TRAY_LABEL: &'static str = "main-tray";
430 +
431-+pub fn window_event_handler<R: tauri::Runtime>(event: GlobalWindowEvent<R>) {
432-+ match event.event() {
433-+ // Prevent Cinny from closing, instead hide it and let it be
434-+ // reopened through the tray.
435-+ WindowEvent::CloseRequested { api, .. } => {
436-+ api.prevent_close();
437++pub fn build_tray(app: &App) -> Result<TrayIcon, Error> {
438++ let toggle = MenuItem::with_id(app, "toggle", "Hide", true, None::<&str>)?;
439++ let quit = MenuItem::with_id(app, "quit", "Quit Cinny", true, None::<&str>)?;
440++ let menu = MenuBuilder::new(app)
441++ .separator()
442++ .item(&toggle)
443++ .item(&quit)
444++ .build()?;
445 +
446-+ let window = event.window().clone();
447-+ let tray_handle = window.app_handle().tray_handle_by_id(TRAY_LABEL).unwrap();
448-+ toggle_window_state(window, tray_handle);
449-+ }
450-+ _ => {}
451++ TrayIconBuilder::with_id(TRAY_LABEL)
452++ .icon(app.default_window_icon().unwrap().clone())
453++ .show_menu_on_left_click(false)
454++ .on_menu_event(menu_handler)
455++ .on_tray_icon_event(icon_handler)
456++ .menu(&menu)
457++ .build(app)
458++}
459++
460++fn menu_handler<R: tauri::Runtime>(app: &AppHandle<R>, event: MenuEvent) {
461++ let window = app.get_webview_window("main").unwrap();
462++ let icon = match app.tray_by_id(TRAY_LABEL) {
463++ Some(x) => x,
464++ None => return,
465++ };
466++
467++ match event {
468++ MenuEvent { id } => match id.0.as_str() {
469++ "quit" => {
470++ app.exit(0);
471++ }
472++ "toggle" => {
473++ toggle_shown(&window, &icon);
474++ }
475++ _ => (),
476++ },
477 + }
478 +}
479 +
480-+/// Build the system tray object
481-+pub fn system_tray() -> SystemTray {
482-+ let toggle = CustomMenuItem::new("toggle".to_owned(), "Hide Cinny");
483-+ let quit = CustomMenuItem::new("quit".to_owned(), "Quit");
484-+ let menu = SystemTrayMenu::new()
485-+ .add_item(toggle)
486-+ .add_native_item(SystemTrayMenuItem::Separator)
487-+ .add_item(quit);
488++fn icon_handler<R: tauri::Runtime>(icon: &TrayIcon<R>, event: TrayIconEvent) {
489++ let window = icon.app_handle().get_webview_window("main").unwrap();
490++ let icon = match icon.app_handle().tray_by_id(TRAY_LABEL) {
491++ Some(x) => x,
492++ None => return,
493++ };
494++
495++ match event {
496++ TrayIconEvent::Click { button, .. } => match button {
497++ tauri::tray::MouseButton::Left => {
498++ toggle_shown(&window, &icon);
499++ }
500++ _ => (),
501++ },
502++ _ => (),
503++ }
504++}
505 +
506-+ SystemTray::new()
507-+ .with_menu(menu)
508-+ .with_id(TRAY_LABEL.to_owned())
509++pub fn window_handler<R: tauri::Runtime>(window: &Window<R>, event: &WindowEvent) {
510++ let webview = window.get_webview_window("main").unwrap();
511++ let icon = match window.app_handle().tray_by_id(TRAY_LABEL) {
512++ Some(x) => x,
513++ None => return,
514++ };
515++ match event {
516++ WindowEvent::CloseRequested { api, .. } => {
517++ api.prevent_close();
518++ toggle_shown(&webview, &icon);
519++ }
520++ _ => (),
521++ }
522 +}
523 +
524-+pub fn toggle_window_state<R: tauri::Runtime>(window: Window<R>, tray_handle: SystemTrayHandle<R>) {
525-+ // Hide the window if it's visible, show it if not
526-+ // `is_visible` returns true for minimized state for whatever reason
527++pub fn toggle_shown<R: tauri::Runtime>(window: &WebviewWindow<R>, icon: &TrayIcon<R>) {
528++ let app = window.app_handle();
529++ let show = MenuItem::with_id(app, "toggle", "Show Cinny", true, None::<&str>).unwrap();
530++ let hide = MenuItem::with_id(app, "toggle", "Hide Cinny", true, None::<&str>).unwrap();
531++ let quit = MenuItem::with_id(app, "quit", "Quit Cinny", true, None::<&str>).unwrap();
532 + if window.is_visible().unwrap() {
533 + window.hide().unwrap();
534-+ tray_handle
535-+ .get_item("toggle")
536-+ .set_title("Show Cinny")
537++ let menu = MenuBuilder::new(app)
538++ .item(&show)
539++ .separator()
540++ .item(&quit)
541++ .build()
542 + .unwrap();
543++
544++ icon.set_menu(Some(menu)).unwrap();
545 + } else {
546-+ window.unminimize().unwrap();
547 + window.show().unwrap();
548-+ window.set_focus().unwrap();
549-+ tray_handle
550-+ .get_item("toggle")
551-+ .set_title("Hide Cinny")
552-+ .unwrap();
553-+ };
554-+}
555 +
556-+pub fn system_tray_handler<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: SystemTrayEvent) {
557-+ let tray_handle = match app.tray_handle_by_id(TRAY_LABEL) {
558-+ Some(h) => h,
559-+ None => return,
560-+ };
561-+ let window = app.get_window("main").unwrap();
562++ let menu = MenuBuilder::new(app)
563++ .item(&hide)
564++ .separator()
565++ .item(&quit)
566++ .build()
567++ .unwrap();
568 +
569-+ match event {
570-+ SystemTrayEvent::LeftClick { .. } => {
571-+ toggle_window_state(window, tray_handle);
572-+ }
573-+ SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
574-+ "quit" => {
575-+ app.exit(0);
576-+ }
577-+ "toggle" => toggle_window_state(window, tray_handle),
578-+ _ => {}
579-+ },
580-+ _ => {}
581++ icon.set_menu(Some(menu)).unwrap();
582 + }
583 +}
584-diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
585-index c5fa963..30df2f3 100644
586---- a/src-tauri/tauri.conf.json
587-+++ b/src-tauri/tauri.conf.json
588-@@ -72,6 +72,11 @@
589- ],
590- "security": {
591- "csp": "script-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'"
592-+ },
593-+ "systemTray": {
594-+ "iconPath": "icons/32x32.png",
595-+ "iconAsTemplate": true,
596-+ "menuOnLeftClick": false
597- }
598- }
599- }
600 --
601-2.51.2
602+2.53.0
603
604--
6052.53.0
606