mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-22 09:05:49 +05:30
fix: tray icon on flatpak
This commit is contained in:
@@ -21,6 +21,7 @@ use std::{
|
|||||||
use tauri::{
|
use tauri::{
|
||||||
menu::{Menu, MenuItem},
|
menu::{Menu, MenuItem},
|
||||||
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
||||||
|
path::BaseDirectory,
|
||||||
Emitter, Manager, State,
|
Emitter, Manager, State,
|
||||||
};
|
};
|
||||||
use tauri_plugin_opener::OpenerExt;
|
use tauri_plugin_opener::OpenerExt;
|
||||||
@@ -584,6 +585,20 @@ pub async fn run() {
|
|||||||
.build(app)
|
.build(app)
|
||||||
.map_err(|e| format!("Failed to create tray: {}", e))?;
|
.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);
|
app.manage(tray);
|
||||||
|
|
||||||
let window = app.get_webview_window("main").unwrap();
|
let window = app.get_webview_window("main").unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user