Last active
December 20, 2015 14:28
-
-
Save airtonix/6146333 to your computer and use it in GitHub Desktop.
Simple wineprefix tool (something winetricks should really support)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Chuck this in : ~/bin/wineprefix | |
$ chmod +x ~/bin/wineprefix | |
$ wineprefix list | |
# makes a list of directories at ~/.local/share/wineprefixes | |
borderlands2 | |
masseffect3 | |
fonv | |
$ cd ~/Games/FalloutNewVegas/ | |
$ wineprefix fonv ./FalloutNV.exe | |
$ wineprefix fonv remove | |
# removes ~/.local/share/wineprefixes/fonv/ | |
""" | |
import sys | |
import os | |
import stat | |
import shutil | |
def remove_readonly(fn, path, excinfo): | |
if fn is os.rmdir: | |
os.chmod(path, stat.S_IWRITE) | |
os.rmdir(path) | |
elif fn is os.remove: | |
os.chmod(path, stat.S_IWRITE) | |
os.remove(path) | |
if __name__ == "__main__": | |
wineprefix_path = os.path.expanduser("~/.local/share/wineprefixes") | |
args = sys.argv[1:] | |
if not len(args) > 0: | |
print("Missing prefix") | |
sys.exit() | |
if len(args) < 2: | |
print("no command") | |
sys.exit() | |
if args[0] == "list": | |
for folder in os.listdir(wineprefix_path): | |
print(folder) | |
else: | |
prefix = args[0] | |
args = args[1:] | |
if args[0] == "remove": | |
shutil.rmtree(os.path.abspath(wineprefix_path + "/" + prefix), onerror=remove_readonly) | |
else: | |
wine_command = [ | |
'WINEPREFIX=' + wineprefix_path + "/" + prefix, # setup the prefix | |
"optirun", "-b", "primus", # launch with bumblebee | |
"wine"] # then use wine | |
cmd = " ".join(wine_command + args) | |
os.popen(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment