13 Commits (ec5c35ec9f23254f09e734d0c1880559774dfa52)

Author SHA1 Message Date
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.
8 years ago
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.
8 years ago
Aaron Marcher 74c4f4ebda Add the percent sign to *_perc functions
Units should be added to the corresponding numbers
8 years ago
Aaron Marcher b3e56066ed Implement fmt_scaled for disk_* functions 8 years ago
Laslo Hunhold 80fc20d1d6 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.
8 years ago
Tobias Tschinkowitz 0f46c675d3 corrected calculations for disk space on openbsd 8 years ago
Aaron Marcher 6123f482e3 Fix indents (spaces for alignment) 8 years ago
Aaron Marcher dcffaeaf57 Fix disk_perc by casting it to int 8 years ago
Aaron Marcher 4fc4983502 disk_perc: Simplify 8 years ago
Aaron Marcher ee5ec75621 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
8 years ago
Aaron Marcher faa52bdcc0 Format error messages properly
Make use of strerror(errno) and format all errors equally:
function ['parameters']: error message
8 years ago
Aaron Marcher 96f3a8a54e Get rid of err.h as it is not portable
Replace warn() and warnx() with fprintf() and add <stdio.h> where
necessary.
8 years ago
Laslo Hunhold 7246dc4381
Move components into dedicated subdirectory
This brings us a lot more tidiness.
8 years ago