💾 Archived View for bbs.geminispace.org › s › bash › 19863 captured on 2024-12-17 at 15:04:14. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
#!/bin/bash shopt -s nullglob; # defining rand function which produces unbiased random number rand() { local max=$((32768 / $1 * $1)) r; while (( (r=$RANDOM) >= max )); do :; done; printf '%s\n' "$(( r % $1 ))"; } pkill mpv; # killing already playing song songs=(~/Music/*) len=${#songs[@]} random_index="$(rand len)" if [[ $len == 0 ]]; then echo "No songs to play :(" exit fi mpv --no-video "${songs[random_index]}" & disown
Sep 23 · 3 months ago
👺 daruma · Sep 23 at 20:07:
Nice! you can also use the -shuffle in MPV but you need a playlist.
🚀 random2934 [OP] · Sep 24 at 05:03:
I thought about just having ```mpv -shuffle ~/Music``` however I couldn't key bind this command since I want Ctrl+Shift+M to play a random song.
👺 daruma · Sep 24 at 05:35:
right but you could do a one liner script with that move -shuffle and chmod +x it to bind it to your ctrl-shift-m too
🚀 random2934 [OP] · Sep 24 at 05:39:
yeah, that would be much simpler :D