#!/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