Vassal package in Arch User Repository

For desktop icons, etc. take a look at the instructions for running VASSAL on SteamDeck or Android. In particular

Create the file ~/Desktop/VASSAL.desktop with the content

[Desktop Entry]
Type=Application
MimeType=application/x-vassal-module;application/x-vassal-log;application/x-vassal-save
Name=VASSAL
Exec=${HOME}/VASSAL-current/VASSAL.sh
Icon=${HOME}/VASSAL-current/VASSAL.svg
Actions=Run;Edit;
Categories=Games

[Desktop Action Run]
Name=Run
Exec=${HOME}/VASSAL-current/VASSAL.sh -l %f
                                   
[Desktop Action Edit]
Name=Edit
Exec=${HOME}/VASSAL-current/VASSAL.sh -e %f

and make it executable

chmod 755 ~/Desktop/VASSAL.desktop

Note, this assumes you have VASSAL installed in ~/VASSAL-current. If you put VASSAL elsewhere (say in /opt/vassal/current), then change ${HOME}/VASSAL-current in the above to the correct path (e.g., /opt/vassal/current).

Also copy the file to ~/.local/share/applications

cp ~/Desktop/VASSAL.desktop ~/.local/share/applications/

Create the file ~/.local/share/mime/packages/application-x-vassal.xml with the content

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-vassal-module">
    <comment>VASSAL module file</comment>
    <glob pattern="*.vmod"/>
    <icon name="application-x-vassal"/>
  </mime-type>
  <mime-type type="application/x-vassal-log">
    <comment>VASSAL log file</comment>
    <glob pattern="*.vlog"/>
    <icon name="application-x-vassal"/>
  </mime-type>
  <mime-type type="application/x-vassal-save">
    <comment>VASSAL save file</comment>
    <glob pattern="*.vsav"/>
    <icon name="application-x-vassal"/>
  </mime-type>
</mime-info>

Copy the VASSAL icon (in say /opt/vassal/current) to /.local/share/icons/hicolor/scalable/mimetypes

cp ~/VASSAL-current/VASSAL.svg  ~/.local/share/icons/hicolor/scalable/mimetypes/application-x-vassal.svg

Finally, update the Desktop registries with the new information

update-desktop-database ~/.local/share/applications
update-mime-database ~/.local/share/mime

This applies to all desktop environments that support the free-desktop standard, including GNOME, KDE, and Xfce.

Ideally, VASSAL would distribute a script or the like that did this set-up. Something like

#!/bin/bash

VASSAL_DIR=`realpath $(dirname $0)`

# --- For logging purposes -------------------------------------------
msg() {
    if test $verb -lt 1 ; then return ; fi

    echo $@
}

# --- Help message ---------------------------------------------------
usage()
{
    cat <<-EOF
	Usage: $0 [OPTIONS]
	
	Options:
	  -h,--help		     This help
	  -u,--user		     Install for current user only
	  -s,--system		     Install system wide
	  -v,--vassal-path DIR	     VASSAL installation (${VASSAL_DIR})
	  -d,--desktop		     Make desktop short-cut
	  -D,--no-desktop	     Do not make desktop short-cut
	  -V,--verbose		     Be verbose
	  -r,--remove                Remove VASSAL desktop integration
	  
	System-wide (-s,--system) requrires super-user privileges.  Run
	this script with f.ex. 'sudo'.

	Default is to install for current user only.

	By default, no desktop short-cut is not installed.
	EOF
}

# --- Delete a file --------------------------------------------------
del_file() {
    file=$1
    msg "Removing $file"
    if test ! -f $file ; then
        echo "$file does not exist" > /dev/stderr
        return 0
    fi
    rm -f $file 
}

# --- Settings -------------------------------------------------------
user=1
verb=0
app=application-x-vassal
rem=0

# --- Handle command line --------------------------------------------
while test $# -gt 0 ; do
    case x$1 in
        x-h|x--help) usage ; exit 0 ;;
        x-u|x--user) user=1 ;;
        x-s|x--system) user=0 ;;
        x-V|x--verbose) verb=1 ;;
        x-v|x--vassal-path) VASSAL_DIR=$2 ; shift ;;
        x-d|x--desktop) desktop_dir=$HOME/Desktop ;;
        x-D|x--no-desktop) desktop_dir= ;;
        x-r|x--remove|x--uninstall) rem=1 ;; 
        *) echo "$0: Unknown option $1" > /dev/stderr ; exit 1 ;;
    esac
    shift
