suckless/slstatus.git
6 years agoFix disk_perc by casting it to int
Aaron Marcher [Mon, 7 May 2018 10:14:46 +0000 (12:14 +0200)]
Fix disk_perc by casting it to int

6 years agodisk_perc: Simplify
Aaron Marcher [Mon, 7 May 2018 09:44:15 +0000 (11:44 +0200)]
disk_perc: Simplify

6 years agocpu: Simplify functions
Aaron Marcher [Mon, 7 May 2018 09:39:59 +0000 (11:39 +0200)]
cpu: Simplify functions

6 years agoUnify header includes
Aaron Marcher [Mon, 7 May 2018 09:21:59 +0000 (11:21 +0200)]
Unify header includes

- Sort Alphabetically
- Same indentation for preprocessor clauses

6 years agoentropy: Small fix
Aaron Marcher [Sun, 6 May 2018 21:09:36 +0000 (23:09 +0200)]
entropy: Small fix

6 years agoentropy: Port to OpenBSD
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.

6 years agodatetime: Add <stdio.h> for fprintf
Aaron Marcher [Sun, 6 May 2018 20:41:56 +0000 (22:41 +0200)]
datetime: Add <stdio.h> for fprintf

6 years agodatetime: Add error message
Aaron Marcher [Sun, 6 May 2018 20:38:29 +0000 (22:38 +0200)]
datetime: Add error message

6 years agoFix coding style
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

6 years agoRemove cpu_iowait
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.

6 years agocpu_perc: Documentation and readbility improvements
Aaron Marcher [Sun, 6 May 2018 19:10:02 +0000 (21:10 +0200)]
cpu_perc: Documentation and readbility improvements

6 years agocpu_perc: Port to OpenBSD
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.

6 years agoswap_*: Port to OpenBSD
Aaron Marcher [Sat, 5 May 2018 23:20:46 +0000 (01:20 +0200)]
swap_*: Port to OpenBSD

6 years agobattery: Remove full indicator
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.

6 years agowifi_perc: Fix file descriptor leak
Aaron Marcher [Wed, 2 May 2018 17:41:53 +0000 (19:41 +0200)]
wifi_perc: Fix file descriptor leak

6 years agoAdd examples to config.def.h
Aaron Marcher [Wed, 2 May 2018 10:30:16 +0000 (12:30 +0200)]
Add examples to config.def.h

6 years agouptime: Add missing brace
Aaron Marcher [Wed, 2 May 2018 10:08:54 +0000 (12:08 +0200)]
uptime: Add missing brace

6 years agovolume: Cast SOUND_MIXER_READ_DEVMASK to int to avoid warning.
parazyd [Wed, 2 May 2018 09:38:27 +0000 (11:38 +0200)]
volume: Cast SOUND_MIXER_READ_DEVMASK to int to avoid warning.

6 years agowifi: Various cleanups
Aaron Marcher [Wed, 2 May 2018 06:49:06 +0000 (08:49 +0200)]
wifi: Various cleanups

6 years agouser: Only declare variables in the beginning
Aaron Marcher [Wed, 2 May 2018 06:42:55 +0000 (08:42 +0200)]
user: Only declare variables in the beginning

6 years agouptime: Simplifiy and clean up
Aaron Marcher [Wed, 2 May 2018 06:41:06 +0000 (08:41 +0200)]
uptime: Simplifiy and clean up

6 years agorun_command: Clean up
Aaron Marcher [Wed, 2 May 2018 06:29:36 +0000 (08:29 +0200)]
run_command: Clean up

6 years agokeyboard_indicators: Clean up opening display
Aaron Marcher [Wed, 2 May 2018 06:26:23 +0000 (08:26 +0200)]
keyboard_indicators: Clean up opening display

6 years agoip: Sort headers alphabetically
Aaron Marcher [Wed, 2 May 2018 06:21:32 +0000 (08:21 +0200)]
ip: Sort headers alphabetically

6 years agobattery_state: Unify unknown state with "?" symbol
Aaron Marcher [Wed, 2 May 2018 06:16:21 +0000 (08:16 +0200)]
battery_state: Unify unknown state with "?" symbol

