Merge pull request #2235 from Kingtous/master
opt: stop show tray icon in root mode
This commit is contained in:
		
						commit
						8b20237096
					
				| @ -188,8 +188,14 @@ pub fn core_main() -> Option<Vec<String>> { | |||||||
|             #[cfg(target_os = "linux")] |             #[cfg(target_os = "linux")] | ||||||
|             { |             { | ||||||
|                 let handler = std::thread::spawn(move || crate::start_server(true)); |                 let handler = std::thread::spawn(move || crate::start_server(true)); | ||||||
|                 crate::tray::start_tray(); |                 // Show the tray in linux only when current user is a normal user
 | ||||||
|                 // revent server exit when encountering errors from tray
 |                 // [Note]
 | ||||||
|  |                 // As for GNOME, the tray cannot be shown in user's status bar.
 | ||||||
|  |                 // As for KDE, the tray can be shown without user's theme.
 | ||||||
|  |                 if !crate::platform::is_root() { | ||||||
|  |                     crate::tray::start_tray(); | ||||||
|  |                 } | ||||||
|  |                 // prevent server exit when encountering errors from tray
 | ||||||
|                 hbb_common::allow_err!(handler.join()); |                 hbb_common::allow_err!(handler.join()); | ||||||
|             } |             } | ||||||
|         } else if args[0] == "--import-config" { |         } else if args[0] == "--import-config" { | ||||||
|  | |||||||
| @ -150,6 +150,13 @@ fn get_default_app_indicator() -> Option<AppIndicator> { | |||||||
|     match std::fs::File::create(icon_path.clone()) { |     match std::fs::File::create(icon_path.clone()) { | ||||||
|         Ok(mut f) => { |         Ok(mut f) => { | ||||||
|             f.write_all(icon).unwrap(); |             f.write_all(icon).unwrap(); | ||||||
|  |             // set .png icon file to be writable
 | ||||||
|  |             // this ensures successful file rewrite when switching between x11 and wayland.
 | ||||||
|  |             let mut perm = f.metadata().unwrap().permissions(); | ||||||
|  |             if perm.readonly() { | ||||||
|  |                 perm.set_readonly(false); | ||||||
|  |                 f.set_permissions(perm).unwrap(); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         Err(err) => { |         Err(err) => { | ||||||
|             error!("Error when writing icon to {:?}: {}", icon_path, err); |             error!("Error when writing icon to {:?}: {}", icon_path, err); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user