random game from cartridges.

This commit is contained in:
CronyAkatsuki 2023-12-10 18:54:28 +01:00
parent 024b5696ab
commit 829052147b

9
rand-game Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
random=$(jq 'select(.hidden != true) | select(.removed != true) | select(.name | contains("Proton") | not) | select(.name | contains("Steam") | not) | input_filename' -r "$HOME"/.local/share/cartridges/games/*.json | sort -R | head -n 1)
name=$(jq '.name' -r "$random")
exec=$(jq '.executable | if type == "array" then .[] end' -r "$random")
answer=$(printf "yes\nno" | dmenu -p "Want to play $name?")
[ "$answer" = "yes" ] && eval "$exec" || exit