this post was submitted on 15 Aug 2025
38 points (95.2% liked)

Linux

14531 readers
910 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS
 

The goal was to be able to have a function to randomly pick a movie for me to watch.

I made a text file with one movie title per line that included random flicks top-of-my-head, adding 10. Then, I went and exported some imdb lists, which was so handy because csv files. So, export one list, open it in calc; highlight, and then copy the title column. Simple. I pasted it into my movies list file.

I did this maybe 7 times which gave me a good sized list of movies - then, I needed to remove duplicates, so, I saved the file and ran this on it:

cat films.txt | sort | uniq > films2.txt

I opened the new file and double entries were stacked so I could go through and delete redundant rows, of which, there weren't very many. Now, I have a file with 1892 lines, each line being a movie title. Handy.

Of course, now, I need to randomly be able to choose a title (line) from the file because I can't be bothered to open the thing and read through it every time I need some inspiration, or, guidance. That's where shuf comes in - look:

shuf -n 1 films.txt

Dayum! And the final step of my goal is to make this available, so, bash alias and keybind.

I added the following to my ~/.bash_aliases file:

alias pick='shuf -n 1 films.txt'

I made a bash script with the following command in it and then bound the script to some keys in rc.xml:

#!/bin/bash
bash -c 'notify-send -i /usr/share/icons/gnome/256x256/emotes/face-glasses.png -t 5000 "Watch this one" "$(shuf -n 1 films.txt)" '

the keybind:

    <keybind key="C-A-p">
      <action name="Execute">
        <command>sh ~/bin/pick.sh</command>
      </action>
    </keybind>

Awesome linux for every day stuff.

top 7 comments
sorted by: hot top controversial new old
[–] lyda@programming.dev 6 points 11 months ago (1 children)

One quick tip: sort -u films.txt > films2.txt

If you only include the filename you could just feed it to vlc.

[–] Atherel@lemmy.dbzer0.com 2 points 11 months ago

And cut -d ';' -f3 to only output the movie Name (assuming it's in column 3)

[–] illusionist@lemmy.zip 2 points 11 months ago (1 children)

Nice. What would you do better the next time, or how could you improve it?

What about using your jellyfin db for the entries and a simple connection so that it randomly chooses one or multiple videos every 3 hours?

[–] machiner@lemmy.org 1 points 11 months ago

Nothing I could think of readily without some sort of infrastructure support. If you look 'lazy' up in a dictionary you will see my smiling face.

[–] Marafon@sh.itjust.works 2 points 11 months ago

Neat! Thanks for detailing how you set it up!

[–] A_norny_mousse@feddit.org 1 points 11 months ago (1 children)

Ah, Openbox. Or is it already the wayland successor?

[–] machiner@lemmy.org 1 points 11 months ago

Openbox.

All. Day.