Aaron Marcher [Sun, 20 May 2018 22:41:03 +0000 (00:41 +0200)]
battery_remaining: Change float to double
Aaron Marcher [Sun, 20 May 2018 22:36:59 +0000 (00:36 +0200)]
battery: Minor coding style fixes
- Line length
- Spacing and indentation
- No explicit checks for NULL
Aaron Marcher [Sun, 20 May 2018 22:29:54 +0000 (00:29 +0200)]
Increase readability for load_uvmexp return
Aaron Marcher [Sun, 20 May 2018 22:16:54 +0000 (00:16 +0200)]
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.
Aaron Marcher [Sun, 20 May 2018 22:02:33 +0000 (00:02 +0200)]
swap_perc: check for division by zero on obsd too
Aaron Marcher [Sun, 20 May 2018 21:53:26 +0000 (23:53 +0200)]
swap_perc: check for division by zero
Aaron Marcher [Sun, 20 May 2018 20:16:39 +0000 (22:16 +0200)]
Add David Demelier to LICENSE
David Demelier [Sun, 20 May 2018 07:42:16 +0000 (09:42 +0200)]
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.
Tobias Tschinkowitz [Sun, 20 May 2018 13:53:48 +0000 (15:53 +0200)]
ip: fixed memory leak
free the interface list before returning from the function
Laslo Hunhold [Sat, 19 May 2018 22:57:24 +0000 (00:57 +0200)]
Check return value of pclose()
Aaron Marcher [Sat, 19 May 2018 22:42:07 +0000 (00:42 +0200)]
Refactor ram.c
Aaron Marcher [Sat, 19 May 2018 22:30:16 +0000 (00:30 +0200)]
Make temp more readable on Linux
Laslo Hunhold [Sat, 19 May 2018 22:18:08 +0000 (00:18 +0200)]
Refactor entropy.c
Aaron Marcher [Sat, 19 May 2018 22:17:35 +0000 (00:17 +0200)]
Remove initialization to 0 for static vars
Aaron Marcher [Sat, 19 May 2018 22:16:20 +0000 (00:16 +0200)]
Remove unnecessary "valid" variable in cpu_perc
Aaron Marcher [Sat, 19 May 2018 22:02:49 +0000 (00:02 +0200)]
Add unit to temperature
Aaron Marcher [Sat, 19 May 2018 21:58:14 +0000 (23:58 +0200)]
Implement scaling for cpu_freq
Laslo Hunhold [Sat, 19 May 2018 20:52:17 +0000 (22:52 +0200)]
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.
Aaron Marcher [Sat, 19 May 2018 18:33:06 +0000 (20:33 +0200)]
Add the percent sign to *_perc functions
Units should be added to the corresponding numbers
Laslo Hunhold [Sat, 19 May 2018 18:09:38 +0000 (20:09 +0200)]
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.
Laslo Hunhold [Sat, 19 May 2018 17:33:04 +0000 (19:33 +0200)]
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.
Aaron Marcher [Sat, 19 May 2018 11:34:18 +0000 (13:34 +0200)]
Simplify ipv* functions
Aaron Marcher [Sat, 19 May 2018 11:29:21 +0000 (13:29 +0200)]
Use `int` for flags
Aaron Marcher [Sat, 19 May 2018 11:25:35 +0000 (13:25 +0200)]
Revert
aac29e2 as it is nonsense
Aaron Marcher [Sat, 19 May 2018 11:19:53 +0000 (13:19 +0200)]
Set {r,t}xbytes 0 before incrementing them on OBSD
Aaron Marcher [Sat, 19 May 2018 11:12:06 +0000 (13:12 +0200)]
Missing assignment for last commit
Aaron Marcher [Sat, 19 May 2018 11:07:05 +0000 (13:07 +0200)]
Unify and simplify netspeed logic and types
Tobias Tschinkowitz [Sat, 19 May 2018 09:23:16 +0000 (11:23 +0200)]
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.
Aaron Marcher [Fri, 18 May 2018 23:55:31 +0000 (01:55 +0200)]
uptime: Format function is static
Aaron Marcher [Fri, 18 May 2018 23:49:46 +0000 (01:49 +0200)]
battery: Move out struct as common code
Tobias Tschinkowitz [Fri, 18 May 2018 23:29:20 +0000 (01:29 +0200)]
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.
Aaron Marcher [Fri, 18 May 2018 22:40:59 +0000 (00:40 +0200)]
Add netspeeds to config.def.h
Aaron Marcher [Fri, 18 May 2018 22:31:33 +0000 (00:31 +0200)]
Add network speed functions
Aaron Marcher [Fri, 18 May 2018 21:38:59 +0000 (23:38 +0200)]
Implement fmt_scaled for ram_* functions
Aaron Marcher [Fri, 18 May 2018 21:32:00 +0000 (23:32 +0200)]
Fix ram_free for Linux
Aaron Marcher [Fri, 18 May 2018 21:19:18 +0000 (23:19 +0200)]
Implement fmt_scaled for swap_* functions
Aaron Marcher [Fri, 18 May 2018 21:14:55 +0000 (23:14 +0200)]
Implement fmt_scaled for disk_* functions
Aaron Marcher [Fri, 18 May 2018 21:14:10 +0000 (23:14 +0200)]
Add fmt_scaled util function
Aaron Marcher [Fri, 18 May 2018 17:58:51 +0000 (19:58 +0200)]
Use %d instead of accidentally %i
Aaron Marcher [Fri, 18 May 2018 15:25:09 +0000 (17:25 +0200)]
Port battery_remaining to Linux
Additionally unify the format of battery_state and uptime
Aaron Marcher [Fri, 18 May 2018 14:55:37 +0000 (16:55 +0200)]
Fix memory leak
Tobias Tschinkowitz [Fri, 18 May 2018 14:33:51 +0000 (16:33 +0200)]
battery: fixed remaining time on connected AC
when an AC is connected apm_info shows a non-valid value for remaining
minutes. it was decided that in that case the function should return an
empty string.
Aaron Marcher [Fri, 18 May 2018 13:32:15 +0000 (15:32 +0200)]
Fix indentation
Tabs for indentation, spaces for alignment
Tobias Tschinkowitz [Fri, 18 May 2018 12:43:04 +0000 (14:43 +0200)]
Add battery_remaining function on OpenBSD
Implementation of a battery_remaining function which returns the
remaining battery time in HH:MM format. Linux function still needs
implementation.
Move common code to load_apm_power_info
Laslo Hunhold [Fri, 18 May 2018 08:59:05 +0000 (10:59 +0200)]
Add warn() and die()
Given slstatus is a tool that runs in the background, most likely run
from .xinitrc, it's important to prepend the name of the tool to error
messages so it becomes clear where the error is coming from.
To make this much more consistent, this commit adds warn() and die()
utility functions consistent with other suckless projects and adapts all
calls to fprintf(stderr, *) to the warn() and die() functions, greatly
increasing the readability of the code.
Laslo Hunhold [Fri, 18 May 2018 08:07:50 +0000 (10:07 +0200)]
Audit slstatus.c
1) Remove setlocale() (locales are harmful and any 'issues' shall
be fixed in different ways that are expected).
2) Disable buffering on stdout with setbuf() rather than flushing
it each time.
3) Make error messages more consistent.
4) Add error checks where applicable.
5) Make code a bit more readable where res is assigned.
6) Use XFlush() rather than XSync() (we don't need to wait for the
XServer to react, which could lead to long hangs on our side).
Laslo Hunhold [Thu, 17 May 2018 21:23:28 +0000 (23:23 +0200)]
Properly handle *snprintf() errors
Posix guarantees that the resulting string is null-terminated, even if
we have an overflow. Instead of doing what has already been done,
properly warn when there has been an error or overflow, so the user can
do something about it.
Aaron Marcher [Thu, 17 May 2018 18:05:57 +0000 (20:05 +0200)]
Remove UNUSED macro
Use variables named unused instead which is simpler
Aaron Marcher [Thu, 17 May 2018 16:29:25 +0000 (18:29 +0200)]
Mark unused parameters, fix compiler warnings
Aaron Marcher [Thu, 17 May 2018 16:14:08 +0000 (18:14 +0200)]
wifi: Fix order and add missing header
<sys/select.h> is needed before <net80211/ieee80211_ioctl.h> on OpenBSD
to define NBBY and shut up compiler warnings.
Aaron Marcher [Thu, 17 May 2018 16:08:31 +0000 (18:08 +0200)]
wifi: Change memmove to memcpy on OpenBSD
Aaron Marcher [Thu, 17 May 2018 16:05:38 +0000 (18:05 +0200)]
Unify type of in for loops
Aaron Marcher [Thu, 17 May 2018 15:59:05 +0000 (17:59 +0200)]
wifi_essid: Fix coding style
Only initialize variables at the beginning of a block
Aaron Marcher [Thu, 17 May 2018 15:40:11 +0000 (17:40 +0200)]
Unify type of `i` in for loops
int for normal indexes
size_t for usage with the LEN macro
Aaron Marcher [Thu, 17 May 2018 15:28:32 +0000 (17:28 +0200)]
Change done to int as it is the CPU's natural type
Aaron Marcher [Thu, 17 May 2018 15:25:31 +0000 (17:25 +0200)]
Change interval to unsigned int
Aaron Marcher [Thu, 17 May 2018 15:24:47 +0000 (17:24 +0200)]
Add comments for battery_* functions on OpenBSD
Tobias Tschinkowitz [Thu, 17 May 2018 11:19:29 +0000 (13:19 +0200)]
added comment for temp function (openbsd)
Tobias Tschinkowitz [Thu, 17 May 2018 10:43:21 +0000 (12:43 +0200)]
corrected calculations for disk space on openbsd
Aaron Marcher [Wed, 16 May 2018 21:19:33 +0000 (23:19 +0200)]
Update README
Aaron Marcher [Wed, 16 May 2018 21:17:30 +0000 (23:17 +0200)]
wifi: Fix coding style
Use block for single statement ifs
When functions return -1 for error test against 0 not -1
Newlines
Aaron Marcher [Wed, 16 May 2018 21:08:33 +0000 (23:08 +0200)]
load_ieee80211_nodereq: Fix typo
Aaron Marcher [Wed, 16 May 2018 20:57:13 +0000 (22:57 +0200)]
wifi: Move out common headers
Tobias Tschinkowitz [Wed, 16 May 2018 20:37:43 +0000 (22:37 +0200)]
added wifi functionality for openbsd
display ESSID and signal strength percentage
Tobias Tschinkowitz [Wed, 16 May 2018 11:26:34 +0000 (13:26 +0200)]
corrected calculation for swap on openbsd
The swapctl(2) function fills the swapent struct with 512KB blocks.
As we want to display in GB, i just modified the calculation for this to
get the expected output.
Tobias Tschinkowitz [Wed, 16 May 2018 07:57:38 +0000 (09:57 +0200)]
consistent calculation of ram_* on openbsd
Aaron Marcher [Wed, 16 May 2018 06:13:09 +0000 (08:13 +0200)]
Add he4d to LICENSE
Tobias Tschinkowitz [Tue, 15 May 2018 22:45:41 +0000 (00:45 +0200)]
updated ram_total and ram_free (obsd)
Aaron Marcher [Mon, 14 May 2018 18:54:48 +0000 (20:54 +0200)]
Cast CPU percentage to int and fix indenation
Josuah Demangeon [Tue, 8 May 2018 13:13:56 +0000 (15:13 +0200)]
fflush(stdout) to print line by line if stdout is not a tty
To reproduce the issue:
$ slstatus -s | tee
then it would print only when the stdout buffer is full, by block
of multiple lines.
fflush() makes sure the line is printed at every loop iteration
Aaron Marcher [Tue, 8 May 2018 13:06:55 +0000 (15:06 +0200)]
Add josuah to LICENSE
Josuah Demangeon [Tue, 8 May 2018 11:42:17 +0000 (13:42 +0200)]
include <sys/time.h> before <sys/sensors.h> for time struct timeval
sys/sensors.h has two structs struct timeval: sensor and ksensor:
struct sensor {
...
struct timeval tv; /* sensor value last change time */
...
};
Aaron Marcher [Mon, 7 May 2018 13:57:32 +0000 (15:57 +0200)]
Only variable declarations at top of block
Aaron Marcher [Mon, 7 May 2018 11:48:43 +0000 (13:48 +0200)]
Fix indents (spaces for alignment)
Aaron Marcher [Mon, 7 May 2018 10:25:34 +0000 (12:25 +0200)]
wifi_perc: Simplify
Aaron Marcher [Mon, 7 May 2018 10:17:13 +0000 (12:17 +0200)]
num_files: Variable declarations at top of block
Aaron Marcher [Mon, 7 May 2018 10:14:46 +0000 (12:14 +0200)]
Fix disk_perc by casting it to int
Aaron Marcher [Mon, 7 May 2018 09:44:15 +0000 (11:44 +0200)]
disk_perc: Simplify
Aaron Marcher [Mon, 7 May 2018 09:39:59 +0000 (11:39 +0200)]
cpu: Simplify functions
Aaron Marcher [Mon, 7 May 2018 09:21:59 +0000 (11:21 +0200)]
Unify header includes
- Sort Alphabetically
- Same indentation for preprocessor clauses
Aaron Marcher [Sun, 6 May 2018 21:09:36 +0000 (23:09 +0200)]
entropy: Small fix
Aaron Marcher [Sun, 6 May 2018 20:54:32 +0000 (22:54 +0200)]
entropy: Port to OpenBSD
OpenBSD's entropy design is superior to Linux.
Aaron Marcher [Sun, 6 May 2018 20:41:56 +0000 (22:41 +0200)]
datetime: Add <stdio.h> for fprintf
Aaron Marcher [Sun, 6 May 2018 20:38:29 +0000 (22:38 +0200)]
datetime: Add error message
Aaron Marcher [Sun, 6 May 2018 20:28:56 +0000 (22:28 +0200)]
Fix coding style
- Use block for single statement ifs
- Keep lines to reasonable length (current debate as to reasonable)
- When functions return -1 for error test against 0 not -1
- Do not indent cases another level
- Do not test against NULL and 0 explicitly
- Use tabs for indentation, use spaces for alignment
Aaron Marcher [Sun, 6 May 2018 19:11:50 +0000 (21:11 +0200)]
Remove cpu_iowait
The third value from load_avg (idle) gives us almost the same
information as cpu_iowait. Plus OpenBSD does not offer an iowait value
as Linux and thus the corresponding function would not be portable.
Aaron Marcher [Sun, 6 May 2018 19:10:02 +0000 (21:10 +0200)]
cpu_perc: Documentation and readbility improvements
Aaron Marcher [Sun, 6 May 2018 15:48:37 +0000 (17:48 +0200)]
cpu_perc: Port to OpenBSD
In OpenBSD the CPU usage in percent is now computed using KERN_CPTIME
sysctl.
Aaron Marcher [Sat, 5 May 2018 23:20:46 +0000 (01:20 +0200)]
swap_*: Port to OpenBSD
Aaron Marcher [Fri, 4 May 2018 16:04:53 +0000 (18:04 +0200)]
battery: Remove full indicator
It does not respect charging thresholds and it is not trivial to
implement the indicator in OpenBSD.
Aaron Marcher [Wed, 2 May 2018 17:41:53 +0000 (19:41 +0200)]
wifi_perc: Fix file descriptor leak
Aaron Marcher [Wed, 2 May 2018 10:30:16 +0000 (12:30 +0200)]
Add examples to config.def.h
Aaron Marcher [Wed, 2 May 2018 10:08:54 +0000 (12:08 +0200)]
uptime: Add missing brace
parazyd [Wed, 2 May 2018 09:38:27 +0000 (11:38 +0200)]
volume: Cast SOUND_MIXER_READ_DEVMASK to int to avoid warning.
Aaron Marcher [Wed, 2 May 2018 06:49:06 +0000 (08:49 +0200)]
wifi: Various cleanups
Aaron Marcher [Wed, 2 May 2018 06:42:55 +0000 (08:42 +0200)]
user: Only declare variables in the beginning
Aaron Marcher [Wed, 2 May 2018 06:41:06 +0000 (08:41 +0200)]
uptime: Simplifiy and clean up
Aaron Marcher [Wed, 2 May 2018 06:29:36 +0000 (08:29 +0200)]
run_command: Clean up
Aaron Marcher [Wed, 2 May 2018 06:26:23 +0000 (08:26 +0200)]
keyboard_indicators: Clean up opening display
Aaron Marcher [Wed, 2 May 2018 06:21:32 +0000 (08:21 +0200)]
ip: Sort headers alphabetically