#!/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
=> Posted in: s/bash | ๐ random2934
2024-09-23 ยท 4 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
text/gemini; charset=utf-8
This content has been proxied by September (3851b).