From 1e6ddf55ceb9b54af7ad3c5e70a833da37fd0a1a Mon Sep 17 00:00:00 2001 From: Jankees van Woezik Date: Mon, 15 Sep 2025 12:22:28 +0200 Subject: [PATCH] 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 --- config/chromium-flags.conf | 1 + .../extensions/copy-url/background.js | 21 ++++++++++++++++++ default/chromium/extensions/copy-url/icon.png | 1 + .../extensions/copy-url/manifest.json | 19 ++++++++++++++++ icon.png | Bin 0 -> 1555 bytes migrations/1757021485.sh | 3 +++ 6 files changed, 45 insertions(+) create mode 100644 default/chromium/extensions/copy-url/background.js create mode 120000 default/chromium/extensions/copy-url/icon.png create mode 100644 default/chromium/extensions/copy-url/manifest.json create mode 100644 icon.png create mode 100755 migrations/1757021485.sh diff --git a/config/chromium-flags.conf b/config/chromium-flags.conf index 5f560eb..0df58c2 100644 --- a/config/chromium-flags.conf +++ b/config/chromium-flags.conf @@ -1,5 +1,6 @@ --ozone-platform=wayland --ozone-platform-hint=wayland --enable-features=TouchpadOverscrollHistoryNavigation +--load-extension=~/.local/share/omarchy/default/chromium/extensions/copy-url --oauth2-client-id=77185425430.apps.googleusercontent.com --oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT diff --git a/default/chromium/extensions/copy-url/background.js b/default/chromium/extensions/copy-url/background.js new file mode 100644 index 0000000..a2537c5 --- /dev/null +++ b/default/chromium/extensions/copy-url/background.js @@ -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: '' + }); + }); + }); + } +}); diff --git a/default/chromium/extensions/copy-url/icon.png b/default/chromium/extensions/copy-url/icon.png new file mode 120000 index 0000000..e088259 --- /dev/null +++ b/default/chromium/extensions/copy-url/icon.png @@ -0,0 +1 @@ +../../../../icon.png \ No newline at end of file diff --git a/default/chromium/extensions/copy-url/manifest.json b/default/chromium/extensions/copy-url/manifest.json new file mode 100644 index 0000000..d1442a1 --- /dev/null +++ b/default/chromium/extensions/copy-url/manifest.json @@ -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"} +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..09da5008bed2ce1893c505db0376d04478db47d8 GIT binary patch literal 1555 zcmeAS@N?(olHy`uVBq!ia0y~yVAKI&4mO}jWo=(6km4-xh%9Dc;1&j9Muu5)B!DV1 zGo76STr!IbauO>Q0*o0LD&~|<*z0{bK;)?Z>Yxi&9elDfMxD-AE^(C=W@wAJ8icT} z4xUxVnOmcx8B{17uK7bg;$URKhK`Ve!U6#ocEP)ItTcCIRNR{$a!cvn@uz<+<`nOY zIUpS%sr`*f(3Xz-t+H>^xa)1aMM3# z`Z>MnW%HPV>;J}Hoquwc)ZhD89D60j9!%_>Pfny{nzbshiO-zRf(-;2)3EjXut>y{I< z#oUFHuim~@!6G5WkoU^RG{pVY!f(%t4*cdcn8DQcUSo6OvqOsI)%83tsvrJI=J_DY zR5tbVdgXI(rCR4VYX4;y*UZ{usOfLVz`zpV>Eakt!T9#>!QMj-0<0H5c6D%cDl-F>|EF~K7;d}!5Ln7Hc)I$ztaD0e0sw_e8;Jk_ literal 0 HcmV?d00001 diff --git a/migrations/1757021485.sh b/migrations/1757021485.sh new file mode 100755 index 0000000..cb8f4c4 --- /dev/null +++ b/migrations/1757021485.sh @@ -0,0 +1,3 @@ +echo "Install Copy URL extension for Chromium" + +omarchy-refresh-config chromium-flags.conf