#!/bin/ash
# Launcher for some built-in Wine programs
# JakeSFR 2019 GPLv3

export TEXTDOMAIN=fatdog
export OUTPUT_CHARSET=UTF-8

# Command|Name
apps="
clock|Clock
winecfg|Config
wineconsole|Console
control|Control Panel
winefile|File Manager
winhlp32|Help (.hlp) Viewer
iexplore|Internet Explorer
winemine|Mine
notepad|Notepad
progman|Program Manager
regedit|Registry Editor
taskmgr|Task Manager
uninstaller|Uninstaller
winver|Version
wordpad|WordPad
"

which zenity >/dev/null 2>&1 && apps="${apps}winetricks|Winetricks"

HARDSPACE="$(echo -ne '\xc2\xa0')"
apps="${apps// /$HARDSPACE}"

app=$(Xdialog --stdout \
				--no-tags \
				--title "$(gettext "Wine Apps")" \
				--check "$(gettext "Use 'wine64' prefix")" off \
				--menubox "$(gettext "Run selected application:")" 20 30 0 ${apps//|/ })
	
[ $? -ne 0 ] && exit 1

prefix="$(echo "$app" | tail -n 1)"
app="$(echo "$app" | head -n 1)"

if [ "$prefix" = "checked" ]; then
	prefix='wine64'
else
	prefix='wine'
fi

if [ "$app" = "winetricks" ]; then
	exec "$app"
else
	exec "$prefix" "$app"
fi

exit
