Ubuntu – Creating a foobar.desktop file and a Wine app icon on the launcher

desktoplauncherwine

This a specification of my previous question (What's a .desktop file?) where I wondered how to create a .desktop file in order to create an icon on the launcher for a Wine application.

I don't understand what do we have to do with the following code:

[Desktop Entry]
Name=FooBar
Comment=Foo & Bar
Exec=sh -c "cd /home/USER/.wine/drive_c/Program\ Files/FOOBAR_FOLDER; wine foobar.exe"
Icon=wine
Terminal=false
Type=Application
Categories=Wine;
StartupNotify=true

Replace USER and FOOBAR_FOLDER with appropriate values. So you'll be
able to locate your application in the Launcher by typing "FooBar".

This is the top answer given to a question similar to my previous one, which you can see here: How does one create a custom application launcher for Wine installed apps?, but I don't understand how shall I handle the code I just provided. I tried to copy and paste on the terminal, but it wouldn't work.

In other words, I need that same answer but more comprehensively explained and easier to understand since I don't get what to do with the code provided! Please note, I have few skills with computers. Thank you very much! 🙂

Best Answer

  • Desktop files contain a command to open an application. It is not much more than a textfile, with the extension ".desktop". Although you can store these files anywhere, and run it as a standalone link to an application (that is: if you make it executable), the default locations are:

    `/usr/share/applications`
    

    (globally) or

    `~/.local/share/applications` 
    

    (locally).

    What you need to do is paste the text in your post into an empty textfile (open gedit), and change the line:

    Exec=sh -c "cd /home/USER/.wine/drive_c/Program\ Files/FOOBAR_FOLDER; wine foobar.exe"
    

    What do you need to change?

    Explanation of the sections of the line:

    Exec=
    

    This means: what comes after this will be executed if the desktop file is invoked. That is actually what would make the application start if you would run it in a terminal.

    sh -c "cd /home/USER/.wine/drive_c/Program\ Files/FOOBAR_FOLDER;
    

    this is telling the shell to go into the directory where the application is located (the backslash in /Program\ Files is to escape the space in the name of the Program Files folder, telling the shell not to stop at the space).

    You should replace USER with your own username, replace FOOBAR_FOLDER with the name of the application folder. If you don't know, open your home directory, press ctrl+h to make the .wine folder visible (if it isn't already), and browse into the directory ~/.wine/drive_c/Program Files to see the name of your application folder.

    wine foobar.exe
    

    This tells the shell to run foobar.exe with Wine. Replace foobar.exe with the actual application_name.exe.

    Finally, your Exec= line should look something like (if RedNotebook is your application for example):

    Exec=sh -c "cd /home/antortjim/.wine/drive_c/Program\ Files/RedNotebook; wine rednotebook.exe"
    

    Then, after you have changed the line Name=Foobar into a more appropriate name, save the file as (for example) rednotebook.desktop

    If you want to use the file as a starter on your Desktop, save it there as renotebook.desktop and make it executable. If you want to run it from Dash, move it into ~/.local/share/applications. After log out and back in, it will be available in Dash. You can lock it to the launcher then.

  • Related Question