[问题]让conky发音[已解决]

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
ubuntu_lover
帖子: 119
注册时间: 2007-10-07 11:40

[问题]让conky发音[已解决]

#1

帖子 ubuntu_lover » 2008-04-04 11:14

我已经使用一个脚本让conky能够检测我的gmail邮箱,每半个小时查看一次有没有未读邮件。现在我想在检测到有未读邮件的时候发出声音提醒。请问这个功能能用shell实现吗?请指教一二。
上次由 ubuntu_lover 在 2008-04-05 16:39,总共编辑 1 次。
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京

#2

帖子 aBiNg » 2008-04-04 16:41

写个发声的脚本,条件是有新邮件(这个具体自己想)。

然后在conky中有execi命令,每隔半小时执行一次该脚本。
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#3

帖子 eexpress » 2008-04-04 16:51

发声提示简单。
顺便带上notify-send吧。
● 鸣学
头像
ubuntu_lover
帖子: 119
注册时间: 2007-10-07 11:40

#4

帖子 ubuntu_lover » 2008-04-04 18:05

我的chek-gmail的脚本是这样的:
#!/bin/bash

gmail_login="username"
gmail_password="password"

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

if [ -z "$dane" ]; then
echo "Connection Error !"
else
echo "GMail: $dane list(Inbox)"
fi


能不能在里面综合进去发声的脚本 然后每半个小时检测 有的话就发声了
这个脚本是在网上找的 我不太会写脚本
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京

#5

帖子 aBiNg » 2008-04-04 22:02

把脚本放到$PATH中,conkyrc加入一段:

代码: 全选

${execi 1800 gmail_notify}
脚本改为(要发声,play命令得先装sox包):

代码: 全选

[21:55@~/script] $ more gmail_notify

代码: 全选

#!/bin/bash

# name : gmail_notify

login="x"
passwd="XX"

inbox=`wget -T 3 -t 1 -q --secure-protocol=TLSv1 --no-check-certificate \
      --user=$login --password=$passwd \
      https://mail.google.com/mail/feed/atom -O - | \
      sed -ne '/fullcount/s:.*>\([0-9]\+\)<.*:\1:p' 2> \
      /dev/null`

if [ ! x$inbox == x'' ]
then
	if [ ! $inbox -eq 0 ]
	then
		echo "$inbox new mail(s) in your box."
		Xdialog --title "gmail messenger" --msgbox "please check the mail(s)." 5 40 &
#		play *.mp3 > /dev/null 2>&1 &
	else
		echo "no new mails found!"
	fi
else
	echo "something error!"
fi
头像
ubuntu_lover
帖子: 119
注册时间: 2007-10-07 11:40

#6

帖子 ubuntu_lover » 2008-04-05 14:20

谢谢aBiNg的指点,我搞定了!装了sox,然后这样修改的脚本

代码: 全选

#!/bin/bash

gmail_login="username"  
gmail_password="password" 

dane="$(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 "$dane" ]; then
  echo "Connection Error !"
  else
  echo "GMail: $dane list(Inbox)"
fi
if [ "$dane" -gt 0 ]; then
 cd /路径
 play ×.mp3
fi]
头像
solcomo
帖子: 2838
注册时间: 2007-04-25 13:12

#7

帖子 solcomo » 2008-04-23 0:10

学习 :lol:
♜♞♝♛♚♝♞♜
♟♟♟♟♟♟♟♟
♙♙♙♙♙♙♙♙
♖♘♗♕♔♗♘♖

☠☯⚔⚓☣☦☃☕
☹☻☪☭☬⚖⚛⚜
ℜℳℬ™ ℋℯℓ℘ ℳℭ
sƂɐʍ рǀɹoʍ əɥʇ oS
头像
A-yu
帖子: 127
注册时间: 2008-04-25 23:45

Re: [问题]让conky发音[已解决]

#8

帖子 A-yu » 2008-11-19 20:06

六楼代码有点小错误,贴上个修改的……

代码: 全选

#!/bin/bash

gmail_login="用户名" 
gmail_password="密码"

dane="$(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 "$dane" ]; then
  echo "连接到Gmail服务器失败 !"
else
	if [ "$dane" -gt 0 ]; then
		cd /路径
		play x.mp3
		echo "GMail: 您有 $dane 封新的邮件 ^^"
	else
		echo "GMail: 没有收到新的邮件 ^-^"
	fi
fi
回复