subspace / space-acres

Space Acres is an opinionated GUI application for farming on Subspace Network
53 stars 18 forks source link

Feat/support tray icon #172

Closed hunjixin closed 2 months ago

hunjixin commented 3 months ago

program hide instead of exit when click close icon, if really want to exit, click tray icon and choose quit. when program is hide, double click tray icon to show (window work, ubuntu not work, others unknown), can also click open menu in tray icon.

Resolves https://github.com/subspace/space-acres/issues/141

hunjixin commented 3 months ago

https://github.com/subspace/space-acres/issues/141

hunjixin commented 3 months ago

This is very promising, thank you!

If you only verified it on Windows and it doesn't yet work on Linux, then Linux changes should not be included here or PR can't be merged in that case.

141

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests instead can be used instead, I edited original message.

Once comments are addressed we can merge Windows support and then probably have Ubuntu support in a separate PR (we'll need to look into dependencies as documented in betrayer to make sure correct dependencies are included in the package.

the reason I added some linux code is twofold. First, to provide a basic support, and second, to prevent potential compilation failures if it's not handled. I will work on the specific support in a separate pull request.

hunjixin commented 3 months ago

the reason I added some linux code is twofold. First, to provide a basic support, and second, to prevent potential compilation failures if it's not handled. I will work on the specific support in a separate pull request.

I understand, but ideally all PRs that are merged are ready for new release. We don't want to merge half-working or broken features. Do you think it'll be a lot of work to make it work on Linux in this PR?

i have try ubuntu, its nearly okay, just no double click event, for kde menu button show as a checkbox, but work okay, no broken at last. there are too much linux distribution, which versions need to be check? we can leave this pr until test some main linux system.

nazar-pc commented 3 months ago

i have try ubuntu, its nearly okay, just no double click event, for kde menu button show as a checkbox, but work okay, no broken at last. there are too much linux distribution, which versions need to be check? we can leave this pr until test some main linux system.

Ubuntu 22.04 and newer is what should work out of the box. Other distros and DEs are nice to have and ideally we would identify where tray icon is not supported and disable corresponding functionality.

hunjixin commented 3 months ago

i will start work for ubutu and kde. not merge this pr until complete linux work.

hunjixin commented 3 months ago

@nazar-pc i think this pr can resolve both windows and linux issue. linux has done minimal work, and betrayer is functioning well(change a little). It has been tested successfully on Ubuntu 22.04 and KDE Neon.

plan to support macos, i am worring about mac,.

nazar-pc commented 3 months ago

Please don't abuse force push this much, it is hard to follow what (if anything) you're changing

hunjixin commented 3 months ago

@nazar-pc have squash and rebase main, and i have test on win11/ubuntu22.04/ubuntu23.10

hunjixin commented 3 months ago

@abhi3700 Please test it on macos

hunjixin commented 2 months ago

@nazar-pc can this pr ready for merge? or anything to imporve?

nazar-pc commented 2 months ago

Waiting for @abhi3700 to confirm macOS is working, I thought that was the remaining issue

abhi3700 commented 2 months ago

Waiting for @abhi3700 to confirm macOS is working, I thought that was the remaining issue

Sorry for the late reply. There is no build error found on macOS. Also, no clippy issues.

nazar-pc commented 2 months ago

There is no build error found on macOS. Also, no clippy issues.

We can see that from CI, does it actually work properly on macOS when you run it?

hunjixin commented 2 months ago

@nazar-pc configure gtk fail, need i to rebase main branch

nazar-pc commented 2 months ago

Indeed, pleae do. Also switch to upstream release of betrayer if it is out already and squash everything since changes are not that large here.

EmilFattakhov commented 2 months ago

@hunjixin, we would like to thank you for your contribution! Please fill out the compliance form to claim your reward! Looking forward to your future contributions!

abhi3700 commented 2 months ago

There is no build error found on macOS. Also, no clippy issues.

We can see that from CI, does it actually work properly on macOS when you run it?

Apologise for misunderstanding.

I am not sure how it should look like. Can I have a preview from other OS so as to verify?

hunjixin commented 2 months ago

work is okay, betray not support on macos, because i and author of betrayer either have no macos, difficulty to complete this work.

abhi3700 commented 2 months ago

@hunjixin, we would like to thank you for your contribution! Please fill out the compliance form to claim your reward! Looking forward to your future contributions!

work is okay, betray not support on macos, because i and author of betrayer either have no macos, difficulty to complete this work.

@hunjixin Are you confirming tray icon is not supported on macOS or it's not checked as you don't have mac?

hunjixin commented 2 months ago

@hunjixin, we would like to thank you for your contribution! Please fill out the compliance form to claim your reward! Looking forward to your future contributions!

work is okay, betray not support on macos, because i and author of betrayer either have no macos, difficulty to complete this work.

@hunjixin Are you confirming tray icon is not supported on macOS or it's not checked as you don't have mac?

hmm, i see this code for macos https://github.com/sidit77/betrayer/blob/1dbe481a0b9512b3357e3a2ea9cb5ff6edac3b89/src/platform/macos/mod.rs#L98, https://github.com/sidit77/betrayer/blob/1dbe481a0b9512b3357e3a2ea9cb5ff6edac3b89/src/platform/macos/mod.rs#L119-L121. this code do nothing with given icon, so i think macos cannot work with feature. not sure the menu can work or not. you can see this https://github.com/subspace/space-acres/issues/142 to know the effection of this pr

abhi3700 commented 2 months ago

@hunjixin Can you please share the tray icon image preview as screenshot here for me to have an idea as to how it is supposed to look like?

hunjixin commented 2 months ago

@abhi3700 image

nazar-pc commented 2 months ago

Unfortunately this didn't work with my custom X11-based DE (I'm using Qtile WM with tint2 as the panel):

2024-04-24T00:36:39.821252Z  WARN space_acres: Unable to create tray icon  err=Os(MethodError(OwnedErrorName("org.freedesktop.DBus.Error.ServiceUnknown"), Some("The name org.kde.StatusNotifierWatcher was not provided by any .service files"), Msg { type: Error, sender: UniqueName("org.freedesktop.DBus"), reply-serial: 7, body: Signature("s"), fds: [] }))

We'll likely want to improve or replace betrayer to improve compatibility. But at least it still works as expected outside of that.

hunjixin commented 2 months ago

@nazar-pc sorry I'm not familiar with the Qtile system, but I searched through the Qtile codebase, and it seems that Qtile does support the org.kde.StatusNotifierWatcher signal, so I think the support should be fine. but I still need to dig more(on the system and the code).

nazar-pc commented 2 months ago

Maybe their bar does, but I don't use it, I use tint2 that has some kind of generic system tray that all other apps work fine with.

hunjixin commented 2 months ago

try this tool with ubunut, work fine. i need to try the tool on qtile. image

nazar-pc commented 2 months ago

I don't think it has anything to do with Qtile specifically, likely Tint2. Run Openbox or similar simple window manager and tint2 and you should be able to reproduce it.

abhi3700 commented 2 months ago

The tray looks like this on macOS:

image

I don't know where is this "TEST BUTTON" name defined 🤔 . Is it in gtk library or somewhere else?

Secondly,I noticed the tray icon goes away when switched to another application. As you can see here in image below that there is no "TEST BUTTON" when I switched to browser.

image

So, these are 2 issues on macOS related to this PR.

@nazar-pc should we open these issues separately to may be solved later?

nazar-pc commented 2 months ago

Just open one issue for macOS tray icon and describe both in there