1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 05:45:50 +05:30

fix: tray icon on flatpak

This commit is contained in:
2026-03-01 22:55:01 +05:30
Verified
parent 5b7df779cc
commit 33c504ae19

View File

@@ -21,6 +21,7 @@ use std::{
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
path::BaseDirectory,
Emitter, Manager, State,
};
use tauri_plugin_opener::OpenerExt;
@@ -584,6 +585,20 @@ pub async fn run() {
.build(app)
.map_err(|e| format!("Failed to create tray: {}", e))?;
// Fix tray icon in sandboxed environments (e.g., Flatpak)
// libappindicator uses the full path of the icon in dbus messages,
// so the path needs to be accessible from both the host and the sandbox.
// The default /tmp path doesn't work across sandbox boundaries.
if let Ok(local_data_path) = app
.path()
.resolve("tray-icon", BaseDirectory::AppLocalData)
{
let _ = fs::create_dir_all(&local_data_path);
let _ = tray.set_temp_dir_path(Some(local_data_path));
// Re-set the icon so it gets written to the new temp dir path
let _ = tray.set_icon(Some(app.default_window_icon().unwrap().clone()));
}
app.manage(tray);
let window = app.get_webview_window("main").unwrap();