-
-
Notifications
You must be signed in to change notification settings - Fork 291
/
Copy pathglobals.py
110 lines (94 loc) · 3.21 KB
/
globals.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# globals.py
#
# Copyright 2022 brombinmirko <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, in version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import shutil
from pathlib import Path
from bottles.backend.utils import yaml, json
class Paths:
xdg_data_home = os.environ.get(
"XDG_DATA_HOME", os.path.join(Path.home(), ".local/share")
)
# Icon paths
icons_user = f"{xdg_data_home}/icons"
# Local paths
base = f"{xdg_data_home}/bottles"
# User applications path
applications = f"{xdg_data_home}/applications/"
temp = f"{base}/temp"
runtimes = f"{base}/runtimes"
winebridge = f"{base}/winebridge"
runners = f"{base}/runners"
bottles = f"{base}/bottles"
steam = f"{base}/steam"
dxvk = f"{base}/dxvk"
vkd3d = f"{base}/vkd3d"
nvapi = f"{base}/nvapi"
latencyflex = f"{base}/latencyflex"
templates = f"{base}/templates"
library = f"{base}/library.yml"
@staticmethod
def is_vkbasalt_available():
vkbasalt_paths = [
"/usr/lib/extensions/vulkan/vkBasalt/etc/vkBasalt",
"/usr/local",
"/usr/share/vkBasalt",
]
for path in vkbasalt_paths:
if os.path.exists(path):
return True
return False
@classmethod
def get_components_paths(cls) -> list[str]:
"""Retrieve list of components' paths."""
return [
cls.temp,
cls.runtimes,
cls.winebridge,
cls.runners,
cls.bottles,
cls.steam,
cls.dxvk,
cls.vkd3d,
cls.nvapi,
cls.latencyflex,
cls.templates,
]
class TrdyPaths:
# External managers paths
wine = f"{Path.home()}/.wine"
lutris = f"{Path.home()}/Games"
playonlinux = f"{Path.home()}/.PlayOnLinux/wineprefix"
bottlesv1 = f"{Path.home()}/.Bottles"
# check if bottles exists in xdg data path
os.makedirs(Paths.base, exist_ok=True)
# Check if some tools are available
gamemode_available = shutil.which("gamemoderun") or False
gamescope_available = shutil.which("gamescope") or False
vkbasalt_available = Paths.is_vkbasalt_available()
mangohud_available = shutil.which("mangohud") or False
obs_vkc_available = shutil.which("obs-vkcapture") or False
vmtouch_available = shutil.which("vmtouch") or False
base_version = ""
if os.path.isfile("/app/manifest.json"):
with open("/app/manifest.json", encoding="utf-8") as file:
base_version = (
json.load(file) # type: ignore
.get("base-version", "")
.removeprefix("stable-")
)
# encoding detection correction, following windows defaults
locale_encodings: dict[str, str] = {"ja_JP": "cp932", "zh_CN": "gbk"}