winerun cmdline wine tool

Questions about Wine on Linux
Locked
hackoon
Level 1
Level 1
Posts: 5
Joined: Sat Feb 27, 2021 12:35 pm

winerun cmdline wine tool

Post by hackoon »

winerun v1.0

After years of using PoL and Lutris I wrote this shell-script to have a faster, simpler and more intuitive way to start and manage my many wine-prefixes. Its now quite complete and I thought I should share it.

install with:
chmod a+x winerun/winerun
sudo cp winerun/winerun /usr/local/bin/

you should now be able to simply run any exe with:
winerun <exe>

if more than one is found all alternatives are printed out.

if you prefix isn't found than either cd into a prefix or prefix-collection folder or define the WINEDRIVES enviroment var with a comma separated list of prefix collection folders.
best added to ~/.bashrc : (example)
export WINEDRIVES="/home/user1/WinePrefixes /media/User1/wingames"

There are many more options - especial useful is 'winerun copy' and to create symbolic links to either the prefix winerun copy or the original winrun

Enjoy

Code: Select all

winerun -- wine cmdline tool
version 1.0

* no need to set WINEPREFIX or "cd" into the right folder
* easy version management
* auto-restores screen-size if changed within wine 
* intuitive, small and fast

syntax:
    winerun [dryrun|copy] [[version] <wineversion>|wine|lutris>] [prefix] <wineprefix>|<exe> [new] [cd] [[exec] <exe>|<shellscript>] [<args>]
    winerun [dryrun] [[version] <wineversion>]|wine|lutris>] [prefix] <wineprefix>|<exe> [cd] [winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad] [<args>]
    winerun [dryrun] [prefix] <wineprefix>|<exe> [edit|firefox|gimp] <args>
    <exe name> [dryrun] [[version] <wineversion>|wine|lutris>] [[exec <exe>|<shellscript>]|winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad|edit|firefox|gimp] [<args>]

with:
    - <wineprefix>: either a full path or defined in WINEDRIVES
    - <exe>: a full or partitional path with shell patterns (*?) with or without ".exe" extensions
    - <exe name>: renamed/liked winerun with the filename of any *.exe inside of a prefix  with or without ".exe" extensions
    - copy: copies the winrun script to <prefix>/<exe without path> to be started with that script by calling it directly or symolic linking it
    - <shellscript>: a full or partitional path with shell patterns with ".sh" extensions
    - <wineversion>: either a folder defined in WINERUNNERS or a number used as pattern in the same WINERUNNERS folders
    - cd: changes dir to the same folder the <exe> is found or to <prefix>/drive_c if no <exe> is given
    - new: creates new prefix (in the first WINEDRIVES folder if no absolute path is given)
    - dryrun: do not execute or create anything (apart from .sh scripts in <prefix>) but print-out the actions
    - also "wine" or "lutris" can be used for version: it removes any saved version and default to either system wine or the lutris version defined in .yml
    - when "exec" is not used then "cd" is assumed
    - all exept <prefix> ignore case distinction 
    - if only prefix is given then it will try to find the exe and path from a Lutris .yml configuration
    - in most places "find" is used to find the file if no absolute path is given
    - will not follow linked folders
    - if more then one alternative is found then the command will be interupted and the alternatives printed on screen

examples:
    winerun GRunner
    winerun 4.24 grunner -fullscreen y
    winerun version 4.24 prefix WGame cd exec grunner.exe -fullscreen y -playnet 2
    winerun wine ~/WPrefixes/WGame new exec /media/user1/CD1/Setup.exe
    winerun Grun* notepad readme.txt
    winerun version lutris-4.21-x86_64 WGame Bin/Release/GRunner
    winerun GRunner.exe edit gfx.ini
    winerun dryrun GRunner.exe regedit myconfig.reg
    winerun lutris WGame exec lvlEdit 
    winerun WGame gimp image/sell0.png
    winerun copy 4.24 GRun* -fullscreen y
    ./WGame/GRunner -playnet 2

env vars:       (auto-assigned)
    WINEDRIVES  (/home/wrtest/myGames)
    WINERUNNERS (/home/wrtest/.local/share/lutris/runners/wine /home/test/.PlayOnLinux/wine)
    WINE        (wine)
    WINEEDITOR  (/usr/bin/xed)

<prefix>/winerun.sh file:
    - will contain the last WINE=<version>
    - can also contain any user-defined script like "export WINEDEBUG=+loaddll"
    - will be removed when empty
    - can use relative path for wine binary with <prefix> as start (to use as bottle)

<prefix>/<exe name without .exe>.sh file:
    - shellscript will be sourced before running exe with the same name
    - autoupdates with options="<cmdline options>" when "copy" is used

vars to be used with the above .sh scripts:
    noscreen_restore=1 (disables the auto restore screensize feature)
    options="<args to exe>" (will by prefixed to cmdline args)

