Skip to content

Instantly share code, notes, and snippets.

@nottux
Last active June 16, 2021 10:20
Show Gist options
  • Save nottux/8943071b5feab818561a477acc9d6cbf to your computer and use it in GitHub Desktop.
Save nottux/8943071b5feab818561a477acc9d6cbf to your computer and use it in GitHub Desktop.
extracting game launcher in bash
#!/bin/bash
process_name="$1"
case "$1" in
openarena)
t=/tmp/openarena_extracting
d='/dev/shm/openarena-0.8.8'
e='./openarena.x86_64'
f='/media/utku3/flash_drive/GAMING/openarena/openarena-0.8.8.tar.xz'
;;
xonotic)
t=/tmp/xonotic_extracting
d='/dev/shm/Xonotic'
e='./xonotic-linux64-glx'
f='/media/utku3/flash_drive/GAMING/xonotic/Xonotic.tar.xz'
;;
UrT)
t=/tmp/urbanterror_extracting
d='/dev/shm/UrbanTerror43'
e='./Quake3-UrT.x86_64'
f='/media/utku3/flash_drive/GAMING/urbanterror/UrbanTerror43.tar.xz'
;;
esac
b=($(ls -rt -d -1 /media/utku3/flash_drive/beaetrice/{*,*}))
run () { if pgrep $process_name ; then beatrice_condemns_you ; fi ; cd $d ; gamemoderun $e ; }
beatrice_condemns_you () { xcowsay --image ${b[$(shuf -i 0-$(("${#b[@]}"-1)) -n1)]} you\'ve double clicked I suppose ; exit ; }
cd /dev/shm
if ls $d
then if ls $t
then echo line 36
beatrice_condemns_you
else echo line 38
run
fi
else echo line 41
mkfifo $t
tar -kxf $f &>$t &
if grep -m 1 'File exists' $t
then echo line 45
beatrice_condemns_you
else echo line 47
rm $t
run
fi
fi
echo line 52
@nottux
Copy link
Author

nottux commented Jun 16, 2021

for some reason launching this through openbox de (via desktop file launching the script file) fifo file doesn't exist!
But kde doesn't have that problem!
I've updated the script to use fifo file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment