You are not logged in.

#1 2011-10-06 02:43:53

mtrokic
Member
From: Montreal
Registered: 2009-10-24
Posts: 56
Website

[SOLVED] [Awesome WM] Naughty and Crontab

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

#2 2011-10-06 18:22:40

mtrokic
Member
From: Montreal
Registered: 2009-10-24
Posts: 56
Website

Re: [SOLVED] [Awesome WM] Naughty and Crontab

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

#3 2011-10-14 01:14:57

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 835
Website

Re: [SOLVED] [Awesome WM] Naughty and Crontab

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

Board footer

Powered by FluxBB