6 years agoUpdate README todo
Aaron Marcher [Tue, 1 May 2018 19:05:50 +0000 (21:05 +0200)]
Update README todo

6 years agoRemove battery_power for various reasons
Aaron Marcher [Tue, 1 May 2018 19:01:25 +0000 (21:01 +0200)]
Remove battery_power for various reasons

- Battery power cannot be easily gatherable via apm(4)
- IMHO it does not represent essential information

6 years agoTweak build system a little bit
Laslo Hunhold [Tue, 1 May 2018 18:50:53 +0000 (20:50 +0200)]
Tweak build system a little bit

Be consistent with brackets and add a comment for OpenBSD to make it
clearer what the actual intent of the uncommented line is.

In the Makefile, add a dependency of slstatus.o from config.mk.

6 years agobattery_perc: Port to OpenBSD
Aaron Marcher [Tue, 1 May 2018 18:45:29 +0000 (20:45 +0200)]
battery_perc: Port to OpenBSD

6 years agocomponents/swap.c | move duplicated code to separate function
Laslo Hunhold [Tue, 1 May 2018 18:20:58 +0000 (20:20 +0200)]
components/swap.c | move duplicated code to separate function

6 years agoUse indentation to increase readability
Laslo Hunhold [Tue, 1 May 2018 17:01:22 +0000 (19:01 +0200)]
Use indentation to increase readability

Granted, this style is definitely not common, but for the short
utility-functions of this program it's just the right choice. This
provides great flexibility, such that in the long run, it will be
possible to also share code between the OS-implementations.

This also keeps the state-keeping at a minimum and makes it clearer
which functions are implemented on which OS without having to jiggle
around with too many files in the process.

6 years agoRevert component-split
Laslo Hunhold [Tue, 1 May 2018 16:10:39 +0000 (18:10 +0200)]
Revert component-split

this reverts the commits from 92ab9ef52ebcb097add97d9f78e67ad1c1d6a6ec up to
d42870d6ca7fb587b38f8cf6d6821ae33a53a696.

After heavy consideration, the component split has more disadvantages
than advantages, especially given there will be utility-functions
sharing quite a lot of code that would then need to be duplicated, as it
does not fit into the util.c due to its speciality.

One big advantage of the component-wise build is readability, and
without doubt, this was achieved here. This point will be addressed
with a different approach that will be visible in the upcoming commits.

One big disadvantage of the component build is the fact that it
introduces state to the build process which is not necessary. Before its
introduction, the only influencing factors where the system-defines
__linux__ and __OpenBSD__. With the components, we are also relying on
the output of uname(1).
Additionally, if the os.mk is not present, make gives the output

     $ make
     Makefile:5: os.mk: No such file or directory
     make: *** No rule to make target 'os.mk'.  Stop.

This could easily be fixed by providing some sort of meta-rule for this
file, however, it indicates the problem we have here, and this entire
statefulness will heavily complicate packaging of this tool and makes
the build process much more complex than it actually has to be.

6 years agoMakefile: add distclean target
Quentin Rameau [Mon, 30 Apr 2018 14:14:05 +0000 (16:14 +0200)]
Makefile: add distclean target

6 years agoMakefile: move OS-specific libs to configure script
Quentin Rameau [Mon, 30 Apr 2018 14:13:12 +0000 (16:13 +0200)]
Makefile: move OS-specific libs to configure script

6 years agoMakefile: separate default flags from user flags
Quentin Rameau [Mon, 30 Apr 2018 14:11:45 +0000 (16:11 +0200)]
Makefile: separate default flags from user flags

6 years agoUpdate LICENSE for Quentin Rameau
Aaron Marcher [Mon, 30 Apr 2018 13:44:41 +0000 (15:44 +0200)]
Update LICENSE for Quentin Rameau

6 years agowifi: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:39 +0000 (15:14 +0200)]
wifi: OS split

6 years agouptime: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:38 +0000 (15:14 +0200)]
uptime: OS split

6 years agotemperature: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:37 +0000 (15:14 +0200)]
temperature: OS split

6 years agoswap: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:36 +0000 (15:14 +0200)]
swap: OS split

6 years agoram: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:35 +0000 (15:14 +0200)]
ram: OS split

