Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm currently developing a piece of software whose functionality is dependent upon knowing the state of the current Firefox session running on the user's Ubuntu computer. The information it will need to know the following:

  • How many Windows are open?
  • How many tabs are there in each window?
  • What is the URL currently opened in each tab?
  • How far down each tab has the user scrolled?

Upon receiving an explicit command from the user, the application will hunt down this information from wherever it resides on the system. The problem is I have no idea where I should program the application to look for this. My first guess was that inspection of the Firefox processes in the kernel would yield the desired information, but I've used the system monitor to watch for additional processes starting up when more windows and tabs are opened, but the only Firefox process it mentions is 'firefox-bin', leading me to conclude that this assumption is incorrect.

I'm prepared to do some significant reading if someone could just point me in the right direction, it's just that my time is limited and I can't afford to start poking around inside the kernel in the hope that I stumble across what I'm looking for.

Does anyone know how I can find the above information without resorting to installing a plugin on Firefox that exports it?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

How about you read /home/*/.mozilla/firefox/*/sessionstore.js?

share|improve this answer
add comment

You aren't going to find any information in the kernel, you have to ask the firefox process. (There's only one. Firefox uses multiple threads but a single process.) Tabs, URLs and scrolling on a page are concepts that are purely internal to the browser.

Firefox has a remote interface which lets you run some commands from a shell prompt.

firefox -remote 'openurl(http://www.example.com/, new-tab)'

I don't know if there are other undocumented functions you can use through the remote interface. A completely untested idea is to open a local (file://) Javascript script to gather information, but the script may not have the requisite permissions.

You can also load chrome into a running process: firefox -chrome file://…. Again, I don't know what capabilities this offers.

One thing you can know from outside Firefox is the windows and their titles:

wmctrl -xl | 
awk '$3 == "Navigator.Firefox"
     {sub(/^([^ ]+ +)([^ ]+ +)([^ ]+ +)([^ ]+ +)/,""); print}'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.