Closed MidnightNerd closed 3 years ago
That's a good point. @MidnightNerd could you turn this into a PR?
I think the problem you mentioned would be OK, since upgrades happen every day. There would be no need to react to power coming back, we'd just skip days when power is on battery.
@clefebvre Eh, I think this could be a problem. I have a laptop that I use primarily on battery, so having the laptop plugged in and powered on at the specific update check time would be pretty rare. (I would not enable automatic updates on such a laptop in the first place, but that's not the point).
Does the update manager at least still show a tray icon when automatic updates are enabled, but they are ignored or fail to run ? That would be a simple fix for both this and #669.
I could add a notification to show when updates aren't applied due to run on battery. However i think some people find this behaviour annoying as notifications are very visible. Additionally i would also check whether the connection is metered before applying updates.
If the tray icon still indicates available updates when automatic updates are skipped (whether due to battery or other reasons), there is no need for additional notifications really.
I'm just thinking about it now, but maybe a setting to skip automatic updates under a certain battery threshold would be a more flexible option instead ? Dunno if this would be worth the hassle though.
Oh also, if this is implemented using systemd timers (I'm pretty sure it is ?), surely there should be a way to trigger these when the device is plugged again, isn't there ? That would prevent the problem you mentioned. (I'm no systemd expert though, lol)
The tray icon is independent from the automatic upgrades script. So updates are indicated in tray if they are available. But there's no indication about the reason. So the tray icon only say "x updates available". I'm also no systemd expert, so i can't tell you whether systemd can trigger the service when power is connected.
A different solution would be using dbus. This would make it also possible to check whether the network connection is metered. The Idea is to connect to "org.freedesktop.NetworkManager" and "org.freedesktop.UPower" PropertiesChanged signal and check whether the conditions to run automatic upgrades are fullfilled.
Of course it is implemented with systemd timers.
A Battery threshold would also be possible. Don't know if it the setting is right placed in the upgrade manager as it should also could be placed in the Energy Options.
Nah, not in the power options; this is a Mintupdate specific thing, not a general Cinnamon setting.
Ideally I think we'd want to hide the tray icon when automatic updates are enabled, unless said updates fail or are skipped. This would avoid confusion for users who don't know that the tray icon and automatic updates run on different schedules.
It would probably be useful in the case of automatic downloads, too. But that's probably a separate issue :slightly_smiling_face:
I'm unsure if that's really a problem, but i want to make sure that i don't bring bugs into linux mint. What is if a notebook can be charged with more than one source? (e.g. USB PD) In this case "/sys/class/power_supply/AC/online" could indicate that there's no charger connected but the notebook is charged with USB PD. The question is: Is it possible to have a notebook connected to a charger with "/sys/class/power_supply/AC/online" = 0
If "/sys/class/power_supply/AC/online" doesn't exists updates will simply be applied but if it exists and indicates 0 when a charger is connected automatic updates may never be applied.
I can't check this as i don't have a notebook with this capabilities.
I checked the behavior on a notebook and AC/online is 1 everything is ok.
I don't know about that. @clefebvre ?
Again, this problem isn't a possibility if we check the battery level instead, which IMO might be a better option (the chances of the updates kicking while the computer is on and charging seems pretty low, while updating when the battery is ie. above 50% seems perfectly reasonable to me)
@Lurux The battery level is sometimes no good solution. Think of someone who uses the computer for a longer time with no charger. The energy could be too less at the end of the day due to updates.
The best solution in my opinion is to connect to UPower via DBus and make the battery level configurable in MintUpdate. If there's a handler for the UPower "PropertiesChanged" signal this could be used also to apply updates when a power supply is attached.
The best solution in my opinion is to connect to UPower via DBus and make the battery level configurable in MintUpdate.
Yeah of course the battery level would be configurable, that makes sense.
If there's a handler for the UPower "PropertiesChanged" signal this could be used also to apply updates when a power supply is attached.
That would be epic !
Btw, sorry i can't help much with this but I'm not too technical with Linux yet so for now I'll stick to working on the GUI side of things :smile:
I wrote a script that uses dbus to connect to UPower and NetworkManager. This enables waiting for power supply or unmetered network connection to reappear. Can someone take a look at the script?
If you have questions please ask.
Sorry I can't help with that, you'll probably need to see this with clefebvre or mtwebster :slightly_smiling_face:
The automated updates shouldn't be applied when the computer is in battery mode.
A solution would be to check whether cat /sys/class/power_supply/AC/online returns 1. as Python bool: open("/sys/class/power_supply/AC/online").read()[0]=='1'
If battery mode is checked in automatic_upgrades script, the problem is, that the script isn't executed again, when the computer is connected with a power supply.
Thank You.