check tray support on inux

Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
FTCHD
2025-10-08 13:07:50 +02:00
parent 5633acfc13
commit 097047a1ce
4 changed files with 87 additions and 2 deletions
+39 -1
View File
@@ -603,6 +603,43 @@ async function checkVersion() {
} catch {}
}
async function checkTraySupport() {
let traySupported = false
try {
traySupported = await invoke<boolean>('is_tray_supported')
} catch {}
if (!traySupported) {
const msg =
'Your desktop environment does not appear to support system tray icons.\n\nRclone UI requires a tray to run. The application will exit automatically in 10 seconds.'
let alreadyExiting = false
const timer = setTimeout(async () => {
if (alreadyExiting) return
alreadyExiting = true
await exit(0)
}, 10_000)
ask(msg, {
title: 'Tray Not Supported',
kind: 'error',
okLabel: 'Exit Now',
cancelLabel: 'Cancel',
})
.then(async (confirmed) => {
if (!alreadyExiting && confirmed) {
alreadyExiting = true
clearTimeout(timer)
await exit(0)
}
})
.catch()
await new Promise(() => {})
}
}
getCurrentWindow().listen('tauri://close-requested', async (e) => {
console.log('(main) window close requested')
await getCurrentWindow().destroy()
@@ -617,7 +654,8 @@ getCurrentWindow().listen('rebuild-tray', async (e) => {
await showDefaultTray()
})
initTray()
checkTraySupport()
.then(() => initTray())
.then(() => showLoadingTray())
.then(() => waitForHydration())
.then(() => checkVersion())