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?
5 Answers
Chrome on Linux - query the browser to see what tabs are open?
For chromium
:
strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://'

- 2,246
- 3
- 20
- 23
-
7I know nobody asked for mac, but I was linked to this question when googling for a mac answer, so I'm just gonna add the info here. `strings ~/'Library/Application Support/Google/Chrome/Default/Current Session' | 'grep' -E '^https?://'` – AlexMorley-Finch Aug 28 '18 at 09:29
-
It gives an error like `No such file or directory`. Can you help, please? – Rahul Raval Dec 18 '18 at 06:47
-
it sorta works. returns urls that are not currently open too, but i suppose thats to be expected based on what `strings` does – stantonk Jan 30 '19 at 17:49
-
Is there a way to get which tab I'm focusing? – roachsinai Feb 24 '19 at 09:26
-
Maybe the last one of the `https` is, thanks. And `~/.config/google-chrome/Default/'Current Session'` for Chrome. – roachsinai Feb 24 '19 at 09:29
-
Does someone have a windows solution ? – Alexander May 16 '20 at 10:18
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.

- 2,724
- 5
- 32
- 37
-
Is it possible to access the list of open tabs from a Google Chrome extension? – Anderson Green Aug 23 '12 at 20:42
-
2This question explains how to find the list of open tabs from a Chrome extension: http://stackoverflow.com/questions/11915370/retrieving-which-tabs-are-open-in-chrome – Anderson Green Aug 23 '12 at 20:43
-
Does this answer apply to all platforms, or does it only apply to Linux? – Anderson Green Jan 03 '13 at 05:58
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: ~*

- 81,433
- 63
- 146
- 187

- 51
- 1
- 1
An expansion on the unix command above (I don't have enough reputation to comment). I was trying to just get a count of tabs. This still isn't perfect because I think the file has the entire history of all tabs in it. I guess they are in order, but not obvious how to separate them.
strings ~/Library/Application\ Support/Google/Chrome/Default/Sessions/Tabs_* | sed -nE 's/^([^:]+):\/\/(.*)\/$/\2/p' | grep -v "newtab" | grep -v "new-tab-page" | sort | uniq | wc -l
This is on mac, so your paths and sed options may vary.
The basic idea is to get rid of trailing slashes (lots of redirects just add a slash) and newtabs so we can get an accurate count. For my current tabs file this went from 181 tabs open down to a count of 35. That actually looks like an undercount right now, but it is a lot closer.

- 51
- 3
I have written a tool to extract data from chrome session files for precisely this purpose. https://github.com/lemnos/chrome-session-dump. Running it like so chrome-session-dump will produce a list of tabs (in order) which can subsequently be passed to firefox. E.G chrome-session-dump|xargs firefox. You can also obtain the currently open tab via -active for processing by external scripts.

- 21
- 1
-
Hi, I get the error 'panic: Unable to find session file.', can you help me? – Miloš Milutinov Jun 27 '22 at 08:37