This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wineprefixmanager
executable file
·86 lines (76 loc) · 2.25 KB
/
wineprefixmanager
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
import configparser
import argparse
import os
import subprocess
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'command',
help='Command to perform',
choices=[
'list', 'show', 'start', 'stop', 'config'
])
parser.add_argument(
'wineapp',
help='Application to act on',
nargs='?')
parser.add_argument(
'-c',
'--configfile',
default="{}/wineprefixmanager.ini".format(
os.environ.get(
'XDG_CONFIG_HOME',
"{}/.config".format(os.environ.get('HOME'))
)
),
help='ini-style config file with game settings')
args = parser.parse_args()
config = configparser.ConfigParser()
config.read(args.configfile)
if args.command == 'list':
for section in config.sections():
print(section)
exit()
elif not args.wineapp:
parser.error("app not specified")
elif not config.has_section(args.wineapp):
parser.error("{} not found in config".format(args.wineapp))
appconf = config[args.wineapp]
appdir = os.path.join(
os.path.expanduser(appconf['prefixpath']),
appconf['prefix'],
)
appenv = os.environ.copy()
appenv['WINEPREFIX'] = appdir
appenv['WINEDEBUG'] = '-all'
appcwd = os.path.join(
appdir,
appconf['exepath']
)
if args.command == 'show':
for k, v in config.items(args.wineapp):
print("{}={}".format(k, v))
if args.command == 'start':
cmd = [
'wine',
appconf['exe'],
]
cmd.append(appconf.get('options', ''))
subprocess.run(cmd, cwd=appcwd, env=appenv)
exit()
if args.command == 'stop':
cmd = [
'wineserver',
'--kill',
]
subprocess.run(cmd, cwd=appcwd, env=appenv)
exit()
if args.command == 'config':
cmd = [
'winecfg',
]
subprocess.run(cmd, cwd=appcwd, env=appenv)
exit()
if __name__ == '__main__':
main()