Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to close the current tab in the active browser window? #101

Open
mxmilkiib opened this issue Jul 20, 2023 · 1 comment
Open

Method to close the current tab in the active browser window? #101

mxmilkiib opened this issue Jul 20, 2023 · 1 comment

Comments

@mxmilkiib
Copy link

I'm trying to bind meta key + mouse button in AwesomeWM to close the current web page tab. Could this be possible through the use of brotab? Thanks for any thoughts!

@drocta
Copy link

drocta commented Aug 10, 2023

I'm not familiar with AwesomeWM, but, assuming you can set it up to call a script of your choosing, that should be possible, I would think.

The command brotab query +active +lastFocusedWindow will tell you the active tab in the browser window which most recently had focus. (I think brotab query +active +currentWindow will do the same but only if you currently have it active? I haven't checked this.)
In my case, this returned
a.920.899 Method to close the current tab in the active browser window? · Issue #101 · balta2ar/brotab https://github.com/balta2ar/brotab/issues/101
this a.920.899 is the thing you would need (please excuse my obscene number of tabs I have open)

Then, brotab close a.920.899 would close the tab.
So, if you make a little bash script which calls brotab query +active +lastFocusedWindow , and then uses split or whatever it is called to get the first field in the resulting line,
and then have the script call brotab close $theVariableWithTheTabId , it should close the tab.

However, I'm not really familiar with how tiling window managers work, so, for all I know, "the current active window" might not quite be a relevant concept there(?).
But, if you have access to the window title of the browser window containing (as its active tab) the tab you want to close,
then instead of brotab query +active +lastFocusedWindow you could use something like brotab query +active -title $bashVariableWithTitleOfTheTabPage to get the tab id, and then use the close command to close it as before.
This should work provided that you don't have multiple windows which have as their active tab, one with a title containing as a substring(?)(the help text says "pattern", so maybe it supports wildcards or something?) the title of the page in the tab you want to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants