Jump to content

Run a script at shutdown - or hibernate?


Recommended Posts

Hi all,

 

Not sure what is the best way to approach this. Here's the sketch:

 

I want to keep my Firefox bookmarks synchronised between my dual-boot WinXP and Mandy 10.1 desktops. At the very minimum, which is where I am now, I can have each OS import the other's bookmarks.html file at startup, and manually export before shutdown or hibernation. All the above is done by shell-scripts.

 

My dream, though, would be to have the startup-import done automatically when resuming from hibernation as well, and similarly to export automatically before either shutdown or hibernation.

 

I don't really want to rely on cron/Task Scheduler for the export, as that would mean waiting X minutes before shutting down/hibernating.

 

So, any ideas?

Link to comment
Share on other sites

Also: another feasible option would be doing the import/export on Firefox open/close, that should be easy enough for the start/import part, but how then to catch the closing in order to export?

 

And of course this method would not be proof against the hibernation case, if I still had the browser open when going into hibernation.

 

Is this hopeless?

Link to comment
Share on other sites

I don't know the details, but I'm sure this can be done, if acpid (or apmd) is running, because those daemons were, among other reasons, created so that scripts could be run before, and after resume. Reason is: depending on hardware, some modules have to be unloaded then reloaded, and some services have to be stopped then restarted.

Good luck...

 

Yves.

Link to comment
Share on other sites

If I understand what you are asking this is a relatively easy thing to do.

 

I currently share bookmarks between my Mandrake 10.1 using Firefox and WinXP using Firefox on the same machine.

 

I have 2 HD. 1st HD has WinXP on 1 partition. 2nd HD has Mandrake 10.1, a separate FAT32 partition and a separate NTFS partition.

 

as per this link:

 

http://www.mozilla.org/support/firefox/tips#beh_bookmarks

 

create a user.js text file to contain the following:

 

// Specify which bookmarks file to use:

user_pref("browser.bookmarks.file", "C:\\Path To Netscape Profile\\bookmarks.html");

 

the above is what it would look like under your firefox profile in WinXP (located in a hidden directory under Documents and Settings/User/).

 

Also put the same file but change the path to match linux vernacular in your ~/.mozilla/firefox/xxx.default directory.

 

On my box I have a separate FAT32 partition (D drive for windows, /mnt/shared for linux).

 

Under WinXP: user_pref("browser.bookmarks.file", "D:\\User\\shared_files\\bookmarks.html");

 

Under Mandrake: user_pref("browser.bookmarks.file", "/mnt/shared/User/shared_files/bookmarks.html");

 

this setup works flawlessly for me. Bookmarks changed, added or deleted when booted in WinXP are automatically picked up when booting into linux.

 

Hope this helps.

 

Regards,

Crispus

Link to comment
Share on other sites

Thanks, that works a treat!

 

Why on earth is the prefs system so odd in Firefox? you have prefs.js (created by default) for most of the stuff in the menus, then you have user.js (which you have to create yourself) for a bunch of other (apparently undocumented) stuff. Is it some kind of legacy thing?

 

I guess we could call this resolved, but I'd still like to hear about the hibernate/resume scripting thing. I'm sure it could come in handy for other things, and will fulfil the title of the question. Any thoughts?

Link to comment
Share on other sites

Glad everything worked out and glad to help. I've been leaching of the linux community for some time now so glad to finally lend a hand myself. B) .

 

As for the prefs.js vs user. js I have no insight except that prefs.js can get overwritten if the program is running and it's a good way to keep track of your tweaks by having a separate file. Many of the tweaks that you set via user.js can also be set in prefs.js by typing about:config in the URL line of firefox. I've also noticed that you can duplicate some of the extensions found on the mozilla site by adding code to your user.js file.

 

FYI, this idea also works with thunderbird.

 

http://texturizer.net/thunderbird/share_mail.html

 

Using the same setup but with a bit more legwork I can share email profiles between XP and Linux.

 

Regards,

Crispus

Link to comment
Share on other sites

I guess we could call this resolved, but I'd still like to hear about the hibernate/resume scripting thing. I'm sure it could come in handy for other things, and will fulfil the title of the question. Any thoughts?

 

You could use something like this... and then pick your runlevels to have it start and stop...

 

#!/sbin/runscript
#
# start stop script
# /etc/init.d/syncbooks

depend() {
       need net
}

checkconfig() {
       if [ ! -e "/sbin/syncfirefoxbooksifneededscript.sh" ]; then
               eerror "You need a script to run first"
               eerror "make sure that you chmod +x the .sh"
               return 1
       fi
}

start() {
       checkconfig || return 1
       ebegin "copying bookmarks if needed"
       /sbin/syncfirefoxbooksifneededscript.sh
       eend $?
}

stop() {
       ebegin "bookmarks syncing"
       /sbin/syncfirefoxbooks.sh
       eend $?
}

Link to comment
Share on other sites

Cheers - bit over my head but I think I get the gist. So does that script run at hibernate/resume too?

 

No it will not run at hibernate resume. You would have to use and modify the hibernate scripts (usually it is in /usr/sbin/hibernate)at the begining for hibernate and at the end for resume. to run a script that will update your bookmarks.

 

The hibernation stuff for linux can be found here:

http://softwaresuspend.berlios.de/

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...