This drops a lot of code and even though we are using a common function,
the specification of only the needed things keeps it very efficient and
even more efficient in memory and time than the previous solution.
On OpenBSD the backlight percentage cannot be retrieved in a simple way.
The only two solutions we are aware of for now are:
- reading from /dev/ttyC0: which isn't possible without changing
permissions or running slstatus as root
- linking against xcb-xrandr: which is bloat and does not work in every
case appearently
This reverts commit 37724ac2c3 for now.
- Get rid of camel-casing
- Don't use all-caps for variable names
- use LEN()-macro
- use strncmp() rather than strstr() for prefix-checking
- clean up the tokenizer-loop and don't use copies
- make the loop more readable by separating different breaking
conditions
- stricter error-checking and cleanup
- store the layout directly with bprintf rather than having
a separate buffer
Adding a new keymap component that will
indicate the current keyboard layout (language)
and variant if any was set. I use the
standard X11 XKB APIs to retrieve and parse
the xkb_symbols set with setxkbmap.
This is a first step to decouple formatting from information because of
two reasons:
1. The components should only gather and return the values by design
2. Fine grained user control should be a focus
Scaling will be implemented in a different way in a later commit.
On some laptops (mostly thinkpads), the remaining time may be
expressed in µWh using energy_now and power_now files rather than µAh
for charge_now and current_now.
Add pick function to conditionally select appropriate one.
These functions take the raw number and a unit and automatically
print it out "scaled down" to a proper SI-prefix, for powers of 2
and 10 respectively.
Apply them to the 2-power cases and keep the 10-power for a later
commit.
First dividing by interval before multiplying with 1000 decreases the
precision by +-(interval - 1) * 1000, as interval arithmetic always
applies the Gauß-function to the result.
This is not necessary and simply reordering the operations mitigates
this.