6 years agoentropy: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:34 +0000 (15:14 +0200)]
entropy: OS split

6 years agocpu: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:33 +0000 (15:14 +0200)]
cpu: OS split

6 years agobattery: OS split
Quentin Rameau [Mon, 30 Apr 2018 13:14:32 +0000 (15:14 +0200)]
battery: OS split

6 years agoMakefile: detect running OS
Quentin Rameau [Mon, 30 Apr 2018 13:14:31 +0000 (15:14 +0200)]
Makefile: detect running OS

6 years agocpu_freq: Port to OpenBSD
Aaron Marcher [Mon, 30 Apr 2018 11:20:24 +0000 (13:20 +0200)]
cpu_freq: Port to OpenBSD

In OpenBSD CPU frequency gets fetched using sysctl now.

6 years agoFix typo in temperature
Aaron Marcher [Sun, 29 Apr 2018 20:44:09 +0000 (22:44 +0200)]
Fix typo in temperature

6 years agoUpdate README for OpenBSD build
Aaron Marcher [Sun, 29 Apr 2018 20:33:15 +0000 (22:33 +0200)]
Update README for OpenBSD build

6 years agouptime: Separate function for readbility
Aaron Marcher [Sun, 29 Apr 2018 18:07:09 +0000 (20:07 +0200)]
uptime: Separate function for readbility

6 years agobattery: Separate function for readbility
Aaron Marcher [Sun, 29 Apr 2018 18:02:42 +0000 (20:02 +0200)]
battery: Separate function for readbility

6 years agoram: Move up includes
Aaron Marcher [Sun, 29 Apr 2018 18:00:38 +0000 (20:00 +0200)]
ram: Move up includes

6 years agoSort LICENSE according to first commit
Aaron Marcher [Sun, 29 Apr 2018 16:50:44 +0000 (18:50 +0200)]
Sort LICENSE according to first commit

6 years agotemp: Port to OpenBSD
Aaron Marcher [Sun, 29 Apr 2018 16:35:41 +0000 (18:35 +0200)]
temp: Port to OpenBSD

In OpenBSD temperature gets fetched using sysctl now.

6 years agoRemove vol_perc() from todo in README
Aaron Marcher [Sun, 29 Apr 2018 14:08:45 +0000 (16:08 +0200)]
Remove vol_perc() from todo in README

6 years agoUpdate LICENSE for parazyd
Aaron Marcher [Sun, 29 Apr 2018 14:05:53 +0000 (16:05 +0200)]
Update LICENSE for parazyd

6 years agoAdd OpenBSD support in volume.c
parazyd [Sun, 29 Apr 2018 13:41:18 +0000 (15:41 +0200)]
Add OpenBSD support in volume.c

6 years agoUpdate LICENSE for Ali H. Fardan
Aaron Marcher [Sun, 29 Apr 2018 11:02:08 +0000 (13:02 +0200)]
Update LICENSE for Ali H. Fardan

6 years agoRemove ipv{4,6}() from todo in README
Aaron Marcher [Sun, 29 Apr 2018 11:00:12 +0000 (13:00 +0200)]
Remove ipv{4,6}() from todo in README

6 years agoip: add OpenBSD support
Ali H. Fardan [Sun, 29 Apr 2018 07:55:38 +0000 (10:55 +0300)]
ip: add OpenBSD support

ip.c already works on OpenBSD, it's just missing some headers:

6 years agoRemove non-portable functions from config.def.h
Aaron Marcher [Mon, 16 Apr 2018 17:09:07 +0000 (19:09 +0200)]
Remove non-portable functions from config.def.h

6 years agoAdd Darron Anderson to LICENSE
Aaron Marcher [Sat, 14 Apr 2018 17:44:54 +0000 (19:44 +0200)]
Add Darron Anderson to LICENSE

Thank you for your contribution.

6 years agoRemove ram_*() from README
Aaron Marcher [Sat, 14 Apr 2018 17:44:25 +0000 (19:44 +0200)]
Remove ram_*() from README

6 years agoAdd OpenBSD RAM stats
Darron Anderson [Sat, 14 Apr 2018 09:41:35 +0000 (09:41 +0000)]
Add OpenBSD RAM stats

6 years agoFormat error messages properly
Aaron Marcher [Wed, 28 Mar 2018 17:46:27 +0000 (19:46 +0200)]
Format error messages properly

Make use of strerror(errno) and format all errors equally:
function ['parameters']: error message

6 years agoRemove program name from error messages
Aaron Marcher [Wed, 28 Mar 2018 16:49:27 +0000 (18:49 +0200)]
Remove program name from error messages

6 years agoGet rid of err.h as it is not portable
Aaron Marcher [Wed, 28 Mar 2018 16:26:56 +0000 (18:26 +0200)]
Get rid of err.h as it is not portable

Replace warn() and warnx() with fprintf() and add <stdio.h> where
necessary.

6 years agoRemove unnecessary headers
Aaron Marcher [Wed, 28 Mar 2018 16:14:08 +0000 (18:14 +0200)]
Remove unnecessary headers

6 years agoRemove ALSA dependency from README
Aaron Marcher [Mon, 26 Mar 2018 16:09:30 +0000 (18:09 +0200)]
Remove ALSA dependency from README

ALSA is not a dependency anymore as we use /dev/mixer. The corresponding
notice about PulseAudio is thus not necessary too.

6 years agoMore robust preprocessor switches
Aaron Marcher [Wed, 21 Mar 2018 11:21:37 +0000 (12:21 +0100)]
More robust preprocessor switches

Replace #ifdef with #if defined() and #elif with #elif defined() as it
should only test if it is defined or not.

6 years agouptime: Port to OpenBSD.
Aaron Marcher [Mon, 19 Mar 2018 23:48:10 +0000 (00:48 +0100)]
uptime: Port to OpenBSD.

In OpenBSD uptime gets fetched using sysctl now.

6 years agobattery_perc: Port to OpenBSD.
Aaron Marcher [Mon, 19 Mar 2018 17:44:52 +0000 (18:44 +0100)]
battery_perc: Port to OpenBSD.

In OpenBSD battery percentage gets fetched using apm now.

6 years agoREADME: Add list of non-portable functions
Aaron Marcher [Sun, 18 Mar 2018 22:30:54 +0000 (23:30 +0100)]
README: Add list of non-portable functions

6 years agoBuild Linux-only functions only on Linux
Aaron Marcher [Sun, 18 Mar 2018 22:26:13 +0000 (23:26 +0100)]
Build Linux-only functions only on Linux

6 years agoREADME: Add Todo
Aaron Marcher [Sun, 18 Mar 2018 21:51:51 +0000 (22:51 +0100)]
README: Add Todo

6 years agoMerge pull request #43 from SiIky/unknown_str
Aaron Marcher [Sat, 17 Feb 2018 20:00:04 +0000 (20:00 +0000)]
Merge pull request #43 from SiIky/unknown_str

Print unknown_str in case of error

6 years agoPrint unknown_str in case of error
SiIky [Sat, 17 Feb 2018 18:08:27 +0000 (18:08 +0000)]
Print unknown_str in case of error

func can return NULL in case of error, but no checking is done when
printing, and unknown_str wasn't being used anywhere.

6 years agoUpdate LICENSE year for myself.
Aaron Marcher [Sat, 6 Jan 2018 22:40:05 +0000 (23:40 +0100)]
Update LICENSE year for myself.

6 years agoFix a bug in wifi_essid().
Aaron Marcher [Sat, 6 Jan 2018 22:37:09 +0000 (23:37 +0100)]
Fix a bug in wifi_essid().

When an invalid interface name is passed to wifi_essid() it does not
close opened sockets.

6 years agoSmall fixes in config.mk
Aaron Marcher [Sun, 3 Dec 2017 00:40:38 +0000 (01:40 +0100)]
Small fixes in config.mk

6 years agoUpdate LICENSE for parazyd
Aaron Marcher [Tue, 24 Oct 2017 09:23:27 +0000 (11:23 +0200)]
Update LICENSE for parazyd

6 years agoReturn actual percentage for wifi_perc()
parazyd [Tue, 24 Oct 2017 09:03:17 +0000 (11:03 +0200)]
Return actual percentage for wifi_perc()

Implement basic percentage calculation for wifi_perc. With this
commit, the function returns correct percentage, since the max
of what /proc/net/wireless returns is 70.

7 years agoMove components into dedicated subdirectory
Laslo Hunhold [Sun, 24 Sep 2017 13:33:01 +0000 (15:33 +0200)]
Move components into dedicated subdirectory

This brings us a lot more tidiness.

7 years agoGet rid of HDR variable
Laslo Hunhold [Mon, 18 Sep 2017 06:53:19 +0000 (08:53 +0200)]
Get rid of HDR variable

The HDR variable is used for general purpose headers, which are not
given in this project. arg.h and config.h are only needed for
slstatus.c, not every component $(COM:=.c).

This also fixes a problem introduced in
e04a3853643df1c98a451969d515d8850f138bcc, where config.h is pulled into
the tarball.

7 years agoSimplify Makefile
Laslo Hunhold [Sun, 17 Sep 2017 21:48:11 +0000 (23:48 +0200)]
Simplify Makefile

7 years agoFix missing config.h in Makefile
Quentin Rameau [Sun, 17 Sep 2017 20:31:26 +0000 (22:31 +0200)]
Fix missing config.h in Makefile

7 years agoAdded LICENSE statements to all source files
Aaron Marcher [Sun, 17 Sep 2017 15:45:03 +0000 (17:45 +0200)]
Added LICENSE statements to all source files

7 years agoProperly declare buf as extern and fix all unused-warnings
Laslo Hunhold [Sun, 17 Sep 2017 15:21:54 +0000 (17:21 +0200)]
Properly declare buf as extern and fix all unused-warnings

7 years agoRewrite Makefile to accomodate file split
Laslo Hunhold [Sun, 17 Sep 2017 15:12:44 +0000 (17:12 +0200)]
Rewrite Makefile to accomodate file split

7 years agoSplit into multiple files
Aaron Marcher [Sun, 17 Sep 2017 14:18:17 +0000 (16:18 +0200)]
Split into multiple files

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

7 years agoAdd blank line after setlocale
Aaron Marcher [Sat, 16 Sep 2017 12:11:49 +0000 (14:11 +0200)]
Add blank line after setlocale

setlocale() has to be separated from the signal handling.

7 years agoslstatus: set locale
Kurt Van Dijck [Mon, 11 Sep 2017 18:05:21 +0000 (20:05 +0200)]
slstatus: set locale

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>
7 years agoAdded CPU iowait to README
Aaron Marcher [Sat, 16 Sep 2017 11:54:28 +0000 (13:54 +0200)]
Added CPU iowait to README

7 years agoslstatus: add cpu_iowait
Kurt Van Dijck [Thu, 14 Sep 2017 21:58:38 +0000 (23:58 +0200)]
slstatus: add cpu_iowait

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>
7 years agoDeleted slstatus.png as it is unnecessary
Aaron Marcher [Thu, 14 Sep 2017 20:20:44 +0000 (22:20 +0200)]
Deleted slstatus.png as it is unnecessary

7 years agoslstatus load_avg format string
Kamil Cholewiński [Fri, 8 Sep 2017 21:08:28 +0000 (23:08 +0200)]
slstatus load_avg format string

7 years agoAdded IPv6 address function
Aaron Marcher [Mon, 14 Aug 2017 16:00:46 +0000 (18:00 +0200)]
Added IPv6 address function

- Renamed "ip" function to "ipv4"
- Added "ipv6" function
- Adjusted README and config.def.h accordingly

7 years agosexy config.def.h table
Aaron Marcher [Mon, 14 Aug 2017 12:04:21 +0000 (14:04 +0200)]
sexy config.def.h table

7 years agoFix a little logic error
Laslo Hunhold [Mon, 14 Aug 2017 08:24:43 +0000 (10:24 +0200)]
Fix a little logic error

7 years agoAdd pscanf()
Laslo Hunhold [Sun, 13 Aug 2017 22:34:00 +0000 (00:34 +0200)]
Add pscanf()

This reduces a lot of equivalent code to one function call.

7 years agoRefactor main()
Laslo Hunhold [Sun, 13 Aug 2017 21:21:23 +0000 (23:21 +0200)]
Refactor main()

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.