Last active
July 31, 2024 11:41
-
-
Save dewomser/7b525aa4c94a612f90b9c77fc7d99e35 to your computer and use it in GitHub Desktop.
copy URL from Firefox to Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## ACHTUNG ! | |
## Only for X / Xorg | |
# xdotool is necessary | |
# Search for the visible Firefox window(s) and get its window ID | |
window_id=$(xdotool search --onlyvisible --class "firefox") | |
# Send the keyboard shortcut to open the URL bar, copy the URL to clipboard and then close the URL bar by sending the Escape key. | |
# The command is sent to the Firefox window with the specified ID using the --window option. | |
xdotool key --window $window_id --delay 20 --clearmodifiers ctrl+l ctrl+c Escape | |
# Get the URL from clipboard | |
# url=$(xsel -ob) | |
url=$(xclip -selection clipboard -o) | |
echo $url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Funktioniert mit Xorg und Wayland . Gerade getestet.