UPDATED 4 NOV 2022: Lately, I figured out how to make a Desktop Shortcut to run an .exe file depending on what kind of applications for Windows, for example:
- If a simple app like
notepad.exe
, ultraiso.exe
or other apps that runs with a simple window without a full screen, it needs only one .desktop
file to run: Follow the point A and C.
- If an app that runs with a full screen like "Need For Speed High Stakes" or "Age of Empires II HD", it needs two files with the different extensions
.sh
and .desktop
to run: Follow the point B and C.
A. Make a new Desktop shortcut archive with the .desktop
extension in the Desktop directory /home/<user>/Desktop/
, and also in "all applications" directory /usr/share/applications/
, copy/paste the following text in it:
- Note: Between the quotation marks next to
wine
, it needs double backslash \\
to separate directories of a path.
[Desktop Entry]
Name=<name>
Comment=<comment>
Keywords=<word1>;<word2>;<word3>
Exec=wine "C:\\Program Files (x86)\\<app_folder>\\<file>.exe"
Terminal=false
Type=Application
StartupNotify=true
Icon=<icon>
- If you want to execute any wine configuration like
winecfg
, then copy/paste this Exec
syntax instead:
Exec=wine <configuration> %f
CONFIGURATION DESCRIPTION
winecfg Wine configuration
control Wine Control Panel
control joy.cpl Game Controllers
regedit Registry Editor
uninstaller Add/Remove Programs
B.1. Make a new shell script archive with the .sh
extension in the main folder of the application installed, copy/paste the following shell script text in it:
gnome-terminal --tab --title="<name>" --command="bash -c 'cd /home/<user>/.wine/drive_c/Program\ Files\ \(x86\)/<app_folder>; wine <file>.exe'"
The meaning of each one of shell script:
SYNTAX DESCRIPTION
gnome-terminal Open up a gnome-terminal
--tab Open up a unique tab
--title="<name>" Name (whatever you want) of a tab
--command="bash -c '<cmd1>;<cmd2>;<cmd3>'"
The (bash -c) syntax is a bash command that runs the first
<command>, once it is finised, it runs the next <command>
and so on.
B.2. Make a new Desktop shortcut archive with the .desktop
extension in the Desktop directory /home/<user>/Desktop/
, and also in "all applications" directory /usr/share/applications/
, copy/paste the following text in it:
[Desktop Entry]
Name=<name>
Comment=<comment>
Keywords=<word1>;<word2>;<word3>
Exec=/home/<user>/.wine/drive_c/Program\ Files\ \(x86\)/<app_folder>/<file>.sh
Terminal=false
Type=Application
StartupNotify=true
Icon=<icon>
- Note: If Terminal launched by a
.sh
file does NOT run an app in several seconds, to solve the problem is to press CTRL+C
to stop Terminal and it closes automatically. And then, try again the same way to run an app. WARNING ! Never, ever close Terminal by user, it could kill Terminal and it will NOT work FOREVER until the user has to format the hard disk and reinstall Ubuntu.
C. Set the .desktop
archive to be executable and allowed to launch, also set the .sh
archive to be executable:
- Note: If the Desktop shortcut or the Desktop directory is set to be writeable for OTHER users, the Desktop shortcut could be blocked to launch.
Setting a file/folder to be executable for USER (owner), is to type u+x
; Removing a file/folder to be writeable for OTHER, is to type o-w
;
This is an example of the command in Terminal to set or remove executable or writeable:
$ chmod -v u+x <file/folder>
Setting a <file>.desktop
to launch in the Desktop directory:
$ gio set <file>.desktop metadata::trusted true
Check if it's allowed to launch:
$ gio info <file>.desktop | grep metadata::trusted
D. About getting the icon file to the Desktop shortcut, there are two kinds to choose:
- The code of the icon (The code of every different icon is in every file in
/usr/share/applications
): Icon=<code_of_icon>
- Getting from any file of PNG:
Icon=/<path>/<file>.png
That's all, best regard.
.sh
and.desktop
as the explanation in my answer. – luisito_36 Oct 26 '22 at 17:02