Wednesday, October 3, 2012

Creating Wine/PlayOnLinux Steam Game Shortcuts on Your Desktop

After my recent invite to the DotA 2 beta (/cheer), my Linux gaming interest has been reignited.  I already had a working install of Steam via Wine (via PlayOnLinux), which is the platform on which DotA 2 is distributed.  Consequently, the regular installation of DotA 2 from Steam went smoothly and the game ran without a hitch (Wine v1.5.13).

When you install a game through Steam, a shortcut is automatically placed on your desktop in the form of a .url file -- at least this was the case with my Fedora/KDE/PlayOnLinux combo.  The shortcut seems to work just fine, but there were a couple of issues with it for me, aesthetically.


That picture alone should tell you exactly what's wrong with it.  For installed native Linux games, you get a nice desktop link to the binary with the intended icon... with a Steam game shortcut, you get a globe on a paper with a rolled corner and a ".url" on the end of the game name.  This will never do for those of us who have an interest in the more aesthetically pleasing things of this world OR those of us who have large Steam game collections... and especially not those of us who fall into both categories.

DISCLAIMER:  This fix is specific to the KDE 4.X environment, although other desktops surely have a similar method for implementing this.  At the very least, you will find the "Command" for opening a game through Steam via Wine useful.

Enough rambling.  What's the fix here?  Well, the file that we have is a URL shortcut with contents like

[InternetShortcut] 
URL=steam://rungameid/570 
ICONFILE=C:\Program Files (x86)\Steam\steam\games\c0d15684e6c186289b50dfe083f5c562c57e8fb6.ico
ICONINDEX=0

Even if we change the ICONFILE line to a more Linux-appropriate path and file type, we still won't be able to change the icon.  Also, you can go into the Properties dialog for this shortcut to change the icon, but this will change EVERY .url file to use the same icon... not ideal.  So, we essentially need to create a new type of shortcut for our games for which we can configure an icon on a per shortcut basis; this can be accomplished with an application shortcut.  For starters, open a windowed terminal session and cd to your user's desktop directory:
cd ~/Desktop
Then do a cat of the shortcut that you intend to replace:
cat Dota\ 2.url
The output should be very similar to what I've posted above (in the [InternetShortcut] section).  The number at the end of the URL=steam://rungameid/... line is what we're most interested in here.  This is the unique number that Steam assigns to each application, and we will be creating the new shortcut using this number.  Now, right click on your Desktop panel and Create New > Link to Application...  Fill in the field at the top of the "General" tab that currently contains "Link to Application" with whatever name you'd like to appear for this shortcut.  Then, click on the application tab and fill in the "Command:" field with the following:
env WINEPREFIX="/home/user/.PlayOnLinux/wineprefix/Steam" wine "C:\\Program Files (x86)\\Steam\\Steam.exe" -applaunch 570 -no-dwrite
Here, you will fill in the WINEPREFIX portion with the root of your Wine drive.  In my case, I'm using PlayOnLinux to manage several Wine drives.  If you're using straight Wine, yours might look more like "/home/user/.wine".  You'll also need to make sure your Steam.exe is in the same relative location as mine.  Then, the last thing will be to change the number (570) to the application number that you got from the previous step.  Also, the "-no-dwrite" portion is to disable the dwrite.dll library to fix the "no text" issue in Steam for Wine versions >=1.5.10 ... so that is optional.

Now, hit the OK button and you'll have a fully functional application link that goes straight to your desired game... but we still haven't resolved the issue at hand.  Right-click on your newly created shortcut and go to Properties.  This time, there is a question mark icon to the left of the shortcut name and it will be clickable.



You can click it to open the dialog for changing the icon.  One last gotcha... you will either need to download a new icon from the web by doing a Google Image search (eg "dota 2 icon") OR browse to the ICONFILE location in the "cat" step, open it in the default image editor, and save it back as a .png, .xpm, .svg, or .svgz;  this is because you can't use a .ico file as an icon in KDE.  Either way... click the question mark icon, click the "Other icons:" radio button, then click "Browse..." and browse to whichever icon graphic you desire, select it and hit "Open".  Now hit "OK" to get out of the dialog, and... you're done!  Mission accomplished!



You've gotten better at Linux! (3)