Copy URL to clipboard from Chromium apps (#1458)

* Copy current URL to clipboard with browser extension

In Omarchy web apps it's impossible to get the curent URL to share it in
another applications. This commit adds a browser extension which is
included by default via the chromium-flags.conf config. With this
extension you can get the current URL via a keyboard shortcut.

The default shortcut for getting the current URL is `Ctrl+Shift+L`, this
shortcut can be changed via this page: chrome://extensions/shortcuts.

* Change the shortcut to Alt+Shift+L

In my testing and research I found out that not all shortcuts
are available as suggested_key. We still want to use L because
that's easy to remember because we associate it with the location bar.

* Improve notification language

* Move it to just Alt + L since that's not used

Better mirrors Ctrl + L as well

* Move this under default/chromium

* Fix symlink

* It didn't like Alt+L alone after all

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
Jankees van Woezik
2025-09-15 12:22:28 +02:00
committed by GitHub
parent 5582c51676
commit 1e6ddf55ce
6 changed files with 45 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
--ozone-platform=wayland --ozone-platform=wayland
--ozone-platform-hint=wayland --ozone-platform-hint=wayland
--enable-features=TouchpadOverscrollHistoryNavigation --enable-features=TouchpadOverscrollHistoryNavigation
--load-extension=~/.local/share/omarchy/default/chromium/extensions/copy-url
--oauth2-client-id=77185425430.apps.googleusercontent.com --oauth2-client-id=77185425430.apps.googleusercontent.com
--oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT --oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT

View File

@@ -0,0 +1,21 @@
chrome.commands.onCommand.addListener((command) => {
if (command === 'copy-url') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const currentTab = tabs[0];
chrome.scripting.executeScript({
target: { tabId: currentTab.id },
func: () => {
navigator.clipboard.writeText(window.location.href);
}
}).then(() => {
chrome.notifications.create({
type: 'basic',
iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==',
title: ' URL copied to clipboard',
message: ''
});
});
});
}
});

View File

@@ -0,0 +1 @@
../../../../icon.png

View File

@@ -0,0 +1,19 @@
{
"manifest_version": 4,
"name": "Copy URL",
"version": "1.0",
"description": "Copy current URL to clipboard, this extension is installed by Omarchy",
"permissions": ["activeTab", "scripting", "notifications"],
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"commands": {
"copy-url": {
"suggested_key": {"default": "Alt+Shift+L"},
"description": "Copy URL"
}
},
"background": {"service_worker": "background.js"}
}

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

3
migrations/1757021485.sh Executable file
View File

@@ -0,0 +1,3 @@
echo "Install Copy URL extension for Chromium"
omarchy-refresh-config chromium-flags.conf