mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-05-02 04:52:03 -04:00
Steamdeck support?
This commit is contained in:
@@ -16,7 +16,7 @@ def fetch_latest_version():
|
|||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
def show_header():
|
def show_header(app_version):
|
||||||
clear_screen()
|
clear_screen()
|
||||||
cyan = '\033[96m'
|
cyan = '\033[96m'
|
||||||
reset = '\033[0m'
|
reset = '\033[0m'
|
||||||
@@ -51,7 +51,13 @@ def parse_vdf(file_path):
|
|||||||
return library_paths
|
return library_paths
|
||||||
|
|
||||||
def find_steam_library_folders():
|
def find_steam_library_folders():
|
||||||
base_paths = [os.path.expanduser('~/.steam/steam'), os.path.expanduser('~/.local/share/Steam'), '/mnt', '/media']
|
base_paths = [
|
||||||
|
os.path.expanduser('~/.steam/steam'),
|
||||||
|
os.path.expanduser('~/.local/share/Steam'),
|
||||||
|
os.path.expanduser('~/home/deck/.steam/steam'),
|
||||||
|
os.path.expanduser('~/home/deck/.local/share/Steam'),
|
||||||
|
'/mnt', '/media'
|
||||||
|
]
|
||||||
library_folders = []
|
library_folders = []
|
||||||
for base_path in base_paths:
|
for base_path in base_paths:
|
||||||
if os.path.exists(base_path):
|
if os.path.exists(base_path):
|
||||||
@@ -76,24 +82,32 @@ def find_steam_apps(library_folders):
|
|||||||
if os.path.exists(folder):
|
if os.path.exists(folder):
|
||||||
for item in os.listdir(folder):
|
for item in os.listdir(folder):
|
||||||
if acf_pattern.match(item):
|
if acf_pattern.match(item):
|
||||||
|
try:
|
||||||
app_id, game_name, install_dir = parse_acf(os.path.join(folder, item))
|
app_id, game_name, install_dir = parse_acf(os.path.join(folder, item))
|
||||||
if app_id and game_name:
|
if app_id and game_name:
|
||||||
install_path = os.path.join(folder, 'common', install_dir)
|
install_path = os.path.join(folder, 'common', install_dir)
|
||||||
if os.path.exists(install_path):
|
if os.path.exists(install_path):
|
||||||
cream_installed = 'Cream installed' if 'cream.sh' in os.listdir(install_path) else ''
|
cream_installed = 'Cream installed' if 'cream.sh' in os.listdir(install_path) else ''
|
||||||
games[app_id] = (game_name, cream_installed, install_path)
|
games[app_id] = (game_name, cream_installed, install_path)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error parsing {item}: {e}")
|
||||||
return games
|
return games
|
||||||
|
|
||||||
def parse_acf(file_path):
|
def parse_acf(file_path):
|
||||||
|
try:
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
data = file.read()
|
data = file.read()
|
||||||
app_id = re.search(r'"appid"\s+"(\d+)"', data)
|
app_id = re.search(r'"appid"\s+"(\d+)"', data)
|
||||||
name = re.search(r'"name"\s+"([^"]+)"', data)
|
name = re.search(r'"name"\s+"([^"]+)"', data)
|
||||||
install_dir = re.search(r'"installdir"\s+"([^"]+)"', data)
|
install_dir = re.search(r'"installdir"\s+"([^"]+)"', data)
|
||||||
return app_id.group(1), name.group(1), install_dir.group(1)
|
return app_id.group(1), name.group(1), install_dir.group(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error reading ACF file {file_path}: {e}")
|
||||||
|
return None, None, None
|
||||||
|
|
||||||
def fetch_dlc_details(app_id):
|
def fetch_dlc_details(app_id):
|
||||||
base_url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
|
base_url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
|
||||||
|
try:
|
||||||
response = requests.get(base_url)
|
response = requests.get(base_url)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if app_id not in data or "data" not in data[app_id]:
|
if app_id not in data or "data" not in data[app_id]:
|
||||||
@@ -122,10 +136,14 @@ def fetch_dlc_details(app_id):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Exception for DLC {dlc_id}: {str(e)}")
|
print(f"Exception for DLC {dlc_id}: {str(e)}")
|
||||||
return dlc_details
|
return dlc_details
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"Failed to fetch DLC details for {app_id}: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
def install_files(app_id, game_install_dir, dlcs, game_name):
|
def install_files(app_id, game_install_dir, dlcs, game_name):
|
||||||
zip_url = "https://github.com/anticitizn/creamlinux/releases/latest/download/creamlinux.zip"
|
zip_url = "https://github.com/anticitizn/creamlinux/releases/latest/download/creamlinux.zip"
|
||||||
zip_path = os.path.join(game_install_dir, 'creamlinux.zip')
|
zip_path = os.path.join(game_install_dir, 'creamlinux.zip')
|
||||||
|
try:
|
||||||
response = requests.get(zip_url)
|
response = requests.get(zip_url)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(zip_path, 'wb') as f:
|
with open(zip_path, 'wb') as f:
|
||||||
@@ -145,10 +163,15 @@ def install_files(app_id, game_install_dir, dlcs, game_name):
|
|||||||
print(f"Installation complete. Set launch options in Steam: 'sh ./cream.sh %command%' for {game_name}.")
|
print(f"Installation complete. Set launch options in Steam: 'sh ./cream.sh %command%' for {game_name}.")
|
||||||
else:
|
else:
|
||||||
print("Failed to download the files needed for installation.")
|
print("Failed to download the files needed for installation.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to install files for {game_name}: {e}")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
show_header()
|
show_header(app_version)
|
||||||
|
try:
|
||||||
library_folders = find_steam_library_folders()
|
library_folders = find_steam_library_folders()
|
||||||
|
if not library_folders:
|
||||||
|
raise FileNotFoundError("No Steam library folders found.")
|
||||||
games = find_steam_apps(library_folders)
|
games = find_steam_apps(library_folders)
|
||||||
if games:
|
if games:
|
||||||
print("Select the game for which you want to fetch DLCs:")
|
print("Select the game for which you want to fetch DLCs:")
|
||||||
@@ -162,14 +185,22 @@ def main():
|
|||||||
print(f"{idx}. {name} (App ID: {app_id})")
|
print(f"{idx}. {name} (App ID: {app_id})")
|
||||||
|
|
||||||
choice = int(input("Enter the number of the game: ")) - 1
|
choice = int(input("Enter the number of the game: ")) - 1
|
||||||
|
if choice < 0 or choice >= len(games_list):
|
||||||
|
raise ValueError("Invalid selection.")
|
||||||
selected_app_id, (selected_game_name, _, selected_install_dir) = games_list[choice]
|
selected_app_id, (selected_game_name, _, selected_install_dir) = games_list[choice]
|
||||||
print(f"You selected: {selected_game_name} (App ID: {selected_app_id})")
|
print(f"You selected: {selected_game_name} (App ID: {selected_app_id})")
|
||||||
|
|
||||||
dlcs = fetch_dlc_details(selected_app_id)
|
dlcs = fetch_dlc_details(selected_app_id)
|
||||||
|
if dlcs:
|
||||||
print("DLC IDs found:", [dlc['appid'] for dlc in dlcs]) # Only print app IDs for clarity
|
print("DLC IDs found:", [dlc['appid'] for dlc in dlcs]) # Only print app IDs for clarity
|
||||||
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
install_files(selected_app_id, selected_install_dir, dlcs, selected_game_name)
|
||||||
|
else:
|
||||||
|
print("No DLCs found for the selected game.")
|
||||||
else:
|
else:
|
||||||
print("No Steam games found on this computer or connected drives.")
|
print("No Steam games found on this computer or connected drives.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error occurred: {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user