Did i finally do something useful

When i download images or youtube videos, i have to juggle between copying urls and pasting them into a terminal, which is tiresome. I made a script, that monitors the clipboard and echoes changes that happened. All you have to do is pipe it to parallel and copy stuff. It saves me lots of time
#!/bin/bash

clipCont=$(xsel --clipboard)
#echo $clipCont
while sleep 0.5; do
new_clipCont=$(xsel --clipboard)
if ! [[ "$clipCont" == "$new_clipCont" ]];then #If new
echo $new_clipCont
fi
clipCont=$new_clipCont
done

Example:
./script.sh | parallel -L 1 youtube-dl --extract-audio --audio-format opus

pic unrelated

Attached: nextstep1.png (1024x768, 230K)

Bump plz

>Did i finally do something useful

ahahahahahahahahaha
huehuehuehuehuehue
khrkhrkhrkhr
jajajajajajaja

he is asking this question HERE where 99% of people never coded anything

Is it useful?

no idea i don't know this language

go to github or reddit you will have more luck there

This is bash

I still don't know how to use scripts in linux.....

>no idea i don't know this language

Attached: wtf.jpg (190x200, 9K)

This is userful but doesn't it affect performance by checking the clipboard every .5 seconds?

It doesn't affect performance and i you can adjust the rate of refreshing. I will rewrite it in C one day and post it to Jow Forums

>copying urls and pasting them into a termina

Why would you even do this?

Good idea

Too lazy to find a more efficient way?

This is convenient and it works everywhere. I use it for downloading lots of files. I have a script to quickly download from unsplash and i use it with this

Just bind a hotkey in your wm to feed the clipboard to youtube-dl, why would you open a terminal for this?

>bindsym Ctrl+$hyper+m exec cd music && youtube-dl -x --audio-format mp3 --audio-quality 0 `xsel -o`

Why not just a shortcut that feeds current clipboard to your preferred downloader?
That's how I'm watching videos.

You can use it for other stuff. You can run it and grep the urls. If they point to youtube, it opens mpv, if they point to soundcloud, it youtube-dls it. This is just a concept that i never saw anywhere

Do you leave it on permanently? I don't think I'd want things happening whenever I used the clipboard. If I'm copying a url to share with a friend it shouldn't open or download it. And if I have to turn it off in those special cases, it seems like more of a hassle than some dedicated bindings. Also I might want to download a youtube video, or just the music, or open it in mpv, or paste it in a to-watch file. You can't grep my intention of copying a link, but the satisfaction of typing yy+keybinding that does what I want with the clipboard is irreplaceable.

I have a mode for that in i3. When i want it opened, i run meta+shift+z and the next thing copied is grepped and it lets me pick what to do with it in rofi

Not who you're replying to, but recently I've been getting more into bash scripts and what not so forgive me if this is inaccurate, but couldn't you just have it check the clipboard at the time of execution?
> Copy youtube URL into clipboard
> Run Script that grabs url from clipboard
The only way I see needing it constantly monitor the clipboard is if you intend to download multiple youtube videos at once.

Yes. You could alias something to 'xsel -b | youtube-dl' but that defeats the purpose

it's english

Bash question here, is sleep 0.5 ran during or after the do..done command is ran?

>What is youtube downloader add-on?

i don't really see how this is any better than my browser keybind of bind Y hint links spawn youtube-dl {hint-url} in qutebrowser, hint links being an enumerated key combo that shows up over every link on the page

>#!/bin/bash
You fucked up

youtube-dl
I have zsh linked to /bin/bash
This is actually great! I will use this for mpv

>I have zsh linked to /bin/bash
Still a fuckup. #! /bin/sh

What the hell. Why would i do that?

Portability

Ok, makes sense.

>making something so simple this complex
...you do know you youtube-dl supports youtube playlists...right user?

Yes. I would have to put all the stuff in a playlist and then download it and delete the playlist

This also runs it in parallel, not a queue