Closed bjohas closed 2 years ago
Great question! This is not supported at the moment. I was thinking maybe it could be added to bt move
command. If it doesn't work out, there could be a clone of move
, but bt edit
that only allows to edit URLs, but that would mean that you'll need to invoke an editor (or come up with a script).
What's your use-case?
Hi @balta2ar - thank you.
Suppose I have this:
b.100.200 title url1
I'd like run e.g. bt location b.100.200 url2
to give
b.100.200 title url2
Use case 1. The use case is e.g. changing user in google docs, where I have a tab with a location logged into user1@gmail.com as follows:
https://docs.google.com/document/d/123456/edit
At the moment, I have a GUI-based approach (using autokey on linux), where I've got a keyboard shortcut bound to some actions, which go to the location bar and replaces the above url with
https://docs.google.com/document/d/123456/edit?authuser=user2@gmail.com
I.e., this changes the location (and, switches to the logged-in user user2@gmail.com for that document). I'd prefer to skip the UI processes, but just bind a keyboard shortcut to [determining the active tab, i.e., b.100.200
) then running this command:
bt location b.100.200 https://docs.google.com/document/d/123456/edit?authuser=user2@gmail.com
Use case 2. For some applications (say gmail), I use a chrome application (or adjusting css in the firefox ui), which hides the browser location bar. Gmail used to have shortcuts for certain searches, which was then taken over by gmail quick links. However, this is now broken: https://github.com/kevinwucodes/gmail-quick-links/issues/65. I'd like to replace that functionality with keyboard shortcuts. I can bind the keyboard shortcut e.g. with autokey. The keyboard shortcut would change this location
https://mail.google.com/mail/u/0/#inbox
to (eg):
https://mail.google.com/mail/u/0/#starred
I.e., I'd like to run
bt location b.100.200 https://mail.google.com/mail/u/0/#starred
Does that help?
On reflection - use case 1 is doable by closing and opening (in the same place), which is doable already. Only Use case 2 requires changing a url in place. It's possible to change urls for chrome apps, but there's no UI for it.
For Use case 1, one could do
Also, this reminded me of this aother error. I am getting "brotab clients
and also brotab active
gives
...
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR
@bjohas Now it's possible. There are three ways to do that:
bt move
-- if you change the URL column, it will be updatedbt navigate b.1.862 'https://google.com'
bt update -tabId b.1.862 -url="http://google.com"
navigate
is basically a convenience shortcut for update
, which is more powerful.
That's amazing, thank you!
@balta2ar - to use this, I've updated to brotab=1.4.2 with pip. I've reinstalled the mediator (brotab install
). However,
bt navigate b.1.2 "https://www.google.com/"
gives me
...
urllib.error.HTTPError: HTTP Error 404: NOT FOUND
Do I need to do anything else?
@bjohas Hm, mediator code should have been updated. Could you try removing and adding the extension?
Also, you need extension v1.4.0. For Firefox it's been published already, but for Chrome the verification usually takes quite some time because of the permissions the extension needs (I missed it, but it turns out that 1.3.0 wasn't even published :grimacing: ). If you wanna try soon, you can install unpacked extension in Chrome. The new version of extension has the handler for the new "update_tabs" command.
I've reinstalled the mediator
Oh right, that doesn't restart the mediator process actually. bt install
just writes the path to the mediator file into config files so that a browser knows what to run when extension is loaded.
@balta2ar - thank you so much. Yes, I don't have 1.4.0 yet obviously, but was wondering whether that was needed. Let me do the unpacked extension.
Edit: Actually, 1.4.0 is available on the store!
Hi @balta2ar. I have
bt install
However
bt navigate b.1.2 "https://www.google.com/"
still gives me
...
urllib.error.HTTPError: HTTP Error 404: NOT FOUND
Any other ideas?
(python3.10, Ubuntu 22.04)
@bjohas I'm positive it is some sort of inconsistency between how you pip install --upgrade brotab
and the code that browser runs (mediator). If you disable and enable the extension, it reloads mediator native app, which prints the following upon the startup:
$ cat /tmp/brotab_mediator.log | grep 'Loading .env file:'
2022-05-30 09:43:16,179 840512 INFO env.py:29:load_dotenv Loading .env file: /home/ybochkarev/.config/brotab/brotab.env
try doing that and see if you have that line (it was added after 1.4.0). If you don't, you're running the old version of mediator, which is actually evident from 404 error anyway, but just to be sure.
In that case look into $HOME/.config/google-chrome/NativeMessagingHosts/brotab_mediator.json
(from bt install
output) and see what path
key says. That's the path to the mediator script. I bet you might see the difference between that path
key and what which bt
says. Maybe you installed bt
with --user
before?
Hi @balta2ar - so yes, I did install with --user
. Thanks - have uninstalled and reinstalled. I do have this line
$ cat /tmp/brotab_mediator.log | grep 'Loading .env file:'
2022-05-30 21:08:00,164 359799 INFO env.py:29:load_dotenv Loading .env file: /home/user/.config/brotab/brotab.env
However, for me, /home/user/.config/brotab/brotab.env
does not exist. Does that matter?
The paths seem to be ok:
$ cat .config/google-chrome/NativeMessagingHosts/brotab_mediator.json
{
"name": "brotab_mediator",
"description": "This mediator exposes interface over TCP to control browser's tabs",
"path": "/usr/local/bin/bt_mediator",
"type": "stdio",
"allowed_extensions": [ "brotab_mediator@example.org" ],
"allowed_origins": [
"chrome-extension://mhpeahbikehnfkfnmopaigggliclhmnc/"
]
}
and
$ which bt
/usr/local/bin/bt
However, I still get the urllib.error.HTTPError: HTTP Error 404: NOT FOUND
.
Any more ideas?
OK - it works!
The problem with urllib.error.HTTPError: HTTP Error 404: NOT FOUND
the not related to this, but was related to 'stale' browsers. Or at least, if I reboot, the problem doesn't occur.
It's unclear to me why the error occurs here, i.e., when addressing a specific tab? E.g., with bt active
, sure, it has to go to all clients/windows, but with bt navigate
, it addresses a specific one?
Can brotab replace the url in an active tab?
Suppose I have a tab open in a browser with url https://www.something.com/. Is there a brotab command to redirect that tab to another url? (I.e., without opening / closing tabs.)
Many thanks!