Welcome to the most active Linux Forum on the web.
Go Back > Blogs > linux-related notes
User Name


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Handy 1-liner script to copy link addresses in Firefox just by hovering and pressing a key

Posted 09-06-2016 at 11:58 AM by the dsc
Updated 10-30-2016 at 02:11 AM by the dsc (grammerz und orthographicz ure wrongzes)

Let's say, there is a page with several interesting podcasts, you want to download several of them, not all. Don't bother with dozens of right-click-copy-url-then-go-and-paste-somewhere-somehow. Just hover the link and press a custom key that runs this script line:

xdotool click 3 && xdotool mousemove_relative 5 5 && xdotool key a && echo "$(xclip -o)" >> /dev/shm/ffclipboard
For Debian (sid/testing, as of 2016), apparently you should add a "&& xdotool key Return" after "key a".

Evidently, it requires xdotool and xclip, not to mention Firefox itself and some WM/DE that allows you to set a keybinding that just executes it. It's very likely it can be more or less easily adapted to be somewhat cross-browser/application; if I recall xdotool itself can query the active application, and from that you'd use the specific "hotkey" instead of "a", on a case/esac by case basis, or something like that.

"Click 3" is for right click, mousemove_relative is because apparently it requires to just hove over the context menu (even though it doesn't even quite flashes on the screen at all, almost as if it were an internal GUI-less function), to make Firefox acccept the hotkey "a" which, in my case, goes for "copy link location". Xclip appends it into a /dev/shm file that collects the clipboard copied with this command.

Then it's reasonably easier to just use that file directly, even if it may require some editing to get rid of left-overs of previous operations. Which can be avoided by deleting it after you've used anyway.
Posted in Uncategorized
Views 701 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 12:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration