Skip to content

Instantly share code, notes, and snippets.

@rage311
Created November 12, 2016 22:49
Show Gist options
  • Save rage311/e6debeb4feaa2a739fe4845d30a701ea to your computer and use it in GitHub Desktop.
Save rage311/e6debeb4feaa2a739fe4845d30a701ea to your computer and use it in GitHub Desktop.
Launch 3 instances of the EQ client for TAKP (The Al'kabor Project)
#!/usr/bin/env bash
# Command to run on dedicated GPU (optirun, primusrun, DRI_PRIME=1)
#OPTIMUS_CMD="optirun"
# Array of PlayOnLinux shortcut names
POL_SHORTCUT[0]='eqgame (takp_64_1)'
POL_SHORTCUT[1]='eqgame (takp_64_2)'
POL_SHORTCUT[2]='eqgame (takp_64_3)'
# Array of desktop numbers, as wmctrl sees them
DESKTOP_NUMBER[0]=1
DESKTOP_NUMBER[1]=2
DESKTOP_NUMBER[2]=3
# String to use as a prefix for the window names
NAME_PREFIX="takp_"
# For loop from 0 to size of POL_SHORTCUT array - 1
for i in `seq 0 $(expr "${#POL_SHORTCUT[@]}" - 1)`; do
# Add 1 to index to get a base one number for renaming windows
BASE_ONE="$(expr $i + 1)"
# Fork playonlinux/wine process
if [ ! -z "$OPTIMUS_CMD" ]; then
"$OPTIMUS_CMD" playonlinux --run "${POL_SHORTCUT[$i]}" &
else
playonlinux --run "${POL_SHORTCUT[$i]}" &
fi
# Wait until the window exists
while ( ! wmctrl -l | grep 'Default - Wine desktop' -q ); do
sleep 0.5
done
# Rename the window to a unique name
wmctrl -r 'Default - Wine desktop' -N "$NAME_PREFIX""$BASE_ONE" && \
# Move the window to the corresponding workspace/desktop
wmctrl -r "$NAME_PREFIX""$BASE_ONE" -t "${DESKTOP_NUMBER[$i]}" ||
# or exit with a failed status code
exit 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment