3 ms·
It's not necessary coding work for someone who intends to use the project themselves and can run tail -f /var/some-log-from-a-clipboard-daemon | grep big-t
by strken 5y ago
It's not necessary coding work for someone who intends to use the project themselves and can run
tail -f /var/some-log-from-a-clipboard-daemon | grep big-tld-regex
They asked for a project idea and he gave them a product idea.
- forgotmypw17 5y agoI would be quite happy with this, actually. I wouldn't even bother with the tld regex and just settle for "http" The part I'm missing is what to tail?
- tremon 5y agoThere is nothing to tail, because (FAFAIK) there are no clipboard events in Linux (well, in X). The best you can do is poll xclip every X ms, so you'd get: while sleep .2 ; do xclip -o ; done | uniq | grep -E 'https?:' but that is pretty wasteful of resources. Luckily processes are cheap on Linux :)
- forgotmypw17 5y agoThank you! I can't imagine myself clipping something more than once 5-10 seconds, so I can set the interval to that. I want to take this moment to remind you that the Web includes http, not just https, and ignoring it is a failure at accessibility and compatibility. For myself a week from now looking for this, here is the version which works for me: while true; do xclip -o | uniq | grep ^http > ~/url.txt ; sleep 5; done Thank you again, this will make my life much easier.
- pbhjpbhj 5y agoPlasma/KDE's Klipper clipboard app has Actions that will do this, fwiw. http://linux-blog.org/make-klipper-work-for-you/ http://linux-blog.org/make-klipper-work-for-you/. You could probably do it very simply by remapping ctrl+c depending on your DE.
- mike_hock 5y agoimport pyperclip import re url_regex = re.compile('^(ftp|https?)') while True: text = pyperclip.waitForNewPaste() if url_regex.match(text): print(text) Seems like a clean, blocking API. I peeked at the source code. It's polling at 10ms intervals under the hood. ... LOL.