You are not logged in.
Hello,
I am having trouble executing my naughty notifications when the script is executed via crontab. That is, I've written a script which polls the acpi for my batter state, and then sends it to naughty for a notification. When I execute the script through urxvt, it works perfectly. However, when I now tell crontab to execute the script, it fails to achieve the result. I know the script executes because I've put some echo commands in it for testing, however, there are no naughty notifications.
Here is my script, called "batlife"
### Determine Battery Life
bat=`acpi | awk '{print $4}' | awk -F"," '{print $1}'`
val=`acpi | awk '{print $4}' | awk -F"," '{print $1}' | awk -F"%" '{print $1}'`
state=`acpi | awk '{print $3}' | awk -F"," '{print $1}'`
### Pass to Naughty
if [ $val -eq 100 ]
then
echo 'naughty.notify({
title = "Battery\n",
text = "Fully charged!"})' | awesome-client -
elif [ $val -eq 80 ]
then
echo 'naughty.notify({
title = "Battery\n",
text = "State: '$state'\nCapacity: '$bat'"})' | awesome-client -
elif [ $val -eq 60 ]
then
echo 'naughty.notify({
title = "Battery",
text = "State: '$state'\nCapacity: '$bat'"})' | awesome-client -
elif [ $val -eq 40 ]
then
echo 'naughty.notify({
title = "Battery",
text = "State: '$state'\nCapacity: '$bat'"})' | awesome-client -
elif [ $val -eq 20 ]
then
echo 'naughty.notify({
title = "Battery",
text = "State: '$state'\nCapacity: '$bat'"})' | awesome-client -
elif [ $val -eq 10 ]
then
echo 'naughty.notify({
title = "Battery",
text = "Warning! Low capacity!\nCapacity: '$bat'"})' | awesome-client -
elif [ $val -eq 5 ]
then
echo 'naughty.notify({
title = "Battery",
text = "Warning! Critical capacity!\nCapacity: '$bat'"})' | awesome-client -
fi
And here is my crontab:
*/3 * * * * /home/mtrokic/SCRIPTS/batlife
Can anyone help me with this?
Last edited by mtrokic (2011-10-06 18:23:18)
Offline
Ok, so it seems I've figured it out. It turns out that if you're feeding naughty to awesome through the pipe awesome-client, and you are not issuing your commands from X, then you must execute your code via the export display instruction, like so:
export DISPLAY=:0.0 ; your_naughty_script_here
Thus, putting the above into crontab solved my issues.
Offline
It turns out that if you're feeding naughty to awesome through the pipe awesome-client
Not just awesome, any X client... your cron daemon knows nothing of X.
You need to install an RTFM interface.
Offline