NSLU2-Linux
view · edit · print · history

HowTo.LEDsShowNewMailAndIRC History

Hide minor edits - Show changes to markup

August 25, 2008, at 10:33 PM by vk -- change crontab line
Changed lines 95-96 from:

*/10 * * * * joe /home/joe/fetchmailcheck.sh

to:

*/10 * * * * joe /home/joe/fetchmailcheck.sh > /dev/null 2> /dev/null

August 20, 2008, at 11:50 PM by fcarolo -- fixed false wikilnks, typo
Changed lines 1-2 from:

This HowTo gives information on how to use the LEDs to display information on Unslung, and more specifically on how to use the disk 1 LED to indicate new mail, and disk 2 LED to indicate a new private message in irssi.

to:

This HowTo gives information on how to use the LEDs to display information on Unslung, and more specifically on how to use the disk 1 LED to indicate new mail, and disk 2 LED to indicate a new private message in irssi.

Changed line 10 from:

Make sure the directory /led exists and that it is writeable by users.

to:

Make sure the directory /led exists and that it is writable by users.

August 20, 2008, at 11:49 PM by fcarolo -- fixed false wikilnks
Changed lines 6-7 from:

LEDs? by running Set_Led every second, setting them on if a file exists, and off otherwise.

to:

LEDs by running Set_Led every second, setting them on if a file exists, and off otherwise.

August 20, 2008, at 11:48 PM by fcarolo -- fixed false wikilnks
Changed lines 1-5 from:

This HowTo gives information on how to use the LEDs? to display information on Unslung, and more specifically on how to use the disk 1 LED to indicate new mail, and disk 2 LED to indicate a new private message in irssi.

Taking control of the LEDs? in Unslung

I couldn't get Unslung to stop updating the LEDs?, so instead i made a script to update the disk

to:

This HowTo gives information on how to use the LEDs to display information on Unslung, and more specifically on how to use the disk 1 LED to indicate new mail, and disk 2 LED to indicate a new private message in irssi.

Taking control of the LEDs in Unslung

I couldn't get Unslung to stop updating the LEDs, so instead i made a script to update the disk

Changed lines 8-9 from:

If the the files /led/disk1on and /led/disk2on exists, disk1 and disk2 LEDs? is on otherwise they are off.

to:

If the the files /led/disk1on and /led/disk2on exists, disk1 and disk2 LEDs is on otherwise they are off.

August 20, 2008, at 10:01 PM by vk -- added notes for debian
Changed line 64 from:

/home/joe/fetchmailcheck.sh:

to:

/home/joe/fetchmailcheck.sh: (Unslung)

Added lines 75-87:

/home/joe/fetchmailcheck.sh: (Debian)

#!/bin/sh         
/usr/bin/fetchmail -c --service 143 && sudo leds disk-1 fast || sudo leds disk-1 off

Debian note: I couldn't figure out how to allow regular users to change led settings, so i used sudo (apt-get install sudo) instead. But sudo by default asks for a password every 15minutes, i changed this by running (as root) "visudo" and add permissions to ex. user joe:

Defaults:joe     timestamp_timeout=-1
...
vk      ALL=(ALL) ALL
Changed line 105 from:

/home/joe/.irssi/scripts/fhilight.pl:

to:

/home/joe/.irssi/scripts/fhilight.pl: (Unslung)

Changed lines 121-139 from:

Make sure /dev/null is writeable by running chmod 777 /dev/null.

to:

Make sure /dev/null is writeable by running chmod 777 /dev/null.

/home/joe/.irssi/scripts/fhilight.pl: (Debian)

use strict;
use Irssi;

sub fhilight {
    system("sudo leds disk-2 fast");
}
sub fseenhilight {
    system("sudo leds disk-2 off");
}

Irssi::signal_add('message private', 'fhilight');
Irssi::signal_add('window changed', 'fseenhilight');

And to actually load this script run "/script load fhilight" in irssi.

May 17, 2008, at 08:08 AM by vk0 -- Make -> Making in headlines
Changed lines 52-53 from:

Make disk 1 LED indicate new mail

to:

Making disk 1 LED indicate new mail

Changed lines 84-85 from:

Make disk 2 LED indicate new private messages in irssi

to:

Making disk 2 LED indicate new private messages in irssi

May 17, 2008, at 08:04 AM by vk0 -- initial
Added lines 1-108:

This HowTo gives information on how to use the LEDs? to display information on Unslung, and more specifically on how to use the disk 1 LED to indicate new mail, and disk 2 LED to indicate a new private message in irssi.

Taking control of the LEDs? in Unslung

I couldn't get Unslung to stop updating the LEDs?, so instead i made a script to update the disk LEDs? by running Set_Led every second, setting them on if a file exists, and off otherwise.

If the the files /led/disk1on and /led/disk2on exists, disk1 and disk2 LEDs? is on otherwise they are off.

Make sure the directory /led exists and that it is writeable by users.

mkdir /led
chmod 777 /led

/root/ledsetter.sh:

#!/bin/sh
while [ 1 ]
do
        if [ -f /led/disk1on ]
        then
                Set_Led turn_on1
        else
                Set_Led turn_off1
        fi

        if [ -f /led/disk2on ]
        then
                Set_Led turn_on2
        else
                Set_Led turn_off2
        fi

        sleep 1
done

Make sure it's executable by running chmod +x /root/ledsetter.sh.

Run ledsetter.sh as root in the background with ./ledsetter.sh &. To make it work after reboots, create the following file (perhaps with a different number):

/opt/etc/init.d/S89ledsetter:

#!/bin/sh
/root/ledsetter.sh &

Make sure it's executable by running chmod +x /opt/etc/init.d/S89ledsetter.

Make disk 1 LED indicate new mail

This works by checking for new mail through fetchmail, and make sure the file /led/disk1on exists if there were new mail, and that it doesn't exist otherwise.

Install fetchmail by running ipkg install fetchmail as root.

Then (if user is joe) create /home/joe/.fetchmailrc with a single line similar to:
poll mail.isp.com protocol imap user "joe" password "joe_is_secretive"

Make sure the file is secret by running chmod 600 /home/joe.fetchmailrc.

/home/joe/fetchmailcheck.sh:

#!/bin/sh         
if /opt/bin/fetchmail -c --service 143
then
        touch /led/disk1on
else
        rm /led/disk1on
fi

Make sure it's executable by running chmod +x /home/joe/fetchmailcheck.sh.

The fetchmail parameter -c simply checks if there is new mail and then stops. The --service 143 parameter tells fetchmail that imap uses port 143 (why are the imap lines commented out in /etc/services ?).

To make this run every 10 minutes add the following line to /etc/crontab:
*/10 * * * * joe /home/joe/fetchmailcheck.sh

Make disk 2 LED indicate new private messages in irssi

This works by using a perl script for irssi that creates /led/disk2on when irssi sends a "message private" signal, and deletes the file on a "window changed" signal.

Make sure the /home/joe/.irssi/scripts directory exists by running mkdir -p /home/joe/.irssi/scripts.

/home/joe/.irssi/scripts/fhilight.pl:

use strict;
use Irssi;

sub fhilight {
    system("touch /led/disk2on 2> /dev/null");
}
sub fseenhilight {
    system("rm /led/disk2on 2> /dev/null");
}

Irssi::signal_add('message private', 'fhilight');
Irssi::signal_add('window changed', 'fseenhilight');

Make sure /dev/null is writeable by running chmod 777 /dev/null.

view · edit · print · history · Last edited by vk.
Based on work by fcarolo, vk, and vk0.
Originally by vk0.
Page last modified on August 25, 2008, at 10:33 PM