You are not logged in.

#1 2010-03-19 10:26:22

Ventil1
Member
Registered: 2010-03-17
Posts: 140

How to make conky+checkgmail.sh to play .wav file? [Solved]

Hi,
I am using this script to count  new gmail messages

checkgmail.sh

#!/bin/bash

gmail_login="myusername"  
gmail_password="mypass"

nbmail="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

if [ -z "$nbmail" ]; then
echo "error"
else
echo "$nbmail message(s)"
fi

This is the gmail part from .conkyrc

#check for new gmail exery 120sec
TEXT
Gmail: ${execi 120 sh ~/Downloads/backup/checkgmail.sh}

How can I make it play a .wav file when there is a new message?


I am new at scripts and all. Can I change this in checkgmail.sh? It doesn't work. Why?

if [ -z "$nbmail" ]; then
echo "error"
aplay ~/sounds/error.wav
else
echo "$nbmail message(s)"
aplay ~/sounds/mail_here.wav
fi


The command "aplay ~/sounds/mail_here.wav" works in terminal

Last edited by Ventil1 (2010-03-19 12:48:34)

Offline

#2 2010-03-19 12:40:06

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: How to make conky+checkgmail.sh to play .wav file? [Solved]

Fixed it! Counts gmail messages, diplays the number of messages and plays a sound if there are more then 0.
I am glad some basic java and C stuff from college finally paid up big_smile

#!/bin/bash

gmail_login="myusername"  
gmail_password="mypass"

nbmail="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

if [ -z "$nbmail" ]; then
echo "Error"
else
  if [ $nbmail != 0 ]; then
    echo "$nbmail message(s)"
    aplay ~/sounds/mail_here.wav
  else
  echo "$nbmail message(s)"
  fi
fi

Last edited by Ventil1 (2010-03-19 12:50:14)

Offline

#3 2010-03-19 13:01:23

robrene
Member
Registered: 2009-04-16
Posts: 168

Re: How to make conky+checkgmail.sh to play .wav file? [Solved]

if [ -z "$nbmail" ]; then
  echo "Error"
else
  if [ $nbmail != 0 ]; then
    aplay ~/sounds/mail_here.wav
  fi
  echo "$nbmail message(s)"
fi

[/pedantic]

I'm curious though, did you find out why the aplay command didn't work in the original version?


smile neutral sad big_smile yikes wink hmm tongue lol mad roll cool

Offline

#4 2010-03-19 15:02:55

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: How to make conky+checkgmail.sh to play .wav file? [Solved]

The path to the file in my script was wrong.

Offline

Board footer

Powered by FluxBB