You are not logged in.
I have come up with this forsaken script...
#!/bin/bash
while :
do
NEWMAIL=$(curl -su "You'd wish." https://mail.google.com/mail/feed/atom | grep fullcount | cut -d ">" -f 2 | cut -d "<" -f 1)
echo $NEWMAIL
notify-send "Gmail" "You have $NEWMAIL new mails!"
sleep 10s
done
It does get the number of new mails perfectly fine - I'm sure there is a better method with cut... -, and it echos the number, but notify-send does not seem to work. From what I've read I need to set the environmental variable or something like that. Yeah, no clue. Any hint is appreciated.
Last edited by ThunderRush (2013-02-05 14:38:15)
Offline
awk is a better choice for your text processing; we would need sample output to give more specific pointers.
export your DISPLAY before notify-send.
Offline
I will read the man to awk later.
So, I added
export $DISPLAY
before the loop, and I get this in return:
/scripts/gmailcheck: Zeile 3: export: `:0': Ist kein gültiger Bezeichner.
I guess it means "Is not a valid designator/identifier."
Google does not really help with that.
Offline
X is running, isn't it?
echo $DISPLAY
DISPLAY=:0 notify-send "GMail" "New mailz..."
Offline
Of course I do, yes. Gnome3.
DISPLY=:0 notify-send "Test" "Test"
Works when I type it my terminal, but once again not from the script.
And Echo $DISPLAY returns :0
Offline
I will read the man to awk later.
So, I added
export $DISPLAY
before the loop, and I get this in return:
/scripts/gmailcheck: Zeile 3: export: `:0': Ist kein gültiger Bezeichner.
I guess it means "Is not a valid designator/identifier."
Google does not really help with that.
export DISPLAY
Your version will get expanded like this
export $DISPLAY
->
export :0
which caused your error message, because ':0' is not valid in this context.
In other words, you're trying to export the content of the variable instead of the variable itself.
Offline
Thank you, knopwob, that fixed the errormessage, but not the missing notify.
I really have no clue why it does not work.
Do you need any configs files, etc? I really kinda want to get over that problem so I can work on some other scripts including that.
Thanks to anyone who helped until now and anyone who will help.
Offline
I've been working on a similar script and ran into a problem where the Gmail ATOM feed only included the 20 most recent items. I'm still looking for an accurate way to check the current count of unread messages in my gmail inbox and send notifications.
Offline
Are you running this as a cron job?
Offline
I have not tried that, I currently run the script directly, and it should be in ~/.config/autostart once it works.
Offline
The script works fine here...
It may have something to do with how Gnome handles sessions, but I don't use or understand DEs, sorry.
Offline
Maybe you need to export also the DBUS session.
In KDE I use this to notify from a root cronjob:
for pid in $(/usr/bin/pgrep 'startkde'); do
eval $(grep -z '^USER=' /proc/$pid/environ)
eval export $(grep -z '^DISPLAY=' /proc/$pid/environ)
eval export $(grep -z '^DBUS_SESSION_BUS_ADDRESS=' /proc/$pid/environ)
sudo -u "$USER" /usr/bin/notify-send -i folder-tar "test" "test"
done
Offline
I tried that aesiris, of course with some gnome things, but it did not work either.
And for jason: It's okay, thank you again for your help.
I will see what else I can do, and will post a solution if I find one - which I doubt.
What other alternatives to notify-send are there? Not a whole popup, but something more subtle?
#EDIT
As always, my own stupidity.
Since I had absolutely no right set on the file, since the password is there in clear text, ist had the Permissions 111.
But - gnome did not belong to my root.
ps aux | grep gnome
And I always started it as sudo, as root. So I changed the ownership to my user...
sudo chown thunderuser gmailcheck
and set the rights to 500. So I can execute and read it.
And it finally worked. Thanks again.
Last edited by ThunderRush (2013-02-05 14:37:53)
Offline