When I want to run a wine program I have to type e.g.

$ wine ~/.wine/drive_c/Program\ Files/TextAloud/TextAloudMP3.exe

Would it be possible to run directly TextAloudMP3? I mean not only from command line (I could create alias) but in whole graphical environment. I'm launching programs with dmenu.


I guess you meant to launch exe programs with wine directly, so tell kernel to run win32 binaries with wine by,

  1. Mount binfmt fs, add a line none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0 to /etc/fstab and execute mount -a afterwards

  2. echo ':DOSWin:M::MZ::/usr/bin/wine:' > /proc/sys/fs/binfmt_misc/register to register the binary format

So later, you just run the exe file with /path/to/XX.exe

Note that this also introduces a security problem.

  • I can't edit /proc/sys/fs/binfmt_misc/register. It writes /proc/sys/fs/binfmt_misc/register E667: Fsync failed. I tried to edit under user acount with sudo and under root account too. Both write this error. – xralf Apr 1 '13 at 9:43
  • Wow! I didn't know the kernel could do that. This particular use case feels evil though. But I like that even when opening that door, filenames, that is extensions, do not matter, whereas other OSes ... :D – Bananguin Apr 2 '13 at 18:21
  • @xralf: How are you trying to edit the file? echo should work, but some (most/all?) editors may not work, because it's not a real editable file, it's virtual within the proc filesystem. – chmeee Apr 7 '13 at 1:47
  • @xralf don't edit with vim – daisy Apr 7 '13 at 2:34
  • @warl0ck I have to do it under root account. I added /path/to/ to my $PATH variable and I can run XX.exe from command line but still can't run it from dmenu. Sorry I've mistaken it with xmobar in the question. – xralf Apr 7 '13 at 8:52

Make sure wine is in your path and create a shell script containing the following:

wine "$HOME/.wine/drive_c/Program Files/TextAloud/TextAloudMP3.exe"

Give yourself permission to execute the script by running chmod u+x SCRIPT_NAME.

Then, just run that script from your file manager. It will start wine, which will run TextAloudMP3.exe.

  • I created a script named textaloud in /usr/local/bin folder. First line is #! /bin/bash second line is wine .... textaloud won't appear in xmobar launcher. When running sh textaloud it writes $ sh textaloud wine: cannot find '~/.wine/drive_c/Program Files/TextAloud/TextAloudMP3.exe' – xralf Mar 31 '13 at 12:12
  • Oops. ~ doesn't expand to a user's home directory when it's within double quotation marks. I have modified my answer to use the environmental variable $HOME instead. – user26112 Mar 31 '13 at 12:51
  • sh textaloud already works, but only from the directory /usr/local/bin and it's still not visible in xmobar launcher. – xralf Mar 31 '13 at 15:46
  • 1
    might want to add $@ after the program name so it passes all arguments. And I usually put such scripts in ~/bin (after making sure it is in your PATH, of course). – Wyatt8740 May 6 '15 at 16:36
  • Couldn't you also define an alias in ~/.bash_aliases? – Aaron Franke Jan 29 '18 at 23:57

Step 0

Set a binary PATH for your user. Run mkdir ~/bin and add this directory to your PATH.

How this is done may vary depending on the shell and desktop environment you use.

Here you can found how to change your PATH in a variety of shells.

Check this solved question if your desktop environment don't care about your shell profile and the former does work from the terminal but not from the desktop environment.

Step 1

Once you have set your shell and your desktop environment to respect a new PATH, you can drop scripts there and run them as regular commands without typing their path.

Create a short shell script to run your wine program in this directory, i.e. ~/bin/textaloud:

cd "~/.wine/drive_c"
exec wine "~/.wine/drive_c/Program Files/TextAloud/TextAloudMP3.exe" "$@"

And give it execute permission.

chmod +x ~/bin/textaloud

There are three things to note about the above script:

  • The cd path is where the program is going to be run (in which directory). Some programs may require you to run them on a specific directory. If you have trouble with this, set there that directory (usually the same where the executable is located). You may unwant this line in some cases.
  • The exec commands tell bash to morph into wine with the following arguments, so this is no longer bash running wine, but bash process becoming wine. The PID remains. You don't have two processes running.
  • The $@ is substituted with the arguments you ran the script, if any. So those are passed to your wine program.

Now you can run your program from the shell like...


Step 2

Create an application launcher. Nowadays these files are standarized as .desktop files and many desktop environments provide graphical tools to create them.

Here is an example skeleton you can use to write it yourself. You may want to provide an icon (often in PNG, SVG or XPM).

[Desktop Entry]

Place this file in ~/.local/share/applications/TextAloud.desktop. Icons are searched (among other places) in ~/.local/share/icons, so make sure to find a cute icon for your application and place it there with the name textaloud.png.

Once you had done this, your desktop environment should find your shortcut file and be able to run the program with the script. If not, reload or restart it.

  • Thank you, I tried your guide but the last step don't work. I can't see textaloud in dmenu launcher. – xralf May 30 '13 at 17:49
  • The step 2 is directed to desktops like GNOME, KDE or XFCE. dmenu does not seem to care about .desktop files, so with Step 1 you should be fine. Did it work from the terminal? If it did but still does not work, review Step 0. Maybe you are using ~/.xsession to get your X11 sesion? Try adding there export PATH="$HOME/bin:$PATH" before the line you use to run dwm and restart X11. – Alicia May 30 '13 at 21:19
  • In works from terminal without problems. PATH is OK. Only the question to be complete I'd like to work it from dmenu. – xralf May 31 '13 at 7:16
  • I told you. Do you have ~/.xsession? Be aware the PATH of your terminal may not be equal to the PATH of your X11 session. – Alicia May 31 '13 at 9:57
  • $@ should be in double quotes for safety. so it would become exec wine "~/.wine/drive_c/Program Files/TextAloud/TextAloudMP3.exe" "$@". – Wyatt8740 May 6 '15 at 16:37

Have you considered trying PlayOnLinux? It can take care of the whole thing for you and even you can configure some filetypes to be opened by wine programs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.