Page 1 of 1

Opening directly a PGN file using xboard

PostPosted: 08 Dec 2011, 21:24
by Sacolevas
Hello, I am using a Linux operating system (with LXDE as desktop environment) and have installed xboard. However, I don't know what should I do to be able to open a PGN file directly using xboard. In windows, I had the option to associate pgn files to winboard, so I could open a pgn file by just double-clicking the file. Here, I always have to open xboard and then open the file in xboard.

Thanks for your attention and my apologies if this topic has already been covered somewhere else in the forum.

Re: Opening directly a PGN file using xboard

PostPosted: 21 Dec 2011, 14:05
by H.G.Muller
I had hoped someone would respond to this, because it is something I would very much like to use in the next XBoard release (4.6.0). I know something like this must be possible, because when I click a PGN file in my Ubuntu now, it starts up some silly Chess viewer.

Arun has looked a bit into this, and did fund out how you can associate a file mime-type with an icon and a application, but not how you can then call this application with command-line options, as would be needed to start XBoard in game-viewer or tournament mode.

Re: Opening directly a PGN file using xboard

PostPosted: 26 Dec 2011, 10:40
by Byrial Jensen
Sacolevas wrote:Hello, I am using a Linux operating system (with LXDE as desktop environment) and have installed xboard. However, I don't know what should I do to be able to open a PGN file directly using xboard. In windows, I had the option to associate pgn files to winboard, so I could open a pgn file by just double-clicking the file. Here, I always have to open xboard and then open the file in xboard.


Hi Sacolevas,

I registered at this forum to be able to answer this question.

On Linux it is done in 2 steps:
1) Associate PGN files with a MIME type (usually application/x-chess-pgn)
2) Register xboard as a handler for the MIME type.

Step 1)

I think that step 1 is already done on most updated Linux systems. You can test if it is the case with the command mimetype. It should look like this:

$ mimetype somefile.pgn
somefile.pgn: application/x-chess-pgn

If pgn-files are recognized as having the MIME type application/x-chess-pgn, you can jump to step 2 below.

But if mimetype answers text/plain instead of application/x-chess-pgn, you will have define the MIME type. To do that, make a file called xboard.xml with this content:

Code: Select all
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-chess-pgn">
    <comment>PGN chess game notation</comment>
    <generic-icon name="text-x-generic"/>
    <glob pattern="*.pgn"/>
    <sub-class-of type="text/plain"/>
    <magic priority="50">
      <match value="[Event " type="string" offset="0"/>
    </magic>
  </mime-type>
</mime-info>

See the specification for the file at http://standards.freedesktop.org/shared ... ec/latest/ if you want to customize it.

Install the file with the xdg-mime program from the xdg-utils package:

$ xdg-mime install --mode <MODE> --novendor xboard.xml

<MODE> should be either "user" for a installation for the current user only, or "system" for a system wide installation. The latter of course requires root access.

Step 2)

Make a file called xboard.desktop with this content:

Code: Select all
[Desktop Entry]
Type=Application
Name=XBoard
GenericName=X Window Chess Board
NoDisplay=true
Comment=Use XBoard to view PGN files
Exec=xboard -ncp -lgf %f
Terminal=false
MimeType=application/x-chess-pgn;
Categories=Game;BoardGame;

You can change the command line options in the Exec key as you wish. The file format is specified in http://standards.freedesktop.org/deskto ... ec/latest/ if you wish change it.

Install the desktop file with:

$ xdg-desktop-menu install --mode <MODE> --novendor xboard.desktop

<MODE> is either "user" or "system" as before.

After the installation of the desktopfile, you may have to run

$ update-desktop-database

I am not sure if it is necessary.

Hope that helps,
- Byrial

Re: Opening directly a PGN file using xboard

PostPosted: 26 Dec 2011, 15:08
by Byrial Jensen
H.G.Muller wrote:Arun has looked a bit into this, and did fund out how you can associate a file mime-type with an icon and a application, but not how you can then call this application with command-line options, as would be needed to start XBoard in game-viewer or tournament mode.


The solution for this is to make a separate desktop file for the association with the mimetype. That desktop file can have the right command line options for opening a file of the desired type, but does not have to show up in the menu system due to having "NoDisplay=true" in the file.