omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Copy URL to clipboard from Chromium apps

Open jankeesvw opened this issue 7 months ago • 14 comments

This afternoon I was at Rails World, talking to @dhh, I was asking if there is a way to copy the current URL to the clipboard with a Omarchy web application. We came up with an idea to use a Chrome extension that would be bundled with Omarchy. In this PR there is a bundled Chrome extension that is loaded via the /config/chromium-flags.conf.

Below in the screenshot you'll see an example of how it works. I'm browsing with the preinstalled HEY application, when I press ALT+SHIFT+U the current URL is on my clipboard and I see a small notification.

image

How to test:

cd ~/.local/share/omarchy
gh pr checkout 1458
omarchy-update

pkill chromium # not required

You should see this:

# Running migration (1757021485)
# Install Copy URL extension for Chromium

Then start a chromium browser, et voila.

jankeesvw avatar Sep 04 '25 22:09 jankeesvw

I just pushed an update to this PR, it is now wrapped in the launcher for web apps. Unfortunately it isn't consistently working yet. If you kill all Chromium sessions it works, but if there is still a session active it won't.

jankeesvw avatar Sep 05 '25 05:09 jankeesvw

guess chromium needs atleast one full restart?!

hjanuschka avatar Sep 05 '25 12:09 hjanuschka

guess chromium needs atleast one full restart?!

My solution works when you don't have any other Chromium open, so it has to be the first.

Right now I'm working on making a .crx, which should work.

jankeesvw avatar Sep 05 '25 16:09 jankeesvw

i wonder if we should just patch chromium to have a global hotkey 🤨

hjanuschka avatar Sep 05 '25 17:09 hjanuschka

i wonder if we should just patch chromium to have a global hotkey 🤨

Is that easier to do? I think this extension could work.

jankeesvw avatar Sep 05 '25 17:09 jankeesvw

shouldn't be that hard, extension for me feels a bit heavy, but well on the otherside if we can ship it so that it works reliable

so your PR works if the first chromium that launches has the config to load the extension? if you'd publish the extension to the store, we could just enable it by default via policy (i think this is what is planned for 1-password; or done already)

hjanuschka avatar Sep 05 '25 18:09 hjanuschka

shouldn't be that hard, extension for me feels a bit heavy, but well on the otherside if we can ship it so that it works reliable

so your PR works if the first chromium that launches has the config to load the extension? if you'd publish the extension to the store, we could just enable it by default via policy (i think this is what is planned for 1-password; or done already)

Shipping it to the store is the easiest, but the disadvantage is that this is also an attack vector that could be exploited, if someone overwrites the extension (through my account) they could compromise the browser. That's why I started with making the extension locally.

The flag --load-extension works great, but only if you aren't running Chromium, otherwise it reuses the existing Chromium.

I'll try to make some time this weekend. Just got back from the conference.

jankeesvw avatar Sep 05 '25 18:09 jankeesvw

cant we somehow download it and verify the hash? to protect against tempered extension?

The flag --load-extension works great, but only if you aren't running Chromium, otherwise it reuses the existing Chromium.

yes this is because there can only be one i nstance running, we could add --load-extension= to https://github.com/basecamp/omarchy/blob/master/config/chromium-flags.conf

so no matter how chromium is started it gets the flags

hjanuschka avatar Sep 05 '25 19:09 hjanuschka

Thanks for the pointer! I'll take a look at it tomorrow.

jankeesvw avatar Sep 05 '25 19:09 jankeesvw

Added the Omarchy icon to the extension so people recognize the origin of this extension:

screenshot-2025-09-06_19-23-24

jankeesvw avatar Sep 06 '25 17:09 jankeesvw

so - i am not the one deciding to merge (cc @dhh ) - but overall this looks good to me.

i would like to rename the extension to "omarchy" - and keep it as a place for further stuff - and not making it explicitly only for copy of url.

hjanuschka avatar Sep 07 '25 06:09 hjanuschka

I'm digging this! But let's use ctrl + alt + L as the hotkey to mirror that ctrl + L is how you access the location bar. Let's refer to icon.png in the root of Omarchy folder too. And let's put this under extensions/copy-url at the top level instead of applications.

dhh avatar Sep 07 '25 18:09 dhh

I'm digging this! But let's use ctrl + alt + L as the hotkey to mirror that ctrl + L is how you access the location bar. Let's refer to icon.png in the root of Omarchy folder too. And let's put this under extensions/copy-url at the top level instead of applications.

Nice to hear that you like it, I agree with your suggestions. However there are two minor "issues";

  1. ctrl + alt + L is not available, but ctrl + shift + L is
  2. The icon in the root is an ascii file, can I include a PNG version of the logo in the root?

What do you think?

jankeesvw avatar Sep 07 '25 19:09 jankeesvw

@dhh I just pushed an update to this branch. I went with ctrl + shift + L, since it's close to ctrl + L like you mentioned. I also added a PNG version of the logo in the root and created a symlink from the extension folder to that file. Plus, I moved everything to the suggested folder. :ok_hand:

jankeesvw avatar Sep 07 '25 20:09 jankeesvw

I just rebased this pull request with master after the release of #1540

jankeesvw avatar Sep 10 '25 08:09 jankeesvw

Hmm, I can get this to load, but the hotkey is not getting picked up. Ctrl + Shift + L doesn't do anything. I checked that the extension is loaded, and it is. But yeah, no hotkey is exposed. Not in chromium itself, not in the webapps.

dhh avatar Sep 14 '25 14:09 dhh

Moving it to Alt + Shift + L worked 👌

dhh avatar Sep 15 '25 10:09 dhh

@dhh ah, you noticed my changed. :-)

I just asked some friends to test it. I'm glad it now works on your machine too.

jankeesvw avatar Sep 15 '25 10:09 jankeesvw

Alt+L is nice, thanks! I tested it and it works for me too.

jankeesvw avatar Sep 15 '25 10:09 jankeesvw

I had Alt + L working, but then I couldn't get it working again?? It refused to allow anything but Alt + Shift + L.

dhh avatar Sep 15 '25 10:09 dhh

I had Alt + L working, but then I couldn't get it working again?? It refused to allow anything but Alt + Shift + L.

I had the same issue, strange. There is something funky with these shortcuts. It's not well documented, what should, and what shouldn't work.

But Ctrl-Alt+L works, notification with the world icon:

image

jankeesvw avatar Sep 15 '25 10:09 jankeesvw