Sunday, May 19, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1251  / 2 Years ago, sat, march 26, 2022, 2:33:20

I have an MS Windows application which needs new version of Wine. I have installed it locally to home-folder using PlayOnLinux.


I'm stuck with creating simple bash/dash/sh script to launch .exe application inside its folder. I tried standard pushd/popd, cd && exec, (cd && exec) approach but it failed.


What I need:



  • Desktop-file as launcher for a script



  • A script which:



    1. changes directory to .exe application's directory

    2. executes wine .exe inside application directory




Currently I'm happy with the following Python-code for wrapper script (to be placed in /usr/local/bin/wine32-wrapper):


#!/usr/bin/python3
import os
import sys
import subprocess

if len(sys.argv) >= 2:
path = sys.argv[1]
wd = os.path.dirname(path)
exec_path = ["/home/{}/.PlayOnLinux/wine/linux-x86/6.15/bin/wine".format(os.getenv('USER'), path), "{}".format(path)]
p = subprocess.run(exec_path, cwd=wd)
else:
print("
Usage {} with one argument - full file path.".format(sys.argv[0]));

and .desktop-file (to be placed in ~/.local/share/applications/wine32.desktop), for it:


#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=mate-panel-launcher
Exec=wine32-wrapper %f
Name=Local Wine32-6.15

then I associate my exe-files with this wine script using Caja.


Is it possible to replace above python script with bash/dash/sh script with exactly same functionality?


More From » command-line

 Answers
5

After some more deeper analysis I found good and interesting desktop-files for "Wine Windows Program Loader" which came from Wine packages. It has special options in Exec field:



Exec=wine start /unix %f



and forces exe-file to be launched in its directory.


For my case it may be adapted for ~/.local/share/applications/wine32.desktop as shown below:


#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=mate-panel-launcher
Exec=/home/user/.PlayOnLinux/wine/linux-x86/6.15/bin/wine start /unix %f
Name=Local Wine32-6.15

Thus the script part is not needed, we end with single desktop-file with special start /unix option.


Note: when Wine is installed from official Ubuntu repositories such "Wine Windows Program Loader" can be registered using commands like mkdir -p ~/.local/share/applications/ && cp /usr/share/doc/wine-stable/examples/wine.desktop ~/.local/share/applications/ .


[#1195] Saturday, March 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bathtusain

Total Points: 380
Total Questions: 124
Total Answers: 111

Location: Trinidad and Tobago
Member since Sat, Apr 9, 2022
2 Years ago
bathtusain questions
Sun, Jul 17, 22, 03:13, 2 Years ago
Sun, Oct 3, 21, 00:24, 3 Years ago
Sat, Apr 22, 23, 00:24, 1 Year ago
Fri, Jul 22, 22, 12:01, 2 Years ago
Sun, Jun 27, 21, 02:31, 3 Years ago
;