Need LINUX help

Will Fleming

Senior Member
Joined
Apr 22, 2003
Messages
4,410
Reaction score
424
Location
Adrift on the Pequod
Country
llUnited States
Looks like you can pass VASSAL.sh two (or more) arguments. First one being the extension as per JR's advice above, but also the logfile/save file.

Trying to make a Nautilus script to run VASSAL.sh with both the extension and logfile. Not quite windows, but you could right click a logfile and select 'run script' and then it should load. Can't get it to read the logfile location/name correctly however.
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
Instead of creating a nautilus script or similar, I recommend creating a new mime type. I base my instructions off this: https://stackoverflow.com/questions/14943742/how-to-add-new-mime-type-and-associate-with-new-application, which has a link to a video. Below are all the steps, so you don't have to view that link. I only include the link for reference.

1) In /usr/share/mime/packages, add a new file called VASSAL.xml. You will need to use sudo (or log in as root) to do this. The contents are:

VASSAL.xml said:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/vasl.game">
<comment>vasl saved game</comment>
<glob pattern="*.vsav"/>
</mime-type>
</mime-info>
I am assuming you are using .vsav for your saved vasl games. Change this if you use some other extension.

2) Using sudo or as root, run "update-mime-database /usr/share/mime". This took a few minutes to run on my machine.

3) I created a new directory that isn't with one of the VASSAL versions I have. The directory is called "vasl.script". I moved my vasl.sh (but not VASSAL.sh) to this new directory. If you put vasl in a menu, you need to change your menu to point to this new script. If you create a new directory and previously set your PATH, you will need to change your path to the location with the new script.

Create or change your vasl.sh script in vasl.script:

vasl.sh said:
#!/bin/sh

#
# Execute this file to launch VASSAL on MacOS or Linux
#

# Find where VASSAL is installed, dereferencing symlinks
INSTALL_DIR=$(dirname "$(readlink "$0" || echo "$0")")

cd "$INSTALL_DIR"

../VASSAL-3.2.17/VASSAL.sh ../vasl/vasl-6.4.2.vmod "$@"
I have fixed the path to VASSAL.sh in vasl.sh so it now points to the particular version of VASSAL I want to use ("../VASSAL-3.2.17/VASSAL.sh"). In addition to that change, the new bit is the "$@" in the call to VASSAL.sh. That will pass any filename given by nautilus (or in my case, thunar) in addition to the .vmod at startup.

4) Open a new nautilus/thunar window. Right click on a .vsav file (it should already say "application/vasl.game" in the type column), open with (or similar), custom, browse to your vasl.sh script. Your saved game should now open with vasl.

That's it. At this point running vasl in your menu should open vasl starting with the wizard, while clicking on a .vsav file should open that saved vasl file.