<prefix>/<exe name without .exe>.lua file:
    - will call lua with the script and the wine exe call as arguments
    - non zero exit status will stop winerun
    - will be ignored while dryrun 

linked/renamed winrerun:
    - linked/renamed winerun will run winerun with <filename> as <exe> 
    - renamed copy of winerun in a WINEPREFIX will be used as <exe> inside of the prefix (can be created with: "winrun copy" )
    - above copy can be symbolical linked (link name can be anything)
Download:
winrun on GitHub

any bugreport/suggestions preferable on GitHub or below
User avatar
succodifrutta
Level 2
Level 2
Posts: 12
Joined: Sat Mar 28, 2020 5:26 am

Re: winerun cmdline wine tool

Post by succodifrutta »

hackoon wrote: Sat Feb 27, 2021 12:58 pm winerun v1.0

if you prefix isn't found than either cd into a prefix or prefix-collection folder or define the WINEDRIVES enviroment var with a comma separated list of prefix collection folders.
best added to ~/.bashrc : (example)
export WINEDRIVES="/home/user1/WinePrefixes /media/User1/wingames"
That's an awesome functionality!!! 8)

So if I understood right:

Code: Select all

winerun portable.exe
winerun setup.exe
winerun someother.exe
etc...
Will always take care of creating ad-hoc prefix (per-application) when starting for the 1st time, and then next times run that dedicated .exe from within its own prefix?
hackoon
Level 1
Level 1
Posts: 5
Joined: Sat Feb 27, 2021 12:35 pm

Re: winerun cmdline wine tool

Post by hackoon »

succodifrutta wrote: Fri Apr 16, 2021 6:56 am
hackoon wrote: Sat Feb 27, 2021 12:58 pm winerun v1.0

if you prefix isn't found than either cd into a prefix or prefix-collection folder or define the WINEDRIVES enviroment var with a comma separated list of prefix collection folders.
best added to ~/.bashrc : (example)
export WINEDRIVES="/home/user1/WinePrefixes /media/User1/wingames"
That's an awesome functionality!!! 8)

So if I understood right:

Code: Select all

winerun portable.exe
winerun setup.exe
winerun someother.exe
etc...
Will always take care of creating ad-hoc prefix (per-application) when starting for the 1st time, and then next times run that dedicated .exe from within its own prefix?
if you want a direct link to start an exe without prefixing winerun you can use:
winerun copy someother.exe
this will create a copy of winerun in the exe's basic prefix folder with the name './someother'
you can then either directly call ./someother or symbolic link it into /usr/local/bin/<anynameyoulike>

I will upload the next version soon that creates a .desktop file with the exe's icon...
hackoon
Level 1
Level 1
Posts: 5
Joined: Sat Feb 27, 2021 12:35 pm

winerun v1.1

Post by hackoon »

winerun v1.1

install with:
chmod a+x winerun/winerun
sudo cp winerun/winerun /usr/local/bin/

see first post for general description
- this is intended as a cmd-line only addition or replacement for PoL or Lutris
- this is mainly for wine users that need a fast way to manage different WINEPREFIXes from the shell prompt or script
- it will use present PREFIXes and some parameters from Lutris configuration (mainly wine-version) if found
- it can also create new WINEPREFIX independetly from Lutris,PoL
- it does not alter the PREFIX's configuration other than using a different wine-version if changed with 'version'

you should now be able to simply run any exe in its existing WINEPREFIX with:
winerun <exe>

