Fuchs / hoppla-sa

Linux / KDE Plasma desktop widget to control Philips Hue lights. Controls lights, groups and customizable actions.
https://store.kde.org/p/1168067/
GNU Lesser General Public License v2.1
66 stars 6 forks source link

Hide tray icon if hue is not available #6

Closed naraesk closed 6 years ago

naraesk commented 6 years ago

Hi! Thanks for this plasmoid, it's very helpful! :-)

I'm using it in the system tray. If would be great if the icon could be hidden if no hue is available. I'm running it on a notebook and when I'm not at home the plasmoid is useless, obviously.

Should be very easy to implement. basically, you just need

Plasmoid.status: isAvailable ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus

... and a property isAvailable that indicates if a hue is available or not.

Fuchs commented 6 years ago

Hi,

I'm currently on holiday, but I'll gladly look into it afterwards, I assume it's simple indeed. Thanks for the idea.

Fuchs commented 6 years ago

I had a quick glance and try, technically it's rather easy, but there is one major downside:

right now, by design, the plasmoid does not check the connection every 30 seconds unless at least once activated by click. So I have two possibilities:

1) trigger that on load, so when it's in the systray, generating minor load on network and CPU even though the user might not even want / need it

2) check the connection once on load and set the status accordingly, with the downside of it never updating, so if it starts in hidden change you have to expand the hidden systray entries and click it once you need it.

I might opt for 1), but that requires some design changes that I am unhappy with, maybe I make a hidden config option for it, so people who want that behaviour (always check every 30 seconds, even if never clicked) can be enabled. I'll give that a few thoughts once my holidays are over

(Checking the connection on local connection changes doesn't really work either, because there might be reasons for it being unavailable that are not related to your current device, so I have to poll)

naraesk commented 6 years ago

Thanks for your answer. Do you think network and CPU usage is such a big issue? Would be really surprised if anyone would notice it. But an option would be fine, of course.

Regarding your last sentence: From my point of view it would be enough to check availability on startup and everytime the connection of the network manager is changed. I don't know if is supported by Plasma/Qt but I would expect so. The status might not be correct all the time, but it's a good guess with minimal polling.

Fuchs commented 6 years ago

Hi,

not a big issue, but I like to keep it minimal. Also I very much don't like "good guess", so what I did is the following:

1) add a config option whether it should poll, and if, how often

2) add a "basic poll" which is executed even if the plasmoid has not been fully initialized (clicked on), so you get a tooltip telling you whether it is connected (and via what connection), unconfigured or unavailable. Plasmoid status is set accordingly.

3) Change the extended poll to disable the above once set

Which combines the best of most worlds (you get your plasmoid status and even a nice tooltip) with only minor caveats (you don't get details in the tooltip such as how many lights are switched on, unless you initialize the full thing) which at the same time doesn't run the whole thing in the background all the time.

It would be great if you could test if that works for you, then I'll do some more tests next week after my holidays and, if all is fine, make a new release out of it.

Kind regards,

Fuchs

naraesk commented 6 years ago

Thanks! That's great, works as expected. However, I haven't noticed any tooltip.

Fuchs commented 6 years ago

Hover the plasmoid in the systray, it should have a two-line (title and text) tooltip as others, the text giving you some details about the connection.

I'll check if the more detailled status can be implemented without too much overkill after my holidays, in the meantime feel free to use current git head

naraesk commented 6 years ago

Nope, I don't see any tooltip when hovering over the systray icon. And I'm relatively sure that there haven't been any tooltip before your changes.

Fuchs commented 6 years ago

There is a systemsettings5 setting for that in desktop behaviour, which turns the tooltips off globally, which I think all plasmoids respect. See if that is turned off. There should be a tooltip and always should have been one,

https://imgur.com/a/t16lek7

also I just noticed that the current implementation has a bug and the basic update triggers even after the full one does, need to inspect that next week. Should not be a huge issue for you in the meantime, it only breaks the tooltip a bit.

naraesk commented 6 years ago

Indeed, I just turned this off a few days ago. Sorry!

Anyway, this issues is fixed. Thanks again, enjoy your holiday. :-)