Updated: August 9, 2024
All right. This is a somewhat niche, convoluted topic. Let me start with some background information. A couple of years ago, I started a journey of trying to migrate away from Windows. To that end, I'm using a laptop, one Slimbook Titan, as my experiment platform. I'm trying to do everything I want or need on it, in an attempt to fully mirror the Windows experience. Part of that setup includes using excellent-but-Windows-only software running through WINE. By and large, this has been a rather successful experiment so far.
However, I did encounter a rather weird snag. During the setup and configuration of SketchUp Make, which I use for 3D modeling, I somehow managed to "bork" the WINE-specific system menu and task manager launchers in my Plasma desktop. They no longer work. The program runs great, but it can only be really invoked on the command line. The usual GUI-driven tools simply fail, quietly. In this article, I will show you how you can fix orphaned WINE system menu entries (probably due to multiple WINE version installations), and create custom launchers that will always work. Let us commence, then.
Problem in more detail
First, the issue didn't affect just SketchUp. It affected several other WINE programs, like Notepad++, Maxwell Render, IrfanView, but oddly, not KompoZer or Kerkythea. Anyway, I decided to examine this delicate issue in more detail. As a starting point, I looked at the Plasma menu launcher entries. The typical entry would be a pointer to a .lnk file. For instance:
env WINEPREFIX="/home/[user]/.wine" wine C:\\ProgramData\\Microsoft\\Windows\\Start\ Menu\\Programs\\Notepad++.lnk
I decided to try to change this to the command I would use to successfully launch the program in a terminal window.
env WINEPREFIX="/home/[user]/.wine" wine "/home/[user]/.wine/drive_c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"
Alas, this did not seem to help, at all. While the command worked beautifully in Konsole, it did not through the system menu, or as a pinned task manager shortcut. Next, I decided to look at the KDE configuration, to see what my task manager icons did in the background. Indeed, the task manager section looked like (shortened for brevity):
[Containments][2][Applets][5][Configuration][General]
launchers=applications:org.kde.spectacle.desktop,preferred://filemanager,...,
applications:wine-Programs-SketchUp 2017-SketchUp.desktop,
applications:Kerkythea.desktop...
I then decided to examine the different WINE program desktop files. Here, I encountered a fresh snag. There were multiple desktop files for each program, stored in different locations. Their contents were also different. I guess this is a leftover from the various WINE attempts to get everything working smoothly.
locate Notepad++.desktop
/home/[user]/.local/share/applications/wine-Programs-Notepad++.desktop
/home/[user]/.local/share/applications/wine/Programs/Notepad++.desktop
I really don't know why there are two sub-folders for WINE: wine-Programs and wine/Programs. Notice the subtle, yet cardinal difference. Likewise, the file contents. The first one:
[Desktop Entry]
Comment=
Exec=env WINEPREFIX="/home/[user]/.wine" wine notepad++
Icon=4D89_notepad++.0
Name=Notepad++
NoDisplay=false
Path=/home/[user]/.wine/dosdevices/c:/Program Files (x86)/Notepad++
StartupNotify=true
StartupWMClass=notepad++.exe
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
The second one:
[Desktop Entry]
Name=Notepad++
Exec=env WINEPREFIX="/home/[user]/.wine" wine
C:\\\\ProgramData\\\\Microsoft\\\\Windows\\\\Start\\ Menu\\\\Programs\\\\Notepad++.lnk
Type=Application
StartupNotify=true
Path=/home/[user]/.wine/dosdevices/c:/Program Files (x86)/Notepad++
Icon=4D89_notepad++.0
StartupWMClass=notepad++.exe
I tried to edit these files, tried to change the paths, no luck. Now, I purposefully decided to show all these issues and complications so you can avoid similar mistakes. Don't try to debug the over-complicated realm of WINE shortcuts and such. Just don't. We need something simpler, clear, more straightforward.
One option is to delete everything and start fresh. But I really wasn't in the mood for losing configurations, plugins and settings (a few of them years and years old and comfortably ported over) for some dozen Windows programs, or having to redownload and reinstall various runtimes. Nope. We need an elegant fix.
Solution
All right, my fix is to create shell scripts, paste inside the proven commands that launch the relevant WINE programs, and then, use those as the "commands" for the (Plasma) system menu entries and the relevant shortcuts. You can do this in any Linux desktop environment. Since I'm using Plasma, I'll demonstrate with Plasma.
Right-click on the system menu icon > Edit Applications. Create a new entry (or copy an existing one). If you're not sure, simply copy a WINE program entry, and then change the command field. It needs to point to an executable script, located somewhere in your home directory (or any accessible path).
The contents of the script can be anything. The easiest template:
#!/bin/bash
env WINEPREFIX="/home/[user]/.wine" wine "path to executable"
exit 0
Once you have this in place, you will now be able to launch programs from the system menu. However, existing pinned task manager shortcuts will still fail to run. To work around that, unpin any program that no longer starts, and then re-pin the new one (the script-launched program). And that's it.
Conclusion
Having created a handful of custom launcher scripts, all of my WINE programs work great now. Both the system menu, task manager shortcuts and desktop icons work properly, and correctly start the relevant applications. I also have full control of the launch sequence, as I can edit scripts as I please. I don't need to worry about weird WINE environment variables, half-broken paths to Windows link files, Windows AppData (like Roaming folder) and other inconsistencies.
I really don't know what went wrong. I also don't know why the Plasma menu had such trouble with the launchers, or why it refused to do the same thing as the command line. For some reason, the Plasma menu support for WINE seems a bit flaky, or there's a bug or two somewhere under the hood. Perhaps it's caching, broken paths, who knows. For me, the full resolution was in custom scripts, and brand-new pinning of application shortcuts. Everything works as it should now. Hopefully, this tutorial will come handy, should you ever need it. I hope you won't even encounter similar issues with WINE like I did, but if you do, then don't be tempted to unravel the mysteries of the WINE setup, go "simple" with shell scripts, and save yourself some time. Anyway, take care.
Cheers.