2022-05-21 14:43:48 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# source our .bashrc if present
|
|
|
|
if [ -f "$HOME/.bashrc" ]
|
|
|
|
then
|
|
|
|
. $HOME/.bashrc
|
|
|
|
fi
|
2022-05-21 13:55:52 -07:00
|
|
|
|
|
|
|
SPC_CFG="$HOME/.config/steamcustomrc"
|
|
|
|
COMMANDTYPE=$1
|
|
|
|
|
2022-05-21 14:43:48 -07:00
|
|
|
if [ "$COMMANDTYPE" = "wait-before-run" ]
|
|
|
|
then
|
|
|
|
# client forwards this env to us
|
2022-05-21 13:55:52 -07:00
|
|
|
STEAM_APPID="$SteamGameId"
|
|
|
|
|
2022-05-21 14:43:48 -07:00
|
|
|
# find valid entry, first result only
|
|
|
|
CHECK_GAME=$(grep ":$STEAM_APPID:" "$SPC_CFG" | head -n 1)
|
2022-05-21 13:55:52 -07:00
|
|
|
|
|
|
|
# nothing found? throw a message...
|
2022-05-21 14:43:48 -07:00
|
|
|
if [ -z "$CHECK_GAME" ]
|
|
|
|
then
|
2022-05-21 13:55:52 -07:00
|
|
|
notify-send -a "SteamPlay-Custom" \
|
|
|
|
-i "steam" "SteamPlay-Custom" \
|
|
|
|
"AppID $STEAM_APPID has no entry in $SPC_CFG"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-05-21 14:43:48 -07:00
|
|
|
# grab our alternative
|
|
|
|
RUN_GAME=$(echo "$CHECK_GAME" | cut -d ':' -f 3)
|
|
|
|
|
|
|
|
# check for empty launch parameter
|
|
|
|
if [ -z "$RUN_GAME" ]
|
|
|
|
then
|
|
|
|
notify-send -a "SteamPlay-Custom" \
|
|
|
|
-i "steam" "SteamPlay-Custom" \
|
|
|
|
"No program supplied with AppID in $SPC_CFG"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if steam launch parms are allowed
|
|
|
|
RUN_PARM=$(echo "$CHECK_GAME" | cut -d ':' -f 4)
|
|
|
|
|
|
|
|
# run it
|
|
|
|
if [ "$RUN_PARM" = "parms" ]
|
|
|
|
then
|
|
|
|
PARMARR=( "$@" )
|
|
|
|
ARGLEN=${#PARMARR[@]}
|
|
|
|
GAMEARGS=${PARMARR[@]:2:$ARGLEN-1}
|
|
|
|
exec ${RUN_GAME} ${GAMEARGS}
|
|
|
|
else
|
|
|
|
exec ${RUN_GAME}
|
|
|
|
fi
|
2022-05-21 13:55:52 -07:00
|
|
|
fi
|