Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome on Linux - query the browser to see what tabs are open?

Tags:

I am running Chromium (the open source chrome version) on Ubuntu Linux. Can I write a programme to see what tabs I have open? I would like to write a programme to monitor how much time I'm spending on things. Is there a command line programme, some way to invoke the chromium-browser command, or some dbus incantation that will tell me what tabs I have open and what URL each tab is at?

like image 313
Amandasaurus Avatar asked Feb 11 '11 11:02

Amandasaurus


3 Answers

Chrome on Linux - query the browser to see what tabs are open?

For chromium :

strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://'
like image 155
MevatlaveKraspek Avatar answered Sep 27 '22 18:09

MevatlaveKraspek


Indeed there is a command line option which can open the door to a running chrome (chromium) process --remote-shell-port. Through this "debugging back-door" you may be able the get the list of open tabs.

  • Look at chromedevtools for further inspiration.

UPDATE:

Chrome DevTools is deprecated and not supported anymore since Version >17.0.950.* See WebKit-Protocol manual if the new Debug-Framework provides similar manners to accomplish the task.

like image 20
Maus Avatar answered Sep 27 '22 17:09

Maus


Here is a more general solution (works with other applications as well) by querying the X window under focus using xdotool

while true; do 
  xdotool getwindowfocus getwindowname; 
  sleep 10; 
done

This outputs the following for instance:

Tilix: Defaultpeter-ThinkPad-T5801: peter@peter-ThinkPad-T580: ~
Chrome on Linux - query the browser to see what tabs are open? - Stack Overflow - Google Chrome
Local KVM
untitled — Atom
untitled — Atom
Open File
iostat_xtmz_3.out — ~/Work/KappAhl/Test1 — Atom
Tilix: Defaultpeter-ThinkPad-T5801: peter@peter-ThinkPad-T580: ~*
like image 34
ptrk64 Avatar answered Sep 27 '22 18:09

ptrk64