-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamelaucher
More file actions
executable file
·29 lines (27 loc) · 1.18 KB
/
gamelaucher
File metadata and controls
executable file
·29 lines (27 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
gamelistfile="$HOME/.cache/gamelaucher-bash/gameslist"
gamesList=$(cat "$gamelistfile")
case "$1" in
help|--help|-h|h)
printf "%s\n" "gameslist [add] <Game Name> <Game Launch Command>"
exit
;;
add|insert|--add|--insert)
[ -z "$2" ] || [ -z "$3" ] && printf "%s\n" "Missing Alias or Command." && exit 1
printf "%s\n" "$gamesList" | awk -F ";" -v mth="$2" '$1 != mth {print $0}' > "$gamelistfile"
printf "Added:\n\tName: %s\n\tCommand: %s\n" "$2" "$3" && printf "%s;%s\n" "$2" "$3" >> "$gamelistfile"
exit
;;
del|delete|--delete|rm|--remove|remove)
[ -z "$2" ] && printf "Missing alias to remove." && exit 1
printf "%s\n" "$gamesList" | awk -F ";" -v mth="$2" '$1 != mth {print $0}' > "$gamelistfile"
exit
;;
*)
esac
gameSelected=$(awk -F ";" '{print $1}' < "$gamelistfile" | dmenu -p 'Games: ')
[ -z "$gameSelected" ] && exit
gameCommand=$(awk -F ";" -v mth="$gameSelected" '$1 == mth {$1="";print $0}' < "$gamelistfile")
printf "Game: %s\nCommand: %s\n" "$gameSelected" "$gameCommand"
printf "%s\n" "$gameCommand" | xargs -I% bash -c %
#${SHELL:-"/bin/sh"} -c ${gameLaunchCommand}