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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...