-
-
Notifications
You must be signed in to change notification settings - Fork 717
Description
I already elaborated on this in #2405 (comment) but it deserves its own issue(s)
If possible, any module that requires some kind of hardware information (e.g. network interface name) should auto-detect these and choose a reasonable default if the user doesn't specify anything.
First, I'll present the current state. We can update this table as this is implemented in more modules.
Module | Notes | |
---|---|---|
✔️ | internal/alsa |
Uses default soundcard and Master mixer |
✔️ | internal/backlight |
Auto detection. See #2728 |
⬜ | internal/battery |
|
✔️ | internal/fs |
Uses / as fallback. See #2705 |
✔️ | internal/mpd |
No detection, but uses the standard port used by MPD |
✔️ | internal/network |
interface-type has to be defined |
✔️ | internal/pulseaudio |
Uses default sink |
✔️ | internal/temperature |
Uses thermal zone 0 by default. With #2752 can select zone by name (zone-type ) |
✔️ | internal/xbacklight |
Uses bar monitor by default |
Backlight
Here, we should just scan /sys/class/backlight/
for a directory that has the required files.
If multiple match, just chose the first one and print a notice.
Documentation: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-backlight
Battery
Scan /sys/class/power_supply/
and chose one that has the necessary files.
If multiple match, just chose the first one and print a notice.
A battery must at least have a file type
that contains Battery
to be considered.
There is also a present
file that tells us if the battery is present.
Though from my own testing, the entire directory disappears if the battery is removed.
If this file is considered, we could also have format-absent
that is used if that file is 0
, the folder doesn't exist or no battery was found.
The type
file identifies the type of device, we should only consider Battery
.
Documentation:
- https://www.kernel.org/doc/html/latest/power/power_supply_class.html
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-power
Filesystem
Scan /proc/self/mountinfo
and use all entries whose mount source (column 10) starts with /dev/
Alternatively, we could always use /
as the default.
Documentation: man 5 proc