Code: Select all


	winerun -- wine cmdline tool
	version 1.1

	* no need to set WINEPREFIX or "cd" into the right folder
	* easy version management
	* auto-restores screen-size if changed within wine 
	* intuitive, small and fast

	syntax:
	    winerun [dryrun|copy] [[version] <wineversion>|wine|lutris>] [prefix] <wineprefix>|<exe> [new] [cd] [[exec] <exe>|<shellscript>] [<args>]
	    winerun [dryrun] [[version] <wineversion>]|wine|lutris>] [prefix] <wineprefix>|<exe> [cd] [winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad] [<args>]
	    winerun [dryrun] [prefix] <wineprefix>|<exe> [edit|firefox|gimp|kill|suspend|resume] <args>
	    <exe name> [dryrun] [[version] <wineversion>|wine|lutris>] [[exec <exe>|<shellscript>]|winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad|edit|firefox|gimp] [<args>]

	with:
	    - <wineprefix>: either a full path or defined in WINEDRIVES
	    - <exe>: a full or partitional path with shell patterns (*?) with or without ".exe" extensions
	    - <exe name>: renamed/liked winerun with the filename of any *.exe inside of a prefix  with or without ".exe" extensions
	    - copy: copies the winrun script to <prefix>/<exe without path> to be started with that script by calling it directly or symolic linking it
	    - copy additonal creates <prefix>/<exe without path>.desktop file 
	    - if both wrestool (icoutils) and convert (ImageMagic) are installed copy creates an <exe>.png iconfile from the windows icon
	    - can be killed, resumed or suspended - kill can have a different signal than default 9 as argument
	    - <shellscript>: a full or partitional path with shell patterns with ".sh" extensions
	    - <wineversion>: either a folder defined in WINERUNNERS or a number used as pattern in the same WINERUNNERS folders
	    - cd: changes dir to the same folder the <exe> is found or to <prefix>/drive_c if no <exe> is given
	    - new: creates new prefix (in the first WINEDRIVES folder if no absolute path is given)
	    - dryrun: do not execute or create anything (apart from .sh scripts in <prefix>) but print-out the actions
	    - also "wine" or "lutris" can be used for version: it removes any saved version and default to either system wine or the lutris version defined in .yml
	    - when "exec" is not used then "cd" is assumed
	    - all exept <prefix> ignore case distinction 
	    - if only prefix is given then it will try to find the exe and path from a Lutris .yml configuration
	    - in most places "find" is used to find the file if no absolute path is given
	    - will not follow linked folders
	    - if more then one alternative is found then the command will be interupted and the alternatives printed on screen

	examples:
	    winerun GRunner
	    winerun GRunner kill
	    winerun 4.24 grunner -fullscreen y
	    winerun version 4.24 prefix WGame cd exec grunner.exe -fullscreen y -playnet 2
	    winerun wine ~/WPrefixes/WGame new exec /media/user1/CD1/Setup.exe
	    winerun Grun* notepad readme.txt
	    winerun version lutris-4.21-x86_64 WGame Bin/Release/GRunner
	    winerun GRunner.exe edit gfx.ini
	    winerun dryrun GRunner.exe regedit myconfig.reg
	    winerun lutris WGame exec lvlEdit 
	    winerun WGame gimp image/sell0.png
	    winerun copy 4.24 GRun* -fullscreen y
	    ./WGame/GRunner -playnet 2
	
	env vars:       (auto-assigned)
	    WINEDRIVES  (/home/test/Games)
	    WINERUNNERS (/home/test/.local/share/lutris/runners/wine /home/test/.PlayOnLinux/wine)
	    WINE        ()
	    WINEEDITOR  (/usr/bin/mcedit)

	<prefix>/winerun.sh file:
	    - will contain the last WINE=<version>
	    - can also contain any user-defined script like "export WINEDEBUG=+loaddll"
	    - will be removed when empty
	    - can use relative path for wine binary with <prefix> as start (to use as bottle)

	<prefix>/<exe name without .exe>.sh file:
	    - shellscript will be sourced before running exe with the same name
	    - autoupdates with options="<cmdline options>" when "copy" is used

	vars to be used with the above .sh scripts:
	    noscreen_restore=1 (disables the auto restore screensize feature)
	    options="<args to exe>" (will by prefixed to cmdline args)

	<prefix>/<exe name without .exe>.lua file:
	    - will call lua with the script and the wine exe call as arguments
	    - non zero exit status will stop winerun
	    - will be ignored while dryrun 

	linked/renamed winrerun:
	    - linked/renamed winerun will run winerun with <filename> as <exe> 
	    - renamed copy of winerun in a WINEPREFIX will be used as <exe> inside of the prefix (can be created with: "winrun copy" )
	    - above copy can be symbolical linked (link name can be anything)



Changelog:
added support to kill, suspend and resume any running exe

- can take another signal as argument to kill (default 9)
- restores screen-size after exe exits (if started with winerun)

added creation of .desktop and .png icon files when using 'copy' cmd

- needs icoutils being installed
- .desktop uses the created copy of winerun in the PREFIX folder to start the exe

Download:
winrun on GitHub
hackoon
Level 1
Level 1
Posts: 5
Joined: Sat Feb 27, 2021 12:35 pm

winerun 1.3

Post by hackoon »

winerun v1.3

install with:
chmod a+x winerun/winerun
sudo cp winerun/winerun /usr/local/bin/

see first post for general description
- this is intended as a cmd-line only addition or replacement for PoL or Lutris
- this is mainly for wine users that need a fast way to manage different WINEPREFIXes from the shell prompt or script
- it will use present PREFIXes and some parameters from Lutris configuration (mainly wine-version) if found
- it can also create new WINEPREFIX independetly from Lutris,PoL
- it does not alter the PREFIX's configuration other than using a different wine-version if changed with 'version'

you should now be able to simply run any exe in its existing WINEPREFIX with:
winerun <exe>

