Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
It should "Just Work™"
  • Loading branch information
Melechtna authored Aug 5, 2021
1 parent ce13620 commit 75c4b36
Show file tree
Hide file tree
Showing 2 changed files with 378 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# gw2sng
a little script I cooked up to help Guild Wars 2 players on Linux play their songs with as minimal effort as possible.

## Overview

This is a little script I cooked up to help Guild Wars 2 players on Linux play their songs with as minimal effort as possible. It uses autohotkey (which it gets itself) to play the songs as this is the only real method available at the moment.


# If you have an issue that happens with this script, don't bother people over at Lutris or the GW2 forums. Just leave an issue report here in github.

### Manual

I've done everything I could to make ABSOLUTELY sure there's as little tweaking or mucking about with this script as possible for the end user. All you should need to do is run it once, navigate to the folders this script generates in your GW2 folder, which Lutris can open for you, and place/create your ahks in the respective instruments folder, then select them from the menu.

Make sure all of the files end in .ahk or the script won't see them. The number one thing you have to make sure of, is that all of the ahks you copy/create start with #NoTrayIcon, otherwise when AHK creates the tray icon it'll steal the focus away from the game and defeat the purpose of the script.

## Modification

Take it, print it, burn it, shove it somewhere, I really don't care what you do with it. I'd simply appreciate credit if you distribute a modified version of the script, or better yet, push a commit. I make no assumptions that my stuffs good, so if you can do better, go for it.
361 changes: 361 additions & 0 deletions gw2sng.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,361 @@
#!/bin/bash

clear

##Define script itself

restart=$(readlink -f "$0")

##Set lutris prefix and do some magic to get the users wineversion

export WINEPREFIX=`lutris -l 2>&1 | grep "Guild Wars 2" | sed -r "s/^[^|]*\|[^|]*\|[^|]*\|[^|]*\| //" | sed "s/[[:space:]]*//g"`

export WINELOC=`cat ~/.config/lutris/games/guild-wars-2-* | grep "version:" | sed "s/[[:space:]]*version: //"`

export WINE=~/.local/share/lutris/runners/wine/$WINELOC/bin/wine

# https://www.youtube.com/watch?v=YAgRBq2jnz4

export WINEDEBUG=-all

##Check if fsync is enabled, if it is, this arguement has to be passed

#I don't know why, I don't want to know why, I shouldn't have to wonder why
#But this fucking script doesn't work unless we export this variable if
#Fsync is enabled

fsyncchk=`cat ~/.config/lutris/games/guild-wars-2-* | grep "fsync:" | sed "s/[[:space:]]*fsync: //"`

if [ $fsyncchk = true ]; then
export WINEFSYNC=1
fi

##Setup directory variables

ahk=$WINEPREFIX/ahk

root=$WINEPREFIX/gw2songs

bell=$WINEPREFIX/gw2songs/bell

flute=$WINEPREFIX/gw2songs/flute

horn=$WINEPREFIX/gw2songs/horn

harp=$WINEPREFIX/gw2songs/harp

lute=$WINEPREFIX/gw2songs/lute

bell2=$WINEPREFIX/gw2songs/bell2

bass=$WINEPREFIX/gw2songs/bass

musicbox=$WINEPREFIX/gw2songs/musicbox

##Setup directories

if [ ! -d $ahk ]; then
mkdir $ahk && wget -q -P $ahk/ https://www.autohotkey.com/download/ahk.zip && unzip -qq $ahk/ahk.zip && rm $ahk/ahk.zip
fi

if [ ! -d $ahk/Compiler ]; then
wget -q -P $ahk/ https://www.autohotkey.com/download/ahk.zip && unzip -qq $ahk/ahk.zip -d $ahk && rm $ahk/ahk.zip
fi

if [ ! -d $root ]; then
mkdir $root
fi

if [ ! -d $bell ]; then
mkdir $bell
fi

if [ ! -d $flute ]; then
mkdir $flute
fi

if [ ! -d $horn ]; then
mkdir $horn
fi

if [ ! -d $harp ]; then
mkdir $harp
fi

if [ ! -d $lute ]; then
mkdir $lute
fi

if [ ! -d $bell2 ]; then
mkdir $bell2
fi

if [ ! -d $bass ]; then
mkdir $bass
fi

if [ ! -d $musicbox ]; then
mkdir $musicbox
fi

#Please always add "#NoTrayIcon" (without quotations)
#To the top of your added scripts explenation in readme

cd $WINEPREFIX

##Setup instrument select

echo -e "1) Bell 2) Flute \n3) Horn 4) Harp \n5) Lute 6) Bell2 \n7) Bass 8) Music Box \n0) Exit"

read -p "Instrument Choice:" instrument

PS3="Which Song:"

##Setup song list

if [ $instrument -eq 0 ]; then
clear
echo "May all your theories be sound."
exit
fi

if [ $instrument -eq 1 ]; then
clear
unset songs i
fp $songs
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $bell -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$bell/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 2 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $flute -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$flute/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 3 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $horn -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$horn/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 4 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $harp -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$harp/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 5 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $lute -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$lute/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 6 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $bell2 -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$bell2/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 7 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $bass -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$bass/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

if [ $instrument -eq 8 ]; then
clear
unset songs i
while gw2sng= read -r -d $'\0' f; do
songs[i++]="$f"
done < <(find $musicbox -maxdepth 1 -name "*.ahk" -print0 | sed "s/[[:print:]]*\///g")

echo "Press enter to show the list again"
select song in "${songs[@]}" "Back to Instruments" "Exit"; do
case $song in
*.ahk)
echo "Playing $song"
wmctrl -a "Guild Wars 2"
$WINE $ahk/AutoHotkeyU64.exe "$musicbox/$song"
;;
"Back to Instruments")
exec $restart
;;
"Exit")
clear
echo "May all your theories be sound."
break
;;
*)
echo "Skritt brained idiot!"
;;
esac
done
fi

0 comments on commit 75c4b36

Please sign in to comment.