[kde-linux] How to check kmail has some unread mails ?

christophe christophe.dr at free.fr
Wed Mar 28 09:11:13 UTC 2007


Le Mardi 27 Mars 2007 22:47, christophe a écrit :
> Le Mardi 27 Mars 2007 15:06, Kevin Krammer a écrit :
> > On Tuesday 27 March 2007 14:49 +0100, christophe wrote:
> > > Le Mardi 27 Mars 2007 14:41, Kevin Krammer a écrit :
> > > > On Tuesday 27 March 2007 13:59 +0100, christophe wrote:
> > > >[...]

Ok i solved the problem by using a ugly hack : i had to use a local file to 
store the number of email because the variable inside the while loop was not 
seen out of this loop and i don't know how to solve that.
Here is my script :


#!/bin/sh
# blinks the mail led if a mail is received by kmail on asus W1N 

isThereMail=1
while [ $isThereMail -gt 0 ]; do
	count=30
	while [ $count -gt 0 ]; do
		echo 0 > /proc/acpi/asus/mled
		sleep 1
		echo 1 > /proc/acpi/asus/mled
		sleep 1
		count=$[$count - 1]
		echo $count
	done
	isThereMail=0
	touch numberOfMail
	dcop kmail KMailIface folderList | while read folder; do
		if [ "$folder" = "/Local" ]
		then
			numberOfM=0
		else
			numberInFolder=$(dcop $(dcop kmail KMailIface getFolder "$folder") 
unreadMessages )
			numberOfM=$[$numberOfM + $numberInFolder]
			if [ $numberOfM > 0 ]
			then
				echo $numberOfM > numberOfMail
			fi
		fi
	done
	isThereMail=$(cat numberOfMail)
	rm -f numberOfMail
	if [ $isThereMail -eq 0 ]
	then
		echo 0 > /proc/acpi/asus/mled
		IsThereMail=0 # exit since this script is launched by kmail and kmail checks 
email every 60 seconds
	fi
done


The problem is that it occupies 100% cpu every minute to check if there is 
mail on kmail. Ideal would be an integrated kmail dcop call.
I think i have already asked it somewhere but is it possible that a more 
recent kmail version supports it ?
Is it kde-pim at kde.org to ask for it , if necessary ?


-- 
christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-linux/attachments/20070328/73b5f20e/attachment.sig>


More information about the kde-linux mailing list