If you use VASSAL for multiple types of games, each with a different extension, you could add more mime-type entries in the VASSAL.xml file:
VASSAL.xml said:
<mime-type type="application/VASSAL.foo.game">
<comment>foo saved game</comment>
<glob pattern="*.vfoo"/>
</mime-type>
[Note that the format for the type is slightly different here than in the version I gave for vasl. In fact the string is arbitrary. It just needs to be different from other mime-types (although perhaps a space is not allowed, but I don't know for certain).]

You would also need to create a new script, perhaps "run_foo.sh", which would point at the right .vmod for your other game.

5) When you get a new version of VASSAL or vasl, you will have to update the vasl.sh script to point to the new VASSAL directory (if you have separate directories for each VASSAL version like I do) and/or the .vmod file.

JR
 
Last edited:

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
A slight variation to the above: instead of installing the VASSAL.xml information globally (for all users on the machine), you can install it locally (for one user). To do so, instead of putting the VASSAL.xml file in /usr/share/mime/packages, put it in ~/.local/share/mime/packages. Instead of running "sudo update-mime-database /usr/share/mime", run "update-mime-database ~/.local/share/mime". Personally I prefer to avoid changing the global settings if I can avoid it. If you have already put the VASSAL.xml file in the global location, delete it and run "sudo update-mime-database /usr/share/mime" again.

JR
 

Will Fleming

Senior Member
Joined
Apr 22, 2003
Messages
4,410
Reaction score
424
Location
Adrift on the Pequod
Country
llUnited States
I will take a look at this, but would post to echo JR's comment about doing the local version instead if possible. Easier to keep your settings as you can just backup your /home/<username> directory when you upgrade. If you know what you are doing, you can just not format your home directory too, but I always suggest a backup.

Will probably try to do this for saves and logfiles both.
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
Going to the bonus level: custom icons

Once you have got your .vsav files associated with vasl.sh, it would be great to have them appear in your file manager and your menu with a cool icon. You need to find a 48 pixel by 48 pixel png image to use for the icon. You can create one using something like gimp, but I will demonstrate using a VASSAL icon. In your VASSAL installation find Vengine.jar. Right-click and open it with archive manager. Search for VASSAL.png. There should be several of them; select the one that's in icons/48x48. Extract to a directory of your choice. The icon should appear underneath that directory in ./icons/48x48

Open up a terminal window and cd to that directory. Run "xdg-icon-resource install --size 48 --mode user --context mimetypes ./VASSAL.png VASL" That will install (copy) the image as a local (to your user) resource.

Edit the VASSAL.xml file you created above. Add the "Icon" line shown below:

VASSAL.xml said:
<mime-type type="application/vasl.game">
<comment>vasl saved game</comment>
<glob pattern="*.vsav"/>
<icon name="VASL" />
</mime-type>
Run "update-mime-database ~/.local/share/mime" again. Open your file manager to a directory with a saved vasl game. The icon should now show the VASSAL icon.

Run alacarte. Find your entry for vasl. Click the "properties" button. Browse to ~/.local/share/icons/hicolor/48x48/mimetypes/VASL.png. Now your menu should also use the icon.

If you play multiple games using VASSAL you may want separate icons for each. Use your artistic/appropriation skills to create/commandeer such images. The recommended size for icons is 48 pixels by 48 pixels. When you install the icon, change the name that the icon is installed as appropriately (e.g. "xdg-icon-resource install --size 48 --mode user --context mimetypes ./my-downtown-image.png downtown") and also the icon name in the .xml file (e.g. "<icon name="downtown" />

JR
 
Last edited:

Will Fleming

Senior Member
Joined
Apr 22, 2003
Messages
4,410
Reaction score
424
Location
Adrift on the Pequod
Country
llUnited States
Whoo-hoo. Got it working on Fedora. Had to change a little bit of stuff around and of course a typo caused me no shortage of pain, but it works and best thing to me is that this should live through upgrades/updates.

Will try to get some instructions out, but I think the key differences is that I needed a ~/.local/share/applications/mimeapps.list file.

1) Files in nautilus show with the proper icon.
2) Both vlog and vsav files are now associated with my custom 'vasl' program (similar to JR's VASL.sh or similar) and are double clickable to load them.

Attached is the icon I used. Changed the old VASL4 logo/icon to be 48x48 and of type png.
 

Attachments

Will Fleming

Senior Member
Joined
Apr 22, 2003
Messages
4,410
Reaction score
424
Location
Adrift on the Pequod
Country
llUnited States
OK, I had to do a reinstall of Fedora (30 in this case). I hope I got the steps correct, but there could be some mistakes or missing things as I had to try a few things and GOOG a lot to fill in the blanks. Bold is just comments or locations, colored text goes into files (blue) or run as a command (green).


File location: ~/bin/VASSAL

#!/bin/sh -ex
# Execute this file to launch VASSAL on MacOS or Linux

# Find absolute path where VASSAL is installed
#INSTALL_DIR=$(cd "$(dirname "$0")"; pwd)
INSTALL_DIR=/home/<username>/Dropbox/VASSAL/
# I put my files into Dropbox, but this is where your VASSAL.sh file is

# Launch VASSSAL
java -Duser.dir="$INSTALL_DIR" -classpath "$INSTALL_DIR"/lib/Vengine.jar VASSAL.launch.ModuleManager "$@"



File location: ~/.local/share/applications/mimeapps.list


[Added Associations]
application/vassal.game=vassal.desktop



File location: .local/share/applications/vassal.desktop

[Desktop Entry]
Version=1.0
Comment=VASSAL
Terminal=false
Name=VASSAL
Exec=/home/<username>/bin/VASSAL
#This is the script above for running VASSAL using JR's advice
Type=Application
Icon=/home/<username>/Pictures/avatars/VASSAL.png
# Whatever directory/png

File location: .local/share/mime/packages/VASSAL-mime.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/vassal.game">
<comment>VASSAL Saved Game</comment>
<glob pattern="*.vsav"/>
<glob pattern="*.vlog"/>
<icon name="VASSAL" />
</mime-type>
</mime-info>


Run this to update the database:
update-mime-database ~/.local/share/mime
 

Attachments

Will Fleming

Senior Member
Joined
Apr 22, 2003
Messages
4,410
Reaction score
424
Location
Adrift on the Pequod
Country
llUnited States
Top