Shell提醒

来自linux中国网wiki
Evan讨论 | 贡献2022年1月12日 (三) 06:27的版本 →‎temp
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

eye

cat apps/eye.sh 
#!/bin/bash
#50,51  * *  * *  /home/evan/apps/eye.sh

export DISPLAY=:0.0;notify-send -u normal -t 50000 -i appointment-new '1分钟后锁屏' '注意休息,善待眼睛、善待颈椎'

temp

 cat apps/temcheck.sh 
#!/bin/bash
# */49  * *  * *  /home/evan/apps/temcheck.sh todo
# install func  is u want
function ins(){
    sudo apt  install lm-sensors && sudo   modprobe coretemp
}

#run func
function todo(){
    str=`sensors | grep Core  | awk '{print $3}'|sed -n '1p' | tr -cd "[0-9]"`
    if [ $str -gt 500 ]
    then
        #export DISPLAY=:0.0;notify-send -u normal -t 50000 -i appointment-new '1分钟后锁屏' '注意休息,善待眼睛、善待颈椎'
	# 没这个export 不显示 在crontab

        export DISPLAY=:0.0;notify-send -i dialog-warning "系统温度提醒" "$(whoami) 你的电脑温度过高 大于50度 \n Quickly To Kill Your Bad Process"
        fi
}

#help func
function h(){
    echo "Usage: $0 (install|todo|help)"
}

#main to start
case $1 in
    ins)
        ins
        ;;
    todo)
        todo
        ;;
    *)
        h
        ;;
esac
exit 0