Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am creating a couple of scripts that will take Firefox's Bookmarks and place them in XFCE's menu. I've pretty much figured that part out, just a couple of tweaks need to be done.
What I want to happen is when Firefox closes that my scripts will run. Or I just thought of this, maybe if Firefox's bookmarks has been changed. But, I have no idea on how to do this.
Could a bash or Python script be used to open Firefox and somehow wait until Firefox closes to run the bookmark updater script? Or even better, only run when Firefox's sqlite bookmarks' table has changed.
"command" will execute after the firefox process finishes normally. Note that if firefox crashes, or an error is generated, "command" will not run, due to using &&.
It looks like the places.sqlite file is what stores the bookmarks, so you could conceivably write a bash script with a while loop that checks (at a specified interval, say once every 10 minutes) whether the file was updated during the last interval, and if so, run your menu script.
Code:
while [ TRUE ]
do
if [ -n "$(find /home/user/.mozilla/firefox/XXXXXXX.default/places.sqlite -mmin -10)" ]
then
run your script here
fi
sleep 10m
done
"command" will execute after the firefox process finishes normally. Note that if firefox crashes, or an error is generated, "command" will not run, due to using &&.
Cheers,
Josh
Thanks, I didn't know about that technique. That should work. I just need to make a bash script that will run the two python files I have made.
It looks like the places.sqlite file is what stores the bookmarks, so you could conceivably write a bash script with a while loop that checks (at a specified interval, say once every 10 minutes) whether the file was updated during the last interval, and if so, run your menu script.
Code:
while [ TRUE ]
do
if [ -n "$(find /home/user/.mozilla/firefox/XXXXXXX.default/places.sqlite -mmin -10)" ]
then
run your script here
fi
sleep 10m
done
Sounds good, but places.sqlite also stores the history, typed addresses among other things, so every time you open Firefox or go to a new site/page the database will be updated. The table 'moz_bookmarks' is the table with just bookmark information. Not even all of it, there is another table with the name of the bookmark. I would need to just check if the table 'moz_bookmarks' was altered, unless I wanted to run my scripts every x minutes.
I was going to do a cronjob once a day to update XFCE's menu. I think I would rather use a cronjob than to run automatically every x minutes that Firefox is open.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.