最简电池警告脚本

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

最简电池警告脚本

#1

帖子 eexpress » 2008-02-14 12:14

代码: 全选

☎ cat 电池警告.bash
#!/bin/bash grep "charging state:" /proc/acpi/battery/BAT0/state|grep discharging
[ $? == 1 ] && exit;
grep "capacity state:" /proc/acpi/battery/BAT0/state|grep ok
[ $? == 0 ] && exit;
notify-send -u critical -t 5000 -i '/home/exp/媒体/48-png/48-laptop-battery.png' '警告' '电池电量即将用完,请及时充电。'
mplayer '/home/exp/媒体/◇事件声音-et/I-need-ammo.wav'
加入crontab运行。

代码: 全选

*/2 * * * * export DISPLAY=:0 && /bin/bash /home/exp/应用/脚本/电池警告.bash
● 鸣学
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#2

帖子 bones7456 » 2008-02-14 16:42

也不说说ubuntu下要先安装libnotify-bin才行...
关注我的blog: ε==3
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#3

帖子 eexpress » 2008-02-14 16:46

我只说结果的。不重过程的。过程,排骨可以cli跑下,就会提示需要什么包。再说,我的其他帖子里面说过这包了啊。
● 鸣学
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#4

帖子 bones7456 » 2008-02-14 17:15

呵呵,那也得想想看你这帖子的人的感受啊...
不过ee这风格,我倒是习惯了.
关注我的blog: ε==3
头像
windwiny
帖子: 2254
注册时间: 2007-03-13 17:26

#5

帖子 windwiny » 2008-02-15 15:14

上次弄了个EA,害得我现在天天要记帐
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#6

帖子 eexpress » 2008-02-15 15:56

啊。幸好还有人用ea。我更新了简单的统计。total.c。
☎ cl
0 21 * * * /usr/local/bin/msg 记账
● 鸣学
回复