More conversion to a modular system.
This commit is contained in:
parent
e892da65c8
commit
6e4d7bae8d
35
.includes/desktop.sh
Normal file
35
.includes/desktop.sh
Normal file
@ -0,0 +1,35 @@
|
||||
# Create desktop launcher file
|
||||
desktop_launcher() {
|
||||
local desktopFile="${HOME}/audiogame-manager.desktop"
|
||||
if [[ -e "${desktopFile}" ]]; then
|
||||
echo "the file ${desktopFile} exists. Cannot create the launcher."
|
||||
exit 1
|
||||
fi
|
||||
local dotDesktop
|
||||
local terminal
|
||||
# Try to find an accessible terminal
|
||||
for i in mate-terminal lxterminal terminator gnome-terminal ; do
|
||||
if command -v $i &> /dev/null ; then
|
||||
terminal="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
dotDesktop=('[Desktop Entry]'
|
||||
'Name=Audiogame manager'
|
||||
'GenericName=Audiogame Manager'
|
||||
'Comment=Play audio games'
|
||||
"Exec=${terminal} -t \"Audiogame Manager\" -e \"/usr/bin/bash -c 'nohup $(readlink -e "$0") 2> /dev/null'\""
|
||||
'Terminal=false'
|
||||
'Type=Application'
|
||||
'StartupNotify=false'
|
||||
'Keywords=game;'
|
||||
'Categories=Game;'
|
||||
'Version=1.0')
|
||||
for i in "${dotDesktop[@]}" ; do
|
||||
echo "$i" >> "${desktopFile}"
|
||||
done
|
||||
desktop-file-install --dir "${HOME}/.local/share/applications" -m 755 "${desktopFile}"
|
||||
xdg-desktop-icon install ~/.local/share/applications/audiogame-manager.desktop
|
||||
rm "${desktopFile}"
|
||||
exit 0
|
||||
}
|
@ -22,6 +22,67 @@ check_requirements() {
|
||||
return 0
|
||||
}
|
||||
|
||||
download() {
|
||||
local source=($@)
|
||||
for i in "${source[@]}" ; do
|
||||
local dest="${i##*/}"
|
||||
dest="${dest//%20/ }"
|
||||
dest="${dest#*\?filename=}"
|
||||
dest="${dest%\?*}"
|
||||
# Remove the destination file if it is empty.
|
||||
[[ -s "${cache}/${dest}" ]] || rm -f "${cache}/${dest}" 2> /dev/null
|
||||
if [[ "${redownload}" == "true" ]] && [[ -e "${cache}/${dest}" ]]; then
|
||||
rm -v "${cache}/${dest}"
|
||||
fi
|
||||
# Skip if the item is in cache.
|
||||
[[ -e "${cache}/${dest}" ]] && continue
|
||||
{ if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" ; then
|
||||
echo "Could not download \"$i\"..."
|
||||
exit 1
|
||||
fi; } | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Downloading \"$dest\" from \"$i\"" -1 -1
|
||||
local downloadError=1
|
||||
case "${dest##*.}" in
|
||||
"pk3"|"zip")
|
||||
unzip -tq "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Validating ${dest##*.} file" -1 -1 --stdout
|
||||
downloadError=$?
|
||||
;;
|
||||
"7z")
|
||||
7z t "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Validating 7z file" -1 -1 --stdout
|
||||
downloadError=$?
|
||||
;;
|
||||
"exe")
|
||||
# Check if it's a valid Windows executable by looking at the MZ header
|
||||
hexdump -n 2 -v -e '/1 "%02X"' "${cache}/${dest}" | grep -q "4D5A"
|
||||
downloadError=$?
|
||||
;;
|
||||
"wad")
|
||||
if [[ "$(file -b --mime-type "${cache}/${dest}")" != "application/octet-stream" ]]; then
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Add HTML check for other file types
|
||||
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
||||
echo "File not found: \"$i\" (HTML document probably 404)"
|
||||
downloadError=1
|
||||
else
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ $downloadError -ne 0 ]]; then
|
||||
rm -fv "${cache}/${dest}"
|
||||
dialog --backtitle "Audio Game Manager" \
|
||||
--infobox "Error downloading \"${dest}\". Installation cannot continue." -1 -1 --stdout
|
||||
alert
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to open urls across OS.
|
||||
open_url() {
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
|
@ -56,6 +56,33 @@ echo "Loading documentation, please wait..."
|
||||
exit 0
|
||||
}
|
||||
|
||||
help() {
|
||||
echo "${0##*/}"
|
||||
echo "Released under the terms of the Common Public Attribution License Version 1.0"
|
||||
echo -e "This is a Stormux project: https://stormux.org\n"
|
||||
echo -e "Usage:\n"
|
||||
echo "With no arguments, open the game launcher."
|
||||
for i in "${!command[@]}" ; do
|
||||
echo "-${i/:/ <parameter>}: ${command[${i}]}"
|
||||
done | sort
|
||||
echo
|
||||
echo "Some settings that are often used can be stored in a settings.conf file."
|
||||
echo "If wanted, place it at the following location:"
|
||||
echo "${configFile%/*}/settings.conf"
|
||||
echo "The syntax is variable=\"value\""
|
||||
echo
|
||||
echo "ipfsGateway=\"https://ipfs.stormux.org\" # Gateway to be used for ipfs downloads."
|
||||
echo "noCache=\"true\" # Do not keep downloaded items in the cache."
|
||||
echo "noqjoypad=\"true\" # Do not launch qjoypad."
|
||||
echo "norh=\"true\" # Do not install RHVoice."
|
||||
echo "redownload=\"true\" # Redownload sources, do not use the version stored in cache."
|
||||
echo "voiceName=\"voicename\" # Select the voice to be installed (default Bdl)."
|
||||
echo "defaultVoice=\"voicename\" # Select the default voice to use for the bottle, e.g. MSMike or RHVoice."
|
||||
echo "defaultRate=\"Default voice rate for the bottle, default 7, may not work in all games. Values 1-9 or A."
|
||||
echo "winedebug=\"flag(s)\" # Set wine debug flags, useful for development."
|
||||
exit 0
|
||||
}
|
||||
|
||||
license() {
|
||||
cat << EOF
|
||||
■The contents of this file are subject to the Common Public Attribution
|
||||
|
@ -3,44 +3,6 @@
|
||||
# Dialog accessibility
|
||||
export DIALOGOPTS='--no-lines --visit-items'
|
||||
|
||||
|
||||
# Create desktop launcher file
|
||||
desktop_launcher() {
|
||||
local desktopFile="${HOME}/audiogame-manager.desktop"
|
||||
if [[ -e "${desktopFile}" ]]; then
|
||||
echo "the file ${desktopFile} exists. Cannot create the launcher."
|
||||
exit 1
|
||||
fi
|
||||
local dotDesktop
|
||||
local terminal
|
||||
# Try to find an accessible terminal
|
||||
for i in mate-terminal lxterminal terminator gnome-terminal ; do
|
||||
if command -v $i &> /dev/null ; then
|
||||
terminal="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
dotDesktop=('[Desktop Entry]'
|
||||
'Name=Audiogame manager'
|
||||
'GenericName=Audiogame Manager'
|
||||
'Comment=Play audio games'
|
||||
"Exec=${terminal} -t \"Audiogame Manager\" -e \"/usr/bin/bash -c 'nohup $(readlink -e "$0") 2> /dev/null'\""
|
||||
'Terminal=false'
|
||||
'Type=Application'
|
||||
'StartupNotify=false'
|
||||
'Keywords=game;'
|
||||
'Categories=Game;'
|
||||
'Version=1.0')
|
||||
for i in "${dotDesktop[@]}" ; do
|
||||
echo "$i" >> "${desktopFile}"
|
||||
done
|
||||
desktop-file-install --dir "${HOME}/.local/share/applications" -m 755 "${desktopFile}"
|
||||
xdg-desktop-icon install ~/.local/share/applications/audiogame-manager.desktop
|
||||
rm "${desktopFile}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# Wine configuration section
|
||||
|
||||
clear_cache() {
|
||||
@ -63,67 +25,6 @@ clear_cache() {
|
||||
echo "Cache deleted."
|
||||
}
|
||||
|
||||
download() {
|
||||
local source=($@)
|
||||
for i in "${source[@]}" ; do
|
||||
local dest="${i##*/}"
|
||||
dest="${dest//%20/ }"
|
||||
dest="${dest#*\?filename=}"
|
||||
dest="${dest%\?*}"
|
||||
# Remove the destination file if it is empty.
|
||||
[[ -s "${cache}/${dest}" ]] || rm -f "${cache}/${dest}" 2> /dev/null
|
||||
if [[ "${redownload}" == "true" ]] && [[ -e "${cache}/${dest}" ]]; then
|
||||
rm -v "${cache}/${dest}"
|
||||
fi
|
||||
# Skip if the item is in cache.
|
||||
[[ -e "${cache}/${dest}" ]] && continue
|
||||
{ if ! curl -L4 -C - --retry 10 --output "${cache}/${dest}" "${i}" ; then
|
||||
echo "Could not download \"$i\"..."
|
||||
exit 1
|
||||
fi; } | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Downloading \"$dest\" from \"$i\"" -1 -1
|
||||
local downloadError=1
|
||||
case "${dest##*.}" in
|
||||
"pk3"|"zip")
|
||||
unzip -tq "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Validating ${dest##*.} file" -1 -1 --stdout
|
||||
downloadError=$?
|
||||
;;
|
||||
"7z")
|
||||
7z t "${cache}/${dest}" | dialog --backtitle "Audio Game Manager" \
|
||||
--progressbox "Validating 7z file" -1 -1 --stdout
|
||||
downloadError=$?
|
||||
;;
|
||||
"exe")
|
||||
# Check if it's a valid Windows executable by looking at the MZ header
|
||||
hexdump -n 2 -v -e '/1 "%02X"' "${cache}/${dest}" | grep -q "4D5A"
|
||||
downloadError=$?
|
||||
;;
|
||||
"wad")
|
||||
if [[ "$(file -b --mime-type "${cache}/${dest}")" != "application/octet-stream" ]]; then
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Add HTML check for other file types
|
||||
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
|
||||
echo "File not found: \"$i\" (HTML document probably 404)"
|
||||
downloadError=1
|
||||
else
|
||||
downloadError=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ $downloadError -ne 0 ]]; then
|
||||
rm -fv "${cache}/${dest}"
|
||||
dialog --backtitle "Audio Game Manager" \
|
||||
--infobox "Error downloading \"${dest}\". Installation cannot continue." -1 -1 --stdout
|
||||
alert
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_bottle() {
|
||||
# Handles games that use the same wine bottle
|
||||
case "${game}" in
|
||||
@ -289,33 +190,6 @@ get_steam() {
|
||||
exit 1; }
|
||||
}
|
||||
|
||||
help() {
|
||||
echo "${0##*/}"
|
||||
echo "Released under the terms of the Common Public Attribution License Version 1.0"
|
||||
echo -e "This is a Stormux project: https://stormux.org\n"
|
||||
echo -e "Usage:\n"
|
||||
echo "With no arguments, open the game launcher."
|
||||
for i in "${!command[@]}" ; do
|
||||
echo "-${i/:/ <parameter>}: ${command[${i}]}"
|
||||
done | sort
|
||||
echo
|
||||
echo "Some settings that are often used can be stored in a settings.conf file."
|
||||
echo "If wanted, place it at the following location:"
|
||||
echo "${configFile%/*}/settings.conf"
|
||||
echo "The syntax is variable=\"value\""
|
||||
echo
|
||||
echo "ipfsGateway=\"https://ipfs.stormux.org\" # Gateway to be used for ipfs downloads."
|
||||
echo "noCache=\"true\" # Do not keep downloaded items in the cache."
|
||||
echo "noqjoypad=\"true\" # Do not launch qjoypad."
|
||||
echo "norh=\"true\" # Do not install RHVoice."
|
||||
echo "redownload=\"true\" # Redownload sources, do not use the version stored in cache."
|
||||
echo "voiceName=\"voicename\" # Select the voice to be installed (default Bdl)."
|
||||
echo "defaultVoice=\"voicename\" # Select the default voice to use for the bottle, e.g. MSMike or RHVoice."
|
||||
echo "defaultRate=\"Default voice rate for the bottle, default 7, may not work in all games. Values 1-9 or A."
|
||||
echo "winedebug=\"flag(s)\" # Set wine debug flags, useful for development."
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_wine() {
|
||||
# Requires wine version, e.g. 7.7 and architecture, 32|64
|
||||
if [[ $# -ne 2 ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user