33
submitted 15 hours ago* (last edited 15 hours ago) by machiner@lemmy.org to c/linux@programming.dev

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.

you are viewing a single comment's thread
view the rest of the comments
[-] illusionist@lemmy.zip 2 points 15 hours ago

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 15 hours 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.

this post was submitted on 15 Aug 2025
33 points (94.6% liked)

Linux

8924 readers
795 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 2 years ago
MODERATORS