done

# --- Check VASSAL directory -----------------------------------------
if test ! -f $VASSAL_DIR/VASSAL.sh ; then
    echo "$0: '$VASSAL_DIR' is not a valid VASSAL installation" > /dev/stderr
    exit 1
fi

# --- Set prefix and check privileges --------------------------------
if test $user -gt 0 ; then
    prefix=$HOME/.local
else
    prefix=/usr
    if test $UID -ne 0 ; then
        echo "You need super-user permissions to install in ${prefix}" \
             > /dev/stderr
        exit 0
    fi
fi

# --- Set target directories -----------------------------------------
mimetype_dir=$prefix/share/mime/packages
app_dir=$prefix/share/applications
icon_dir=$prefix/share/icons/hicolor/scalable/mimetypes

# --- Show current settings ------------------------------------------
msg "VASSAL installation: $VASSAL_DIR"
msg "Mime-types:          $mimetype_dir"
msg "Applications:        $app_dir"
msg "Icons:               $icon_dir"

# --- Create desktop launcher(s) -------------------------------------
mk_app() {
    if test $rem -gt 0 ; then
        del_file ${app_dir}/${app}.desktop

        if test x$desktop_dir != x ; then
            del_file ${desktop_dir}/${app}.desktop
        fi
        return 0
    fi
    
    msg "Making desktop launcher in ${app_dir}/${app}.desktop"
    
    name=`mktemp`

    cat <<-EOF > ${name}
	[Desktop Entry]
	Type=Application
	MimeType=application/x-vassal-module;application/x-vassal-log;application/x-vassal-save
	Name=VASSAL
	Exec=${VASSAL_DIR}/VASSAL.sh
	Icon=${app}
	Actions=Run;Edit;
	Categories=Games
	
	[Desktop Action Run]
	Name=Run
	Exec=${VASSAL_DIR}/VASSAL.sh -l %f
	                                   
	[Desktop Action Edit]
	Name=Edit
	Exec=${VASSAL_DIR}/VASSAL.sh -e %f
	EOF
    
    chmod a+rx ${name}
    mkdir -p ${app_dir}
    mv ${name} ${app_dir}/${app}.desktop

    if test "x${desktop_dir}" != "x" ; then
        msg "Making user Desktop short-cut"
        cp ${app_dir}/${app}.desktop
    fi
}

# --- Create mime-type database entry --------------------------------
mk_mime() {
    if test $rem -gt 0 ; then
        del_file ${mimetype_dir}/${app}.xml
        return 0
    fi
    
    msg "Making mime-type entry in ${mimetype_dir}/${app}.xml"
    
    name=`mktemp`

    cat <<-EOF > ${name}
	<?xml version="1.0"?>
	<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
	  <mime-type type="application/x-vassal-module">
	    <comment>VASSAL module file</comment>
	    <glob pattern="*.vmod"/>
	    <icon name="${app}"/>
	  </mime-type>
	  <mime-type type="application/x-vassal-log">
	    <comment>VASSAL log file</comment>
	    <glob pattern="*.vlog"/>
	    <icon name="${app}"/>
	  </mime-type>
	  <mime-type type="application/x-vassal-save">
	    <comment>VASSAL save file</comment>
	    <glob pattern="*.vsav"/>
	    <icon name="${app}"/>
	  </mime-type>
	</mime-info>
	EOF

    chmod a+r ${name}
    mkdir -p ${mimetype_dir}
    mv ${name} ${mimetype_dir}/${app}.xml
}

# --- Make icon ------------------------------------------------------
mk_icon() {
    if test $rem -gt 0 ; then
        del_file ${icon_dir}/${app}.svg
        return 0
    fi
    
    msg "Installing icon ${icon_dir}/${app}.svg"

    mkdir -p ${icon_dir}
    cp $VASSAL_DIR/VASSAL.svg ${icon_dir}/${app}.svg
}


# --- Update databases -----------------------------------------------
update_entries() {
    msg "Updating desktop database"
    
    update-desktop-database ${app_dir}
    update-mime-database `dirname ${mimetype_dir}` 
}


# --- Run everything -------------------------------------------------
mk_app
mk_mime
mk_icon
update_entries

#
# EOF
#

Yours,
Christian

1 Like