Jump to content

script request: download Google Calendar (ical)+co


Recommended Posts

Hi,

 

I don't know anything about scripting, but what I'm trying to do should not be that hard, at least I think.

 

I keep appointments in Gmail calendar.

However, I also want to copy the calendar to my iPod nano.

 

- Google calendar keeps an iCal file of the calendar on a location like http://someurl/username.ics

- The iPod is mounted at /media/IPOD/ , and the folder for the calendars is called 'Calendars' . So full path + filename gives /media/IPOD/Calendars/username.ics

- If possible, I'd like to use wget for the download (I think that's easiest too...)

- easiest would be to save all relevant info in a configuration file (plain text) in the same directory as the script

 

Also, a bit more specialized: I'd like this script to be run as soon as the IPOD gets detected&mounted.

 

 

Anyone feel up to this?

 

 

[moved from Terminal Shell Commands, etc by spinynorman]

Link to comment
Share on other sites

Well, I decided to give it a try anyways...

 

would this work?

 

#
#
# Script to fetch Gmail Calendar & Copy to iPod.
#
clear
wget -c -r http://someurl/username.ics
cp username.ics /media/IPOD/Calendars/
echo "Script Finished";
exit 0

 

(I don't have access to a Linux OS ATM so I can't try myself...)

Edited by Darkelve
Link to comment
Share on other sites

Hahaha, what do you know, it worked! B)

 

#
#
# Script to fetch Gmail Calendar & Copy to iPod.
#

# clear the screen
clear

# download the Google calendar ical file through the private URL

wget -c -N http://www.google.com/calendar/ical/username@gmail.com/private-somenumbers/basic.ics

# report success
echo "Google Calendar File Saved to Disk";
cp basic.ics /media/ipod/Calendars/CalendarNameOnIPod.ics;

# report success
echo "Calendar File Successfully Copied to iPod";

# delete basic.ics file on hard disk
rm basic.ics

# exit program
exit 0

 

I put this in the /home/Darkelve/bin/ directory and changed the permissions with

chmod 755

 

Now does anyone know how I can execute the script right after the OS (KDE?) detects that the iPod is mounted under /media/ipod/ ?

 

 

Also, I think the error messages need work...

Edited by Darkelve
Link to comment
Share on other sites

If you are using udev, this should work (I really need to know what device name the iPod is, though). In

 

/etc/udev/rules.d/60-dynamic.rules

 

add this line (assuming the iPod is sda<<something>>):

 

KERNEL=="sda[0-9]*", RUN+="/path/to/your/executable/script"

 

This is on Mandriva and it worked for my SanDisk U3 Cruzer Micro. No need for a restart of the service or a reboot.

Link to comment
Share on other sites

It's sda2

 

I'm running SuSe 10.1 though, so I don't know if that makes a difference?

I don't know what mounting method SuSe uses this time around... xD

 

Also, for some reason I've got double entries in my iPod now... but no idea why... it's supposed to overwrite the file I thought?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...