Created
March 18, 2020 11:06
-
-
Save darealshinji/ddd95237e4006c7558758fd77c6bd80f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# requires fltk-dialog to be in PATH | |
# https://github.com/darealshinji/fltk-dialog/releases/tag/continuous | |
steamconfig="${HOME%/}/.steam" | |
pidfile="$steamconfig/steam.pid" | |
steambin="$steamconfig/steam/steam.sh" | |
logfile="$(mktemp)" | |
pid_steam=0 | |
pid_launcher=0 | |
# check PID file | |
if [ -r "$pidfile" -a -s "$pidfile" ]; then | |
pid_steam=$(cat "$pidfile") | |
fi | |
# launch Steam | |
if [ ! -x "$steambin" ]; then | |
"$steambin" & # show a useful error message | |
fltk-dialog --title="Error" --text="Cannot launch Steam!" --center | |
exit 1 | |
fi | |
"$steambin" 2>&1 | tee "$logfile" & | |
if [ $pid_steam -ne 0 ]; then | |
# exit if Steam was already running | |
if kill -0 $pid_steam 2>/dev/null ; then | |
exit 0 | |
fi | |
# find an icon to use for the message window | |
icon="$(find /usr/share/icons/hicolor/ -name steam.png | sort -V | tail -1)" | |
if [ -z "$icon" ] && [ -f "/usr/share/pixmaps/steam.png" ]; then | |
icon="/usr/share/pixmaps/steam.png" | |
else | |
icon="$steamconfig/steam/public/steam_tray.ico" | |
fi | |
# show a message window indicating that Steam is about to start | |
fltk-dialog --title="Steam" \ | |
--text="Launching Steam client..." \ | |
--cancel-label="Hide" \ | |
--icon="$icon" \ | |
--progress \ | |
--pulsate \ | |
--center \ | |
--no-escape \ | |
--undecorated & | |
pid_launcher=$! | |
# close message window after the Steam client has launched | |
if [ $pid_launcher -ne 0 ]; then | |
#while ! kill -0 $pid_steam 2>/dev/null ; do | |
# sleep 0.3 | |
# pid_steam=$(cat "$pidfile") | |
#done | |
while ! grep -q "^CApplicationManagerPopulateThread" "$logfile" ; do | |
sleep 0.3 | |
done | |
kill $pid_launcher | |
rm -f "$logfile" | |
fi | |
fi | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment