Commit graph

33 commits

Author SHA1 Message Date
Andrea Bolognani
5bc8f0105b baraction: Simplify update loop
The current loop is a bit awkward for a number of reasons:

  * iostat exits after a number of iterations, so to keep the script
    going we need to run it in a nested loop;

  * we also run iostat concurrently using the |& syntax, which in
    addition to being non-portable requires us to set up a cleanup
    path so that we don't leave stray processes around when spectrwm
    is restarted;

  * due to the fact that iostat prints its headers again every 20
    records, we have to keep careful track of the number of
    iterations - something which has proven to be error-prone.

Once we do away with the idea of iostat driving the update loop, all
of these issues disappear and the code becomes much simpler.

We still cache battery data for 11 seconds, which is the same amount
as before; tweaking it further, if desired, will be trivial now.

This patch is better viewed with 'git show -w'.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
1ffd2881b9 baraction: Improve portability
The script uses a couple of non-POSIX constructs that are
thankfully fairly easy to replace with more portable alternatives.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
e8f7e415f0 baraction: Shuffle functions around
Keep the order of definition in sync with the order of usage.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
beef2db2ca baraction: Rename print_apm() to print_bat()
It fits better with the output of the function, and is also a
more OS neutral name.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
43e7a3d20a baraction: Drop argument to print_mem()
It's not used.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
97b3f52ea8 baraction: Improve formatting of CPU speed
If the CPU is throttled to less than 1 GHz, the contents of the
bar will move around a bit; always use 4 digits to print the CPU
frequency so that doesn't happen.
2020-02-16 20:23:54 +08:00
Andrea Bolognani
9c77876ca8 baraction: Fix apm data caching
The idea is that it's pointless to collect information about the
battery every single second, so caching has been implemented for
the output of apm; however, the condition has been broken since
3356f1ccd4, which resulted in data being collected every single
second after all.

This fixes the check so that information is collected every 11
seconds, which fits nicely into the 22 second long cycle used to
parse iostat's output.
2020-02-16 20:23:54 +08:00
Edd Barrett
51416d8a84 Make it clear that the example baraction script is for OpenBSD. 2019-06-18 21:32:30 +08:00
Edd Barrett
24194fd29f Fix the example baraction script for OpenBSD-current.
The iostat(8) output now includes a "sp" field.

From the man page:
> sp      % of CPU time spent spinning
2019-06-18 21:32:30 +08:00
orbea
e40e0282a7 Whitespace 2018-05-09 08:18:41 +08:00
Marco Peereboom
7a60eacaab Revert "cleanup baraction.sh"
This reverts commit d78d51c805.
2014-08-14 16:28:52 -05:00
Varun B Patil
d78d51c805 cleanup baraction.sh
1. Do not hardcode path to coreutils.
2. Do not pass variables to functions where not required.
3. Run top as a batch process to be able to grep its output.
2014-08-08 16:44:06 +08:00
Jean-Philippe Ouellet
9e034db344 Fix bug in baraction.sh that causes bar text to flicker every 20s. 2014-08-08 06:35:44 +08:00
Marco Peereboom
e83f3b7908 rename scrotwm to spectrwm 2012-02-15 14:09:13 -06:00
Marco Peereboom
8eb6cfee63 kill cvs tags 2011-10-25 15:54:39 -05:00
Marco Peereboom
d034409fc9 catch up to new top
From: Alicornio <alicornio@ig.com.br>
2011-07-18 16:19:29 +00:00
Marco Peereboom
fd802e8f94 Fix some spaces 2010-07-01 19:49:37 +00:00
Darrin Chandler
3cd1a5315b Add CPU speed to baraction.sh
Diff from Joe Gidi <joe@entropicblur.com>
2010-01-13 22:17:03 +00:00
Marco Peereboom
597613109e Use cut instead of awk for some sort of mem saving.
From Sepp0 <sepp0@openbsderos.org>
2009-09-30 02:50:11 +00:00
Marco Peereboom
cd8f3f52f7 Make tags all the same.
Add amateurish script to generate a release; beats me typing it
2009-09-13 22:28:53 +00:00
Marco Peereboom
52847d8341 kill iostat when restarting scrotwm
from Joe Gidi <joe@entropicblur.com>
2009-09-13 21:37:39 +00:00
Marco Peereboom
1984ff720f Add mem to script; disabled of course.
from sepp0@openbsd.org.ar
2009-09-13 21:01:36 +00:00
Marco Peereboom
3356f1ccd4 Update bar more often and remove ./ from baraction.sh 2009-02-20 14:28:32 +00:00
Marco Peereboom
6ddc03b50d Add clock format from merdely 2009-02-18 20:34:26 +00:00
Ryan McBride
5434fc5516 Rework the sample baraction.sh to use iostat -C rather than the sleep
as its timer, printing CPU stats as well as APM status.
2009-02-11 07:17:06 +00:00
Marco Peereboom
f2e6504a1d Add tags 2009-01-27 16:16:20 +00:00
Marco Peereboom
0f0772ae65 Move delay back to 59 2009-01-24 23:51:08 +00:00
Marco Peereboom
a41ad57261 Remove html so that we can move it to it's own dir. 2009-01-24 23:38:36 +00:00
Ryan McBride
265cac27a6 Add commented-out support for printing CPU stats to the bar. 2009-01-23 08:51:56 +00:00
Ryan McBride
87ba936ecf I want to know if I'm on AC, might as well make it pretty while we're here.
Also try to make it shut up on systems without battery.
2009-01-23 08:30:03 +00:00
Marco Peereboom
c9e5942c47 Use full path 2009-01-23 02:38:30 +00:00
Marco Peereboom
5f373c8f32 update every 59 seconds instead of 1 2009-01-22 18:16:35 +00:00
Marco Peereboom
7288f47b93 Add baraction script for batter and stuff.
bad mcbride broke colors in config file; need to go fix that now.
2009-01-22 17:50:16 +00:00