Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active November 22, 2023 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dewomser/7b525aa4c94a612f90b9c77fc7d99e35 to your computer and use it in GitHub Desktop.
Save dewomser/7b525aa4c94a612f90b9c77fc7d99e35 to your computer and use it in GitHub Desktop.
copy URL from Firefox to Bash
#!/bin/bash
# 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
@dewomser
Copy link
Author

Funktioniert mit Xorg und Wayland . Gerade getestet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment