initial commit
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Python-generated files
|
||||
__pycache__/
|
||||
*.py[oc]
|
||||
build/
|
||||
dist/
|
||||
wheels/
|
||||
*.egg-info
|
||||
|
||||
# Virtual environments
|
||||
.venv
|
||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.12
|
||||
10
LICENSE
Normal file
10
LICENSE
Normal file
@@ -0,0 +1,10 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
111
main.py
Normal file
111
main.py
Normal file
@@ -0,0 +1,111 @@
|
||||
import vdf
|
||||
import os
|
||||
from pathlib import Path
|
||||
import questionary
|
||||
from pyfiglet import Figlet
|
||||
|
||||
library_folders = []
|
||||
apps = {}
|
||||
|
||||
figlet = Figlet()
|
||||
|
||||
print(figlet.renderText("Steam .desktop Fixer"))
|
||||
|
||||
if not questionary.confirm(
|
||||
"This app will (probably) add a ton of files to your applications folder, you should probably back it up before continuing... (it should normally be at ~/.local/share/applications)"
|
||||
).ask():
|
||||
print("(that was probably a good idea tbh)")
|
||||
exit()
|
||||
|
||||
DESKTOP_FOLDER = os.path.join(os.path.expanduser("~"), ".local/share/applications")
|
||||
|
||||
if not os.path.exists(DESKTOP_FOLDER):
|
||||
print(
|
||||
"how the heck do you not even have a .desktop folder? ur system is too crazy for me."
|
||||
)
|
||||
exit()
|
||||
|
||||
LIBRARY_FOLDER_VDF_LOCATION = os.path.join(
|
||||
os.path.expanduser("~"), ".local/share/Steam/config/libraryfolders.vdf"
|
||||
)
|
||||
LIBRARY_FOLDER_VDF_LOCATION = (
|
||||
questionary.text(
|
||||
"Please enter the location of the steam libraryfolders.vdf file (nothing or default should work for normal installations, not flatpak):",
|
||||
default=LIBRARY_FOLDER_VDF_LOCATION,
|
||||
).ask()
|
||||
or LIBRARY_FOLDER_VDF_LOCATION
|
||||
)
|
||||
|
||||
if not os.path.exists(LIBRARY_FOLDER_VDF_LOCATION):
|
||||
print(
|
||||
"The file location you gave does not exist, exiting... (searching on google for the location on a flatpak install may help you)"
|
||||
)
|
||||
exit()
|
||||
|
||||
IGNORE_APPS = [
|
||||
lambda app: "steam" in app["name"].lower(),
|
||||
lambda app: "proton" in app["name"].lower(),
|
||||
lambda app: "dedicated server" in app["name"].lower(),
|
||||
lambda app: "soundtrack" in app["name"].lower(),
|
||||
lambda app: "runtime" in app["name"].lower(),
|
||||
lambda app: "steamvr" in app["name"].lower(),
|
||||
lambda app: "tool" in app["name"].lower(),
|
||||
lambda app: "authoring" in app["name"].lower(),
|
||||
lambda app: "sdk" in app["name"].lower(),
|
||||
lambda app: "are you ready for valve index?" in app["name"].lower(),
|
||||
]
|
||||
|
||||
print("Generating apps list...")
|
||||
|
||||
library_folders_vdf = vdf.load(open(LIBRARY_FOLDER_VDF_LOCATION, "r"))
|
||||
|
||||
for steam_library_info in library_folders_vdf["libraryfolders"].values():
|
||||
if isinstance(steam_library_info, dict):
|
||||
library_folders.append(steam_library_info["path"])
|
||||
|
||||
for steam_library in library_folders:
|
||||
steamapps_dir = os.path.join(steam_library, "steamapps")
|
||||
for file in os.listdir(steamapps_dir):
|
||||
if Path(file).suffix == ".acf" and file.startswith("appmanifest_"):
|
||||
app_manifest = vdf.load(open(os.path.join(steamapps_dir, file)))
|
||||
app_info = app_manifest["AppState"]
|
||||
apps.update({app_info["appid"]: app_info["name"]})
|
||||
|
||||
print("Done...")
|
||||
|
||||
choices = []
|
||||
for id, name in apps.items():
|
||||
app_dict = {"id": id, "name": name}
|
||||
if any(rule(app_dict) for rule in IGNORE_APPS):
|
||||
choices.append(questionary.Choice(name, value=app_dict, checked=False))
|
||||
else:
|
||||
choices.insert(0, questionary.Choice(name, value=app_dict, checked=True))
|
||||
|
||||
|
||||
selected_apps = questionary.checkbox(
|
||||
"Please select the games you want to add...", choices
|
||||
).ask()
|
||||
|
||||
if any(
|
||||
app["name"] + ".desktop" not in os.listdir(DESKTOP_FOLDER) for app in selected_apps
|
||||
):
|
||||
print("Creating .desktop files...")
|
||||
for app in selected_apps:
|
||||
name = app["name"]
|
||||
id = app["id"]
|
||||
desktop_name = name + ".desktop"
|
||||
if not desktop_name in os.listdir(DESKTOP_FOLDER):
|
||||
with open(os.path.join(DESKTOP_FOLDER, desktop_name), "w") as f:
|
||||
f.write(f"""[Desktop Entry]
|
||||
Name={name}
|
||||
Comment=Play this game on Steam
|
||||
Exec=steam steam://rungameid/{id}
|
||||
Icon=steam_icon_{id}
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Game;""")
|
||||
print("Successfully added all the applications (that didn't exist already)!")
|
||||
else:
|
||||
print(
|
||||
"You don't have any apps that need a .desktop to be generated (if you are having a problem, it's probably something else)!"
|
||||
)
|
||||
11
pyproject.toml
Normal file
11
pyproject.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[project]
|
||||
name = "steam-dot-desktop-fixer"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"pyfiglet>=1.0.4",
|
||||
"questionary>=2.1.1",
|
||||
"vdf>=3.4",
|
||||
]
|
||||
71
uv.lock
generated
Normal file
71
uv.lock
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[[package]]
|
||||
name = "prompt-toolkit"
|
||||
version = "3.0.52"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "wcwidth" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a1/96/06e01a7b38dce6fe1db213e061a4602dd6032a8a97ef6c1a862537732421/prompt_toolkit-3.0.52.tar.gz", hash = "sha256:28cde192929c8e7321de85de1ddbe736f1375148b02f2e17edd840042b1be855", size = 434198, upload-time = "2025-08-27T15:24:02.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/84/03/0d3ce49e2505ae70cf43bc5bb3033955d2fc9f932163e84dc0779cc47f48/prompt_toolkit-3.0.52-py3-none-any.whl", hash = "sha256:9aac639a3bbd33284347de5ad8d68ecc044b91a762dc39b7c21095fcd6a19955", size = 391431, upload-time = "2025-08-27T15:23:59.498Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyfiglet"
|
||||
version = "1.0.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/c8/e3/0a86276ad2c383ce08d76110a8eec2fe22e7051c4b8ba3fa163a0b08c428/pyfiglet-1.0.4.tar.gz", hash = "sha256:db9c9940ed1bf3048deff534ed52ff2dafbbc2cd7610b17bb5eca1df6d4278ef", size = 1560615, upload-time = "2025-08-15T18:32:47.302Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9f/5c/fe9f95abd5eaedfa69f31e450f7e2768bef121dbdf25bcddee2cd3087a16/pyfiglet-1.0.4-py3-none-any.whl", hash = "sha256:65b57b7a8e1dff8a67dc8e940a117238661d5e14c3e49121032bd404d9b2b39f", size = 1806118, upload-time = "2025-08-15T18:32:45.556Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "questionary"
|
||||
version = "2.1.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "prompt-toolkit" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f6/45/eafb0bba0f9988f6a2520f9ca2df2c82ddfa8d67c95d6625452e97b204a5/questionary-2.1.1.tar.gz", hash = "sha256:3d7e980292bb0107abaa79c68dd3eee3c561b83a0f89ae482860b181c8bd412d", size = 25845, upload-time = "2025-08-28T19:00:20.851Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/3c/26/1062c7ec1b053db9e499b4d2d5bc231743201b74051c973dadeac80a8f43/questionary-2.1.1-py3-none-any.whl", hash = "sha256:a51af13f345f1cdea62347589fbb6df3b290306ab8930713bfae4d475a7d4a59", size = 36753, upload-time = "2025-08-28T19:00:19.56Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "steam-dot-desktop-fixer"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "pyfiglet" },
|
||||
{ name = "questionary" },
|
||||
{ name = "vdf" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "pyfiglet", specifier = ">=1.0.4" },
|
||||
{ name = "questionary", specifier = ">=2.1.1" },
|
||||
{ name = "vdf", specifier = ">=3.4" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vdf"
|
||||
version = "3.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/44/7f/74192f47d67c8bf3c47bf0d8487b3457614c2c98d58b6617721d217f3f79/vdf-3.4.tar.gz", hash = "sha256:fd5419f41e07a1009e5ffd027c7dcbe43d1f7e8ef453aeaa90d9d04b807de2af", size = 11132, upload-time = "2021-05-22T09:26:05.252Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/96/60/6456b687cf55cf60020dcd01f9bc51561c3cc84f05fd8e0feb71ce60f894/vdf-3.4-py2.py3-none-any.whl", hash = "sha256:68c1a125cc49e343d535af2dd25074e9cb0908c6607f073947c4a04bbe234534", size = 10357, upload-time = "2021-05-22T09:26:03.948Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wcwidth"
|
||||
version = "0.7.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2c/ee/afaf0f85a9a18fe47a67f1e4422ed6cf1fe642f0ae0a2f81166231303c52/wcwidth-0.7.0.tar.gz", hash = "sha256:90e3a7ea092341c44b99562e75d09e4d5160fe7a3974c6fb842a101a95e7eed0", size = 182132, upload-time = "2026-05-02T16:04:12.653Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/41/52/e465037f5375f43533d1a80b6923955201596a99142ed524d77b571a1418/wcwidth-0.7.0-py3-none-any.whl", hash = "sha256:5d69154c429a82910e241c738cd0e2976fac8a2dd47a1a805f4afed1c0f136f2", size = 110825, upload-time = "2026-05-02T16:04:11.033Z" },
|
||||
]
|
||||
Reference in New Issue
Block a user