Age | Commit message (Collapse) | Author |
|
|
|
Fixes coding style. Formatting commits suck, incoherent coding style
sucks more.
https://suckless.org/coding_style/
|
|
Fixes coding style. Formatting commits suck, incoherent coding style
sucks more.
https://suckless.org/coding_style/
|
|
function prototype with unspecified argument is obsolete since c99.
additionally some of these function which don't take any argument were
being called with a `const char *` arg, which is UB.
fix both these issues by declararing ALL the components to accept a
`const char *`, and name the arg "unused" if it's meant to be ignored.
|
|
Allow slstatus to be used by programs that can grab status by calling
an external program on a periodic basis (e.g. tmux)
|
|
At some point one might want to force a refresh for example after
checking email or changing the volume. Sending a SIGUSR1 achieves this
now
|
|
|
|
This is (arguably) more elegant and it matches Xlib output logic.
Also use puts instead of printf as we don't do formating there.
|
|
|
|
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 fa8b939990ed0648f99b0cbeba4efed807160db3.
|
|
This way cases like
$ slstatus -s > /dev/full
are properly caught and the program terminated with the proper return
code.
|
|
|
|
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.
|
|
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.
|
|
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).
|
|
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.
|
|
|
|
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
|
|
|
|
|
|
|
|
func can return NULL in case of error, but no checking is done when
printing, and unknown_str wasn't being used anywhere.
|
|
|
|
|
|
For multiple reasons the program is now split:
- Make future porting to OpenBSD easier
- Assign header includes to individiual functions
- Make future program extensions easier
- Recompile only changed parts
|
|
setlocale() has to be separated from the signal handling.
|
|
I want my date & time printed according my locale settings.
This commit enables that
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
|
|
This commit introduces the cpu_iowait item, this is the percentage
of cpu time spent waiting on disks. High numbers typically indicate
that your system is not responsive due to disk IO.
This commit also avoid sleeping inside the cpu_perc and cpu_iowait
functions: waiting in either one implies lost info for the other.
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
|
|
|
|
- Renamed "ip" function to "ipv4"
- Added "ipv6" function
- Adjusted README and config.def.h accordingly
|
|
|
|
This reduces a lot of equivalent code to one function call.
|
|
We remove the hack with the sleep and global "delay"-variable and use a
monotonic clock to derive the desired monotonic properties of the tool.
Inside each function that demands a personal delay we can then just do a
nanosleep() and be done with it.
It's a shame that timespec is so ugly to work with, but there's really
no way to make it more beautiful. However, at this cost though we
finally can set the interval times in milliseconds and not only just
seconds.
We remove setlocale(), because nothing good ever came out of this
function.
Besides that we have some more code refactoring, especially in the
argument loop which saves us a bit of complexity.
|
|
|
|
|
|
|
|
Debugging #define is very difficult. The performance overhead of static const
char is negligible.
|
|
Debugging #define, especially in mathematical constructs is very
difficult. The performance overhead of static const int is negligible.
|
|
|
|
- Added a check for the return value of XOpenDisplay() in main().
This fixes a possible NULL-deref.
- Removed unnsecessary XOpenDisplay and XCloseDisplay from
keyboard_indicators(). The ones in main() are sufficent.
|
|
|
|
|
|
|
|
What we really want is to either output to WM_NAME or stdout. If we want
just one single line, we do slstatus | head -n 1.
|
|
d-flag: There's no need for that, use the &-operator or fork+exec in a
non-shell-context. In the latter case you get the PID for free.
v-flag: If you want to find out which version of a package is installed,
consult your package manager. That's his job.
|
|
We also change the semantics of -v to only return the version
information.
There is now no need for usage() to exit with anything other than 1.
|
|
|
|
|
|
|
|
|