Code: Select all

	winerun -- wine cmdline tool
	version 1.3

	* no need to set WINEPREFIX or "cd" into the right folder
	* easy version management
	* auto-restores screen-size if changed within wine 
	* intuitive, small and fast

	syntax:
	    winerun [gdb|dbg|dryrun|copy] [[version] <wineversion>|wine|lutris>] [prefix] <wineprefix>|<exe> [new] [cd] [[exec] <exe>|<shellscript>] [<args>]
	    winerun [gdb|dbg|dryrun] [[version] <wineversion>]|wine|lutris>] [prefix] <wineprefix>|<exe> [cd] [winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad] [<args>]
	    winerun [dryrun] [prefix] <wineprefix>|<exe> [edit|firefox|gimp|kill|suspend|resume] <args>
	    <exe name> [gdb|dbg|dryrun] [[version] <wineversion>|wine|lutris>] [[exec <exe>|<shellscript>]|winecfg|regedit|msiexec|regsvr32|reg|cmd|winetricks|noteapad|edit|firefox|gimp] [<args>]

	with:
	    - <wineprefix>: either a full path or defined in WINEDRIVES
	    - <exe>: a full or partitional path with shell patterns (*?) with or without ".exe" extensions
	    - <exe name>: renamed/liked winerun with the filename of any *.exe inside of a prefix  with or without ".exe" extensions
	    - copy: copies the winrun script to <prefix>/<exe without path> to be started with that script by calling it directly or symolic linking it
	    - copy additonal creates <prefix>/<exe without path>.desktop file (does not overwrite existing file) 
	    - if both wrestool (icoutils) and convert (ImageMagic) are installed copy creates an <exe>.png iconfile from the windows icon (no overwrite)
	    - can be killed, resumed or suspended - kill can have a different signal than default 9 as argument
	    - <shellscript>: a full or partitional path with shell patterns with ".sh" extensions
	    - <wineversion>: either a folder defined in WINERUNNERS or a number used as pattern in the same WINERUNNERS folders
	    - cd: changes dir to the same folder the <exe> is found or to <prefix>/drive_c if no <exe> is given
	    - new: creates new prefix (in the first WINEDRIVES folder if no absolute path is given)
	    - dpg / gdb use internal or gdb as debugger
	    - dryrun: do not execute or create anything (apart from .sh scripts in <prefix>) but print-out the actions
	    - also "wine" or "lutris" can be used for version: it removes any saved version and default to either system wine or the lutris version defined in .yml
	    - when "exec" is not used then "cd" is assumed
	    - all exept <prefix> ignore case distinction 
	    - if only prefix is given then it will try to find the exe and path from a Lutris .yml configuration
	    - in most places "find" is used to find the file if no absolute path is given
	    - will not follow linked folders
	    - if more then one alternative is found then the command will be interupted and the alternatives printed on screen

	examples:
	    winerun GRunner
	    winerun GRunner kill
	    winerun 4.24 grunner -fullscreen y
	    winerun version 4.24 prefix WGame cd exec grunner.exe -fullscreen y -playnet 2
	    winerun wine ~/WPrefixes/WGame new exec /media/user1/CD1/Setup.exe
	    winerun Grun* notepad readme.txt
	    winerun version lutris-4.21-x86_64 WGame Bin/Release/GRunner
	    winerun GRunner.exe edit gfx.ini
	    winerun dryrun GRunner.exe regedit myconfig.reg
	    winerun lutris WGame exec lvlEdit 
	    winerun WGame gimp image/sell0.png
	    winerun copy 4.24 GRun* -fullscreen y
	    ./WGame/GRunner -playnet 2
	
	env vars:       (auto-assigned)
	    WINEDRIVES  (/files/Games)
	    WINERUNNERS (/files/wine)
	    WINE        (wine)
	    WINEEDITOR  (/usr/bin/mcedit)

	<prefix>/winerun.sh file:
	    - will contain the last WINE=<version>
	    - can also contain any user-defined script like "export WINEDEBUG=+loaddll"
	    - will be removed when empty
	    - can use relative path for wine binary with <prefix> as start (to use as bottle)

	<prefix>/<exe name without .exe>.sh file:
	    - shellscript will be sourced before running exe with the same name
	    - autoupdates with options="<cmdline options>" when "copy" is used

	vars to be used with the above .sh scripts:
	    noscreen_restore=1 (disables the auto restore screensize feature)
	    options="<args to exe>" (will by prefixed to cmdline args)

	<prefix>/<exe name without .exe>.lua file:
	    - will call lua with the script and the wine exe call as arguments
	    - non zero exit status will stop winerun
	    - will be ignored while dryrun 

	linked/renamed winerun:
	    - linked/renamed winerun will run winerun with <filename> as <exe> 
	    - renamed copy of winerun in a WINEPREFIX will be used as <exe> inside of the prefix (can be created with: 'winerun copy' )
	    - above copy can be symbolical linked (link name can be anything)
Download:

winerun on github
Locked