Commit graph

600 commits

Author SHA1 Message Date
Aaron Marcher
cf2b604507 Add Michael Buch to LICENSE 2018-05-23 10:12:20 +02:00
Michael Buch
943b42de05 Add keymap component
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.
2018-05-23 10:09:13 +02:00
Laslo Hunhold
57f69e900b Remove o-flag as it is redundant
Even if we extend the flag to be an n-flag with a numerical input, we
already have other Unix-tools to take care of us much more flexibly,
e.g. with head(1) you can easily get the first 10 outputs with

	slstatus -s | head -n 10,

but also e.g. discard the first one and then get the consecutive 10
outputs.

For the X11-root-window-name, you can limit the runtime with timeout(1)
or a comparable solution.

This reverts commit fa8b939990.
2018-05-22 13:27:11 +02:00
Laslo Hunhold
9c9ce8a125 Check printf() for output errors
This way cases like

	$ slstatus -s > /dev/full

are properly caught and the program terminated with the proper return
code.
2018-05-22 13:25:47 +02:00
Aaron Marcher
825f637e20 netspeeds: Fix indentation 2018-05-22 12:42:31 +02:00
David Demelier
37724ac2c3 Add basic backlight percentage support
At the moment linux only, but will add support for OpenBSD as well.
2018-05-22 12:40:31 +02:00
Aaron Marcher
cbbf59fd3d Change to fmt_human in netspeeds on OpenBSD
Thanks to Hiltjo
2018-05-22 12:21:52 +02:00
Laslo Hunhold
7f91ce265e swap.c: Refactor getstats() and its usage
Add a return value so we are able to check any errors and actually fail
when there has been a critical error instead of carrying on uselessly.
2018-05-21 23:05:39 +02:00
Laslo Hunhold
ceb13206a4 Refactor fmt_human() and fix a bug
It is not necessary to copy memory or anything. Just keep a pointer to
the active prefix-array and assign the length of the arrays to a
variable.

Make the code more readable by using a switch, be more strict when an
invalid base is passed to it and fix a small oversight in the bottom of
the code where the base 1024 was forgotten to generalized.
2018-05-21 20:28:57 +02:00
Aaron Marcher
10dbc9543e Merge fmt_human_2 and fmt_human_10 to one function
Now only one function, fmt_human, takes an additional argument "base".
2018-05-21 14:44:21 +02:00
Aaron Marcher
fc0dde5a60 Remove fmt from load_avgs for consistency
In a later commit something like that will be enabled for every
component
2018-05-21 14:14:45 +02:00
Aaron Marcher
fa8b939990 Add option to output only once and exit 2018-05-21 14:07:41 +02:00
Aaron Marcher
aa8654795d battery_remaining: check for division by zero 2018-05-21 00:42:06 +02:00
Aaron Marcher
a546d4b585 battery_remaining: Change float to double 2018-05-21 00:41:03 +02:00
Aaron Marcher
103945e7bb battery: Minor coding style fixes
- Line length
- Spacing and indentation
- No explicit checks for NULL
2018-05-21 00:38:13 +02:00
Aaron Marcher
bae576cd22 Increase readability for load_uvmexp return 2018-05-21 00:29:54 +02:00
Aaron Marcher
ec5c35ec9f Remove units from numbers
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.
2018-05-21 00:16:54 +02:00
Aaron Marcher
4bd234c7ef swap_perc: check for division by zero on obsd too 2018-05-21 00:02:33 +02:00
Aaron Marcher
806815778f swap_perc: check for division by zero 2018-05-20 23:53:26 +02:00
Aaron Marcher
d8ce4e6942 Add David Demelier to LICENSE 2018-05-20 22:16:39 +02:00
David Demelier
f386a03a20 Support energy_now/power_now in battery_remaining
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.
2018-05-20 22:12:44 +02:00
Tobias Tschinkowitz
1cd8a7b510 ip: fixed memory leak
free the interface list before returning from the function
2018-05-20 22:06:54 +02:00
Laslo Hunhold
b640cc489b Check return value of pclose() 2018-05-20 01:01:26 +02:00
Aaron Marcher
c12b9cc50b Refactor ram.c 2018-05-20 00:42:07 +02:00
Aaron Marcher
7873b3b132 Make temp more readable on Linux 2018-05-20 00:30:16 +02:00
Laslo Hunhold
951ea4e304 Refactor entropy.c 2018-05-20 00:19:52 +02:00
Aaron Marcher
3f45a5f7ca Remove initialization to 0 for static vars 2018-05-20 00:17:35 +02:00
Aaron Marcher
a7ade0dc6d Remove unnecessary "valid" variable in cpu_perc 2018-05-20 00:16:20 +02:00
Aaron Marcher
062f33f874 Add unit to temperature 2018-05-20 00:02:49 +02:00
Aaron Marcher
0bc6855741 Implement scaling for cpu_freq 2018-05-19 23:58:14 +02:00
Laslo Hunhold
46c4540dd2 Implement fmt_human_2() and fmt_human_10()
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.
2018-05-19 22:58:21 +02:00
Aaron Marcher
74c4f4ebda Add the percent sign to *_perc functions
Units should be added to the corresponding numbers
2018-05-19 20:33:06 +02:00
Laslo Hunhold
68a3902dc5 Increase precision in netspeeds.c
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.
2018-05-19 20:14:09 +02:00
Laslo Hunhold
422cadfd5f Implement esnprintf() and make formatted calls more efficient
Within the components, snprintf() was unchecked and had inefficient
calls in some places.
We implement esnprintf() that does all the dirty laundry for us
and use it exclusively now.
2018-05-19 19:44:02 +02:00
Aaron Marcher
f31b113e7e Simplify ipv* functions 2018-05-19 13:34:18 +02:00
Aaron Marcher
d47d78255e Use int for flags 2018-05-19 13:29:21 +02:00
Aaron Marcher
74891945d8 Revert aac29e2 as it is nonsense 2018-05-19 13:25:35 +02:00
Aaron Marcher
06d4447f03 Set {r,t}xbytes 0 before incrementing them on OBSD 2018-05-19 13:19:53 +02:00
Aaron Marcher
a37224bf7b Missing assignment for last commit 2018-05-19 13:12:06 +02:00
Aaron Marcher
e3ccac3298 Unify and simplify netspeed logic and types 2018-05-19 13:07:05 +02:00
Tobias Tschinkowitz
2321aecff0 netspeeds: added error condition for openbsd
implemented additional error condition for openbsd netstat in case the
interface could not be found in the interface list or if_data is not
readable.
2018-05-19 12:20:25 +02:00
Aaron Marcher
0383146e5e uptime: Format function is static 2018-05-19 01:55:31 +02:00
Aaron Marcher
aac29e2bba battery: Move out struct as common code 2018-05-19 01:49:46 +02:00
Tobias Tschinkowitz
22175f0d57 implemented openbsd netspeed functions
implemented the netspeed functionality for openbsd.
furthermore the static keyword was removed of the interval variable in
config.def.h for usage as extern variable.
2018-05-19 01:44:36 +02:00
Aaron Marcher
176d8ff874 Add netspeeds to config.def.h 2018-05-19 00:40:59 +02:00
Aaron Marcher
0d05b3d13d Add network speed functions 2018-05-19 00:31:33 +02:00
Aaron Marcher
d0c68989cd Implement fmt_scaled for ram_* functions 2018-05-18 23:38:59 +02:00
Aaron Marcher
49d1e5fae2 Fix ram_free for Linux 2018-05-18 23:32:00 +02:00
Aaron Marcher
39ee31c242 Implement fmt_scaled for swap_* functions 2018-05-18 23:19:18 +02:00
Aaron Marcher
b3e56066ed Implement fmt_scaled for disk_* functions 2018-05-18 23:14:55 +02:00