dmenu-scripts/dmenu-games

43 lines
708 B
Plaintext
Raw Permalink Normal View History

2022-04-22 12:48:51 +02:00
#!/bin/sh
2021-05-01 09:12:33 +02:00
2022-04-22 12:48:51 +02:00
# dmenu script to open up my games
2023-11-04 22:03:43 +01:00
load_config() {
. $HOME/.config/dmenu/config
}
2022-07-17 11:03:13 +02:00
2023-11-04 22:03:43 +01:00
get_category() {
category=$(game-run list | $DMENU -p "Choose game category:")
2021-05-01 09:12:33 +02:00
2023-11-04 22:03:43 +01:00
[ -z "$category" ] && exit 0
2022-05-27 17:32:44 +02:00
}
2022-05-22 19:36:32 +02:00
2023-11-04 22:03:43 +01:00
menu() {
while [ -z "$game" ]; do
[ -z "$1" ] && game=$(game-run list "$category" | sed '/-18+/d' | $DMENU -p "Choose game to run:")
2023-11-04 22:03:43 +01:00
[ "$1" = "-a" ] && game=$(game-run list "$category" | $DMENU -p "Choose game to run:")
2023-11-04 22:03:43 +01:00
[ -z "$game" ] && get_category
done
}
2022-05-22 19:36:32 +02:00
2023-11-04 22:03:43 +01:00
launch_game() {
if game-run launch "$game"; then
quick-notify "Game run" "Launching $game"
else
quick-notify "Game run" "Failed to launch $game"
fi
}
2022-05-22 19:36:32 +02:00
2023-11-04 22:03:43 +01:00
main() {
load_config
2023-11-04 22:03:43 +01:00
get_category
2023-11-04 22:03:43 +01:00
menu $@
2023-11-04 22:03:43 +01:00
launch_game
}
2022-05-27 17:32:44 +02:00
main $@