Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Is there a way to make finch tile it's 'windows'? I'm getting tired of constantly having to alt+m / r things around.

If not, is there another console-based solution like finch that supports tiling?

Adbot
ADBOT LOVES YOU

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

I'm trying to learn how to best write shell scripts. I have the following script for downloading YouTube videos as MP3 and injecting them with metadata + cover art:

code:
#!/bin/bash

yt-dlp \
    --windows-filenames \
    -x \
    --audio-format mp3 \
    --audio-quality 0 \
    --embed-metadata \
    --embed-thumbnail \
    --convert-thumbnails png \
    --exec-before-download "ffmpeg -i %(thumbnails.-1.filepath)q -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\" _%(thumbnails.-1.filepath)q" \
    --exec-before-download "rm %(thumbnails.-1.filepath)q" \
    --exec-before-download "mv _%(thumbnails.-1.filepath)q %(thumbnails.-1.filepath)q" \
    $1

$SHELL
I have it aliased in my .bashrc as this:
code:
alias music='exec /home/hovercastle/tools/scripts/music.sh'
When I try to chain multiple executions of this alias:
pre:
music url1 && music url2
it only runs the first one. What am I missing here?

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Thanks for those replies, that is a huge help.

hifi posted:

So, is yt-dlp returning an error? why do you have the $SHELL at the end there? etc
AFAICT yt-dlp is not returning any errors.
Adding $SHELL to the end is (supposedly) to ensure the script doesn't kill my shell and drop my ssh connection. At least that's what superuser says haha

pseudorandom name posted:

Also you don't need a shell alias, ~/bin and ~/.local/bin are probably already in your path.
Where should I be putting scripts like this ideally?

Volguus posted:

Just make your script executable (chmod u+x) and remove the exec in the alias and you should be golden.
What does chmod u+x do? I normally just do chmod +x

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Cool, thank you.

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

hifi posted:

If it only runs the first one then it's returning something other than zero; '&&' is a logical AND, so if the first one is false then there's no way the entire statement can be anything other than false.

How do I debug this? Is there an equivalent of try/catch for bash scripts?

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Yeah. It works nicely with the exec and $SHELL removed. Thanks everyone.


Saukkis posted:

That sounds like a weird idea, never seen that used before. If you have the link to that advice I'd be interested to see it.

I suspect the $SHELL is also the reason why your command chaining doesn't work, 'music url2' will only be executed after 'music url1' finishes, but it never does since it's running your new shell. If you run your script a bunch of times and then run 'pstree' you will probably see several nested music- and bash-processes.

Also, you may want to use 'music url1 ; music url2' instead. '&&' is used in a situation where you don't want the second command to execute if the first one wasn't succesful.
https://askubuntu.com/questions/20330/how-to-run-a-script-without-closing-the-terminal

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Yaoi Gagarin posted:

just to explain why that question is different from your situation - they want to run the script with a double-click and have it leave the terminal open. you are just trying to run the script from an already open terminal. in your case when the script finishes running you just get back to your current shell anyway.

Much appreciated, that makes sense.

Adbot
ADBOT LOVES YOU

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Inceltown posted:

Just as a side note to all the stuff you've got, you can use $@ so the script will read an arbitrary number of file names instead of having to chain together
code:
music url1; music url2
It would be
code:
music url1 url2 url<n>

Ahhh that's perfect, thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply