2020-02-10 01:09:45 -05:00
|
|
|
#!/bin/bash
|
2020-02-14 14:37:01 -05:00
|
|
|
export TITLE="Worlds Linux Wrapper"
|
2020-02-10 01:09:45 -05:00
|
|
|
export WORLDSDIR="$(dirname "$(readlink -f "$0")")"
|
|
|
|
export WINEPREFIX=$WORLDSDIR/prefix
|
|
|
|
export WORLDSINSTALL="$WINEPREFIX/drive_c/Program Files/Worlds/"
|
|
|
|
export WINEARCH=win32
|
|
|
|
cd "$WORLDSINSTALL"
|
|
|
|
mkdir -p $WORLDSDIR/backups $WORLDSDIR/themes
|
|
|
|
|
2020-02-14 14:37:01 -05:00
|
|
|
export WINE=$(which wine)
|
|
|
|
|
2020-02-10 01:09:45 -05:00
|
|
|
main() {
|
|
|
|
sel=$(zenity \
|
2020-02-14 14:37:01 -05:00
|
|
|
--title="$TITLE" \
|
2020-02-10 01:09:45 -05:00
|
|
|
--window-icon="$WORLDSDIR/icon.png" \
|
|
|
|
--width=360 \
|
|
|
|
--height=280 \
|
|
|
|
--cancel-label='Exit' \
|
|
|
|
--list \
|
|
|
|
--text 'WorldsPlayer Linux Wrapper' \
|
|
|
|
--radiolist \
|
|
|
|
--column '' \
|
|
|
|
--column 'Options' \
|
|
|
|
TRUE 'Start Worlds' \
|
2020-02-14 14:37:01 -05:00
|
|
|
FALSE 'Open Worlds folder' \
|
2020-02-10 01:09:45 -05:00
|
|
|
FALSE 'Edit worlds.ini' \
|
2020-02-14 14:37:01 -05:00
|
|
|
FALSE 'Backup Worlds files' \
|
|
|
|
FALSE 'Restore from backup' \
|
|
|
|
FALSE 'Set theme' \
|
|
|
|
FALSE 'Clear Cache' \
|
|
|
|
FALSE 'FORCE KILL' 2>/dev/null )
|
|
|
|
case $sel in
|
|
|
|
'Start Worlds')
|
|
|
|
$WINE "$WORLDSINSTALL/run.exe" ;;
|
2020-02-10 01:09:45 -05:00
|
|
|
'Open Worlds folder')
|
2020-02-14 14:37:01 -05:00
|
|
|
gio open "$WORLDSINSTALL"
|
|
|
|
main ;;
|
2020-02-10 01:09:45 -05:00
|
|
|
'Edit worlds.ini')
|
2020-02-14 14:37:01 -05:00
|
|
|
xdg-open "$WORLDSINSTALL/worlds.ini"
|
|
|
|
main ;;
|
2020-02-10 01:09:45 -05:00
|
|
|
'Backup Worlds files')
|
2020-02-14 14:37:01 -05:00
|
|
|
mkdir -p "$WORLDSDIR/backups"
|
|
|
|
bkup=$(zenity --file-selection --title="Select Backup folder to backup to" --directory --filename="$WORLDSDIR/backups/" --save)
|
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
main
|
|
|
|
else
|
|
|
|
cp -r "$WORLDSINSTALL/worlds.ini" "$bkup/worlds.ini"
|
|
|
|
cp -r "$WORLDSINSTALL/gamma.avatars" "$bkup/gamma.avatars"
|
|
|
|
cp -r "$WORLDSINSTALL/gamma.worldsmarks" "$bkup/gamma.worldsmarks"
|
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
zenity --error --text="Could not successfully backup files." --width=240 --height=40 --title="$TITLE - Backup"
|
|
|
|
else
|
|
|
|
zenity --info --text="Personal world files successfully backed up." --width=240 --height=40 --title="$TITLE - Backup"
|
|
|
|
fi
|
|
|
|
main
|
|
|
|
fi ;;
|
2020-02-10 13:15:45 -05:00
|
|
|
'Restore from backup')
|
|
|
|
mkdir -p "$WORLDSDIR/backups"
|
2020-02-10 01:09:45 -05:00
|
|
|
rbkup=$(zenity --file-selection --title="Select Backup folder to restore from" --directory --filename="$WORLDSDIR/backups/")
|
2020-02-10 02:10:54 -05:00
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
main
|
|
|
|
else
|
|
|
|
cp -r "$rbkup/worlds.ini" "$WORLDSINSTALL/worlds.ini"
|
|
|
|
cp -r "$rbkup/gamma.avatars" "$WORLDSINSTALL/gamma.avatars"
|
|
|
|
cp -r "$rbkup/gamma.worldsmarks" "$WORLDSINSTALL/gamma.worldsmarks"
|
2020-02-14 14:37:01 -05:00
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
zenity --error --text="Could not successfully restore files." --width=240 --height=40 --title="$TITLE - Restore"
|
|
|
|
else
|
|
|
|
zenity --info --text="Personal world files successfully restored." --width=240 --height=40 --title="$TITLE - Restore"
|
|
|
|
fi
|
2020-02-10 02:10:54 -05:00
|
|
|
main
|
|
|
|
fi ;;
|
2020-02-10 01:09:45 -05:00
|
|
|
'Set theme' )
|
2020-02-10 13:15:45 -05:00
|
|
|
mkdir -p "$WORLDSDIR/themes"
|
2020-02-10 01:09:45 -05:00
|
|
|
seltheme=$(zenity --file-selection --title="Select a theme folder" --directory --filename="$WORLDSDIR/themes/")
|
2020-02-10 02:10:54 -05:00
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
main
|
|
|
|
else
|
|
|
|
for i in $seltheme/*;
|
|
|
|
do FILENAME="$(basename $i)"
|
|
|
|
echo "$seltheme/$FILENAME >> $WORLDSINSTALL/$FILENAME"
|
|
|
|
ln -sf "$seltheme/$FILENAME" "$WORLDSINSTALL/$FILENAME"
|
|
|
|
done
|
2020-02-14 14:37:01 -05:00
|
|
|
zenity --info --text="Successfully set theme to $(basename $seltheme)." --width=240 --height=40 --title="$TITLE - Theme"
|
2020-02-10 02:10:54 -05:00
|
|
|
main
|
|
|
|
fi ;;
|
2020-02-10 01:09:45 -05:00
|
|
|
'Clear Cache')
|
2020-02-14 14:37:01 -05:00
|
|
|
CDSIZE=$(du -sh "$WORLDSINSTALL/cachedir" | cut -f1)
|
|
|
|
if [ -d "$WORLDSINSTALL/cachedir" ]; then
|
|
|
|
rm -rf "$WORLDSINSTALL/cachedir"
|
|
|
|
if [ ! -d "$WORLDSINSTALL/cachedir" ]; then
|
|
|
|
zenity --info --text="$CDSIZE were successfully cleared." --width=240 --height=40 --title="$TITLE - Cachedir"
|
|
|
|
else
|
|
|
|
zenity --error --text="Something went wrong." --width=240 --height=40 --title="$TITLE - Cachedir"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
zenity --error --text="Cachedir doesn't exist! Was it already cleared?" --width=240 --height=40 --title="$TITLE - Cachedir"
|
|
|
|
fi
|
|
|
|
main ;;
|
|
|
|
'FORCE KILL' )
|
|
|
|
killall WorldsPlayer.exe run.exe javaw.exe jrew.exe
|
|
|
|
zenity --error --text="Killed all possible running processes of Worlds." --width=240 --height=40 --title="$TITLE - Kill"
|
|
|
|
main ;;
|
|
|
|
esac
|
2020-02-10 01:09:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|