Disc drive LED as shell busy indicator

Rena <[email protected]> Sun, 23 Sep 2012 17:19:00 -0400
Newsgroups gmane.linux.ports.game-cube.devel
Message-ID <CA+rfA1RPUgQ-Czn-Rd+3rEjqk81qbmf11+S=AGTw79oK8E=AWg@mail.gmail.com>
--===============7049653375345070664==
Content-Type: multipart/alternative; boundary=047d7b10cf1b8d340204ca6505ab

--047d7b10cf1b8d340204ca6505ab
Content-Type: text/plain; charset=ISO-8859-1

Compiling devkitPPC on my Wii was taking forever, and from my couch I can't
really see the screen to see how it's going. So I hacked together a simple
script to control the blue disc drive LED:

#!/bin/bash
#installed as /usr/local/bin/discled
echo 250 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio250/direction
echo $1 > /sys/class/gpio/gpio250/value
echo 250 > /sys/class/gpio/unexport

And a .bashrc hack to use it:

# turn disc LED off before displaying a prompt, so that
# we know the command has finished
PROMPT_COMMAND='discled 0 > /dev/null 2>&1'

# turn it on before executing a command
trap 'discled 1 > /dev/null 2>&1' DEBUG

Now, whenever you run a command in bash, the LED will turn on, and turn off
again when the command finishes. That way you can easily look over to see
if the LED is still on, to check if your long-running compile is finished
yet.

Of course this is a dirty hack, so it's far from perfect. The LED will be
on the entire time you're working in nano, will turn on/off when you're
working in other terminals while one is busy, won't inform you if the batch
job is paused waiting for user input, etc. A smarter program might run as a
daemon, turning the LED on whenever CPU/disk/network activity is high
enough or blinking it whenever a character is written to the terminal,
under the assumption that if the job is paused or finished, the system is
going to be mostly idle. But that's another hack for another day.

One amusing side effect is that you won't be able to simply turn the LED on
using the script, because bash will immediately turn it off again. If you
want to do that (say because you executed a command in one terminal while
another was busy, and want to turn it back on to monitor that job), you can
do:

(sleep 1; discled 1)&

So that after bash shows the prompt (and turns the LED off), it'll turn
back on a second later.

--
Sent from my toaster.

--047d7b10cf1b8d340204ca6505ab
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<p>Compiling devkitPPC on my Wii was taking forever, and from my couch I ca=
n&#39;t really see the screen to see how it&#39;s going. So I hacked togeth=
er a simple script to control the blue disc drive LED:</p>
<p>#!/bin/bash<br>
#installed as /usr/local/bin/discled<br>
echo 250 &gt; /sys/class/gpio/export<br>
echo out &gt; /sys/class/gpio/gpio250/direction<br>
echo $1 &gt; /sys/class/gpio/gpio250/value<br>
echo 250 &gt; /sys/class/gpio/unexport</p>
<p>And a .bashrc hack to use it:</p>
<p># turn disc LED off before displaying a prompt, so that<br>
# we know the command has finished<br>
PROMPT_COMMAND=3D&#39;discled 0 &gt; /dev/null 2&gt;&amp;1&#39;</p>
<p># turn it on before executing a command<br>
trap &#39;discled 1 &gt; /dev/null 2&gt;&amp;1&#39; DEBUG</p>
<p>Now, whenever you run a command in bash, the LED will turn on, and turn =
off again when the command finishes. That way you can easily look over to s=
ee if the LED is still on, to check if your long-running compile is finishe=
d yet.</p>

<p>Of course this is a dirty hack, so it&#39;s far from perfect. The LED wi=
ll be on the entire time you&#39;re working in nano, will turn on/off when =
you&#39;re working in other terminals while one is busy, won&#39;t inform y=
ou if the batch job is paused waiting for user input, etc. A smarter progra=
m might run as a daemon, turning the LED on whenever CPU/disk/network activ=
ity is high enough or blinking it whenever a character is written to the te=
rminal, under the assumption that if the job is paused or finished, the sys=
tem is going to be mostly idle. But that&#39;s another hack for another day=
.</p>

<p>One amusing side effect is that you won&#39;t be able to simply turn the=
 LED on using the script, because bash will immediately turn it off again. =
If you want to do that (say because you executed a command in one terminal =
while another was busy, and want to turn it back on to monitor that job), y=
ou can do:</p>

<p>(sleep 1; discled 1)&amp;</p>
<p>So that after bash shows the prompt (and turns the LED off), it&#39;ll t=
urn back on a second later.</p>
<p> --<br>
Sent from my toaster.</p>

--047d7b10cf1b8d340204ca6505ab--


--===============7049653375345070664==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
--===============7049653375345070664==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gc-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gc-linux-devel

--===============7049653375345070664==--