Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tray Icon in Linux Automatically Disappears #13130

Open
Aswathips opened this issue Oct 4, 2023 · 16 comments
Open

Tray Icon in Linux Automatically Disappears #13130

Aswathips opened this issue Oct 4, 2023 · 16 comments

Comments

@Aswathips
Copy link

tray icon in linux system automatically Disappears , starting of the program there is no issue after some time of work it will happen , i tested this issue in various ubuntu versions and there is no error log ( in apps exception log and linux syslog)

  • OS: Linux (Ubuntu 18 , 20)
  • Avalonia-Version: [11.0.4 and below ]
@Aswathips Aswathips added the bug label Oct 4, 2023
@timunie
Copy link
Contributor

timunie commented Oct 4, 2023

can you test a minimal sample? If it still happens, please upload your sample here for some of us to double-check.

@Aswathips
Copy link
Author

ok i will give you a sample repo

@Aswathips
Copy link
Author

Here is the minimal sample. In this sample also the tray icon disapears.

https://github.com/Aswathips/TrayIcon_Test.git

@timunie
Copy link
Contributor

timunie commented Oct 6, 2023

Okay I tried your sample on my windows machine. I guess I know what happens here. If the user closes the last window, the App thinks it should shut down. However, in your case it is not what you want. So try to add this line and check if it helps in your situation:

    public override void OnFrameworkInitializationCompleted()
    {
        if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
        {
+           desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            
            _contex = DataContext as ApplicationViewModel;
            //other code
        }

        base.OnFrameworkInitializationCompleted();
    }

@Aswathips
Copy link
Author

I already added it in program.cs file

public static void Main(string[] args)
{
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args, ShutdownMode.OnExplicitShutdown);
}

Actually my application doesn't shut down on window close. The application will run in the background even after the icon disapers from the system tray .

@timunie
Copy link
Contributor

timunie commented Oct 6, 2023

okay got it. We will investigate further.

@Aswathips
Copy link
Author

Ok. Thank you

@Aswathips
Copy link
Author

Aswathips commented Oct 9, 2023

Hi, Is there any update.

@timunie
Copy link
Contributor

timunie commented Oct 9, 2023

No, that issue has not high priority. So don't expect us to fix it in the next few days. If you need urgend support, we offer paid support.

@dsigninfinnium
Copy link

Any Updates on This ?

@timunie
Copy link
Contributor

timunie commented Dec 18, 2023

@dsigninfinnium see comment above

@Nayjest
Copy link

Nayjest commented Dec 31, 2023

I had similar issue on Windows,
Thanks to @timunie
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown; helped (my app have no main window)

However, I suggest, it should be handled somehow by Avalonia devs, because such system behaviour doesn't feels good.

@timunie
Copy link
Contributor

timunie commented Dec 31, 2023

However, I suggest, it should be handled somehow by Avalonia devs, because such system behaviour doesn't feels good.

We cannot handle every scenario reliable in any way, so this is the way to go. I think it's a fair solution. Thanks for your understanding.

@janmechtel
Copy link

I also experience this problem on Linux. The icon disappears if I suspend the current session and then resume/login again.

Adding .StartWithClassicDesktopLifetime(args, ShutdownMode.OnExplicitShutdown); did not change anything about that behavior.

My app also runs in the background without any open windows.

@aw3-1337
Copy link

Any update on this?
Can confirm the issue is related to screen lock

@timunie
Copy link
Contributor

timunie commented Nov 19, 2024

@aw3-1337 if you have an idea where this is happening, a PR would be welcome, since you can reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants