index.md - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
index.md (1823B)
---
1 email notifications
2 ===================
3
4 Description
5 -----------
6 This init script is based on some ideas taken from the dwm ML. It adds email
7 notification using `fetchmail`. It also adds the functionality of showing the
8 content of the file `$HOME/.message` when it exists. This can be used for
9 displaying info by other programs writing to this file.
10
11 When a new email arrives a flashing text message is shown on the dwm's
12 status bar.
13
14 Config .fetchmailrc
15 -------------------
16 This config works with GMail over IMAP with the IDLE extension for low bandwidth usage:
17
18 poll imap.gmail.com port 993 proto IMAP user "<your_user>@gmail.com"
19 there with password "<your_pass>" keep ssl idle
20
21 Init script
22 -----------
23 The notification is flashing during 60 seconds, then it is removed. Lines
24 written to `.message` are displayed during a second in the status bar. If
25 `.message` is deleted, the normal status message (date and uptime) returns.
26
27 A pipe must be used with `fetchmail` when using IDLE extension because this way
28 it waits for updates from the inbox not doing polling. If the `.message` file
29 exists with some content, it is preserved and no email notification is shown.
30
31 fetchmail --check 2>/dev/null | while read line; do
32 new=`echo $line | sed 's/(//' | awk '{print $1-$3}'`
33 if [ $new != 0 ] && [ ! -e ~/.message ]; then
34 echo "New mail($new)" > ~/.message
35 echo "!!! !!! !!!" >> ~/.message
36 sleep 60
37 if grep '^New mail' ~/.message >/dev/null 2>/dev/null; then
38 rm -f ~/.message
39 fi
40 fi
41 done &
42 while true; do
43 if [ -r ~/.message ]; then
44 while read line; do
45 xsetroot -name "$line"
46 sleep 1
47 done < ~/.message
48 else
49 xsetroot -name "`date` `uptime | sed 's/.*,//'`"
50 sleep 1
51 fi
52 done &
53 exec dwm
54 rm -f ~/.message
55
56 Author
57 ------
58 * Ricardo Catalinas Jiménez <jimenezrick@gmail.com>