Gmail Script

Hi!, somebody know how I can make a fvwm script to check the gmail acount?
thxs :slight_smile:

Heres a link on the gentoo forums on how to do it.

http://forums.gentoo.org/viewtopic-t-242076-highlight-fvwm+gmail.html

Heh, I have some Python code lying around that gets the number of new messages, just havenā€™t gotten around to writing the FvwmScript to display it (Iā€™m rethinking my setup atm), should be dead easy thoughā€¦

[code]#!/usr/bin/env python
import libgmail
import sys

if name == ā€œmainā€:
ga = libgmail.GmailAccount(sys.argv[1] + ā€œ@gmail.comā€, sys.argv[2])
ga.login()
print ga.getUnreadMsgCount()[/code]

It expects two arguments: the username and the password, might kick together the FvwmScript part later today or somewhere tomorrowā€¦

[EDIT]
So that still was todayā€¦

[code]#--fvwm--
WindowTitle {FvwmGmail}
WindowSize 120 25

Init
Begin
Set $MainColorset=(GetScriptArgument 1)
If $MainColorset <> {} Then
Begin
ChangeColorset 0 $MainColorset
ChangeColorset 1 $MainColorset
End
Set $Username=(GetScriptArgument 2)
Set $Password=(GetScriptArgument 3)
Set $cmd={exec .fvwm/scripts/FvwmGmail/NewMessages.py } $Username { } $Password}
Echo $cmd
Set $tmp={New mail(s): }(GetOutput $cmd 1 -1)
ChangeTitle 1 $tmp
End

PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 30)==0 Then
Begin
Set $tmp=(GetOutput $cmd 1 -1)
ChangeTitle 1 $tmp
End
End

Widget 1
Property
Position 0 0
Size 120 25
Type ItemDraw
Title {}
Main
Case message of
SingleClic:
Begin

End
End
[/code]

Itā€™s basic as it only displays the number of new messages, wouldnā€™t be hard to add the total number of messages in your inbox.

thxs for replys:
VoiDeR the post forums.gentoo.org/viewtopic-t-24 ā€¦ gmail.html is deprecated (the links)

theBlackDragon I canā€™t understand ur script, where I set the pass and user? u say that isnā€™t finished yet?

Thxs to all :slight_smile:

Iā€™ve just edited my post, you basically have two files, the Python script which does the actual work of getting the data from the server and the FvwmScript that displays it, you might have to edit the path to the Python script though as I keep both files in ~/.fvwm/scripts/FvwmGmail if you put them there they shouldnā€™t need any modification.

The FvwmScript takes three parameters, the first one being a Colorset number to use, the second one being your Gmail username and the third one being your password, you might want to use Piperead to read in the latter ones from external files as keeping that kind of stuff in your config isnā€™t really secure, and might cause some trouble if you decide to share it and forget to take those ā€˜detailsā€™ out :wink:

But as I said, it doesnā€™t do any advanced stuff, just displays the number of new messages, which is all I need :slight_smile:

Hi!, well Iā€™ve some problems, letā€™s see
Iā€™ve modified the script with my user,pass and the path to the python script

Then, I swallowed the script in FvwmButton

When y restart fvwm, I can see the script in FvwmButton and show me ā€œNew mail(s):ā€, but nothing else. So Iā€™ve tryed to run ā€œmanuallyā€ in a terminal:

exec /home/blue/fvwm-config/scripts/NewMessages.py heremyuser heremypass

After 3 seconds the terminal has closed without errors

NOTE: the 2 files, FvwmGmail and NewMessages.py have chmod a+x
And I have emerged libgmail, any ideas?

thxs :slight_smile:

It seems the script doesnā€™t like it when itā€™s executed with an absolute path, I strongly suspect this to be a bug in libgmail is it works fine for FvwmMpd. I thought that normally FvwmScript should also find the script without the path being specified if itā€™s in the same directory as the calling script but that doesnā€™t seem to work for me which is a real painā€¦

Iā€™ll try to work something out later today.

Well, reading ur post, Iā€™ve tryed this
copy the files FvwmGmail and Newmessage.py to /usr/fvwm/fvwm and edited the FvwmGmail script:

But I get the same result :frowning: