summaryrefslogtreecommitdiff
path: root/slstatus.c
AgeCommit message (Collapse)Author
2023-05-16Add back version flag to prepare for releaseHEADmasterdrkhsh
2022-10-28radical re-formatting 2/3: Fix blocksdrkhsh
Fixes coding style. Formatting commits suck, incoherent coding style sucks more. https://suckless.org/coding_style/
2022-10-28radical re-formatting 1/3: Fix spacingdrkhsh
Fixes coding style. Formatting commits suck, incoherent coding style sucks more. https://suckless.org/coding_style/
2022-10-27do not rely on obsolete featureNRK
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.
2020-11-30Add a -1 option flagDaniel Moch
Allow slstatus to be used by programs that can grab status by calling an external program on a periodic basis (e.g. tmux)
2020-11-30Handle SIGUSR1 for forced refreshesMart Lubbers
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
2018-07-08Consistency with 80 char limit and breaksAaron Marcher
2018-05-29Flush the output stream instead of arbitrarily disabling bufferingQuentin Rameau
This is (arguably) more elegant and it matches Xlib output logic. Also use puts instead of printf as we don't do formating there.
2018-05-27Use E-notation for large powers of 10Laslo Hunhold
2018-05-22Remove o-flag as it is redundantLaslo Hunhold
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.
2018-05-22Check printf() for output errorsLaslo Hunhold
This way cases like $ slstatus -s > /dev/full are properly caught and the program terminated with the proper return code.
2018-05-21Add option to output only once and exitAaron Marcher
2018-05-19Implement esnprintf() and make formatted calls more efficientLaslo Hunhold
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-18Add warn() and die()Laslo Hunhold
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.
2018-05-18Audit slstatus.cLaslo Hunhold
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).
2018-05-17Properly handle *snprintf() errorsLaslo Hunhold
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.
2018-05-17Change done to int as it is the CPU's natural typeAaron Marcher
2018-05-08fflush(stdout) to print line by line if stdout is not a ttyJosuah Demangeon
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
2018-05-07Only variable declarations at top of blockAaron Marcher
2018-03-28Remove program name from error messagesAaron Marcher
2018-03-28Remove unnecessary headersAaron Marcher
2018-02-17Print unknown_str in case of errorSiIky
func can return NULL in case of error, but no checking is done when printing, and unknown_str wasn't being used anywhere.
2017-09-17Properly declare buf as extern and fix all unused-warningsLaslo Hunhold
2017-09-17Rewrite Makefile to accomodate file splitLaslo Hunhold
2017-09-17Split into multiple filesAaron Marcher
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
2017-09-16Add blank line after setlocaleAaron Marcher
setlocale() has to be separated from the signal handling.
2017-09-16slstatus: set localeKurt Van Dijck
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>
2017-09-16slstatus: add cpu_iowaitKurt Van Dijck
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>
2017-09-10slstatus load_avg format stringKamil CholewiƄski
2017-08-14Added IPv6 address functionAaron Marcher
- Renamed "ip" function to "ipv4" - Added "ipv6" function - Adjusted README and config.def.h accordingly
2017-08-14Fix a little logic errorLaslo Hunhold
2017-08-14Add pscanf()Laslo Hunhold
This reduces a lot of equivalent code to one function call.
2017-08-13Refactor main()Laslo Hunhold
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.
2017-08-13Simplify signal handling a bitLaslo Hunhold
2017-08-13Remove unnecessary prototypesLaslo Hunhold
2017-08-13Remove unnecessary blank lines after license-noticeLaslo Hunhold
2017-08-12Removed #define for unknown_strAaron Marcher
Debugging #define is very difficult. The performance overhead of static const char is negligible.
2017-08-12Removed #define for update intervalAaron Marcher
Debugging #define, especially in mathematical constructs is very difficult. The performance overhead of static const int is negligible.
2017-08-12keyboard_indicators: fix segfault when -s is specifiedAli H. Fardan
2017-08-11Fixed possible NULL-deref and removed unnecessary XOpenDisplay()Aaron Marcher
- 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.
2017-08-11Add and use LEN() macroLaslo Hunhold
2017-08-11Refactor battery_state()Laslo Hunhold
2017-08-10Print usage() when we are left with argumentsLaslo Hunhold
2017-08-10Reduce -o | -n to -sLaslo Hunhold
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.
2017-08-10Remove d- and v-flagsLaslo Hunhold
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.
2017-08-10Convert slstatus.1 to mandoc, simplify it and remove -hLaslo Hunhold
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.
2017-08-06add num_files() function for maildirs ;)aaron marcher
2017-06-13check for fgets/fscanf return valuesAaron Marcher
2017-06-13use a static buffer instead of dynamic memoryAaron Marcher
2017-06-12remove format characters from stat functionsAaron Marcher