Bug 2229562

Summary: FR: Add targets for batterystate, charging state and maybe network
Product: [Fedora] Fedora Reporter: Fedora-user <lkenfwq83r984+RHBUGS>
Component: systemdAssignee: systemd-maint
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 38CC: fedoraproject, filbranden, lnykryn, msekleta, ryncsn, systemd-maint, yuwatana, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-07 08:56:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Fedora-user 2023-08-07 02:30:03 UTC
Using udev rules you can create systemd targets for batterystate or AC-state. This is really useful, as services can then depend on these targets.

Example; only autoupdate dnf when battery is full or AC is attached.

This is even more important for "grandma devices" where you want automatic firmware updates.

Having the base targets "ac" and "battery", "battery full" and "battery empty" would make it easy for these services to be implemented or easily deployed, as they work on every system.

If it is possible to detect network states easily, this would be great too. On Android you csn safe cell data a lot, as good apps dont load images, there are no updates and all. At least automatic updates should be easy to pause on cell networks, and using a config file also other networks for example a phone hotspot.

Reproducible: Always

Actual Results:  
There are no ways to control services only running at a certain battery state or network

Expected Results:  
More control and easy possibility to depend on these markers for dependencies in systemd services

Some udev rules, maybe combined services "critical state" (low battery AND no charger) or "save state" (high battery OR low battery AND charger)

Some way to detect metered connections and also state other connections manually

Comment 1 Zbigniew Jędrzejewski-Szmek 2023-08-07 08:56:24 UTC
For RFE's, please open an upstream ticket (https://github.com/systemd/systemd/issues) or even better write to systemd-devel.org to discuss those ideas. The Fedora tracker is not the best place for such things, because most upstream developers will not see the discussion here.