Skip to content

Commit

Permalink
Automatically get steam branch for translations
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Apr 9, 2024
1 parent 45137b7 commit 44805c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions css_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def get_steam_path() -> str:
else:
return f"{get_user_home()}/.steam/steam"

def is_steam_beta_active() -> bool:
beta_path = os.path.join(get_steam_path(), "package", "beta")
return os.path.exists(beta_path)

def create_steam_symlink() -> Result:
return create_symlink(get_theme_path(), os.path.join(get_steam_path(), "steamui", "themes_custom"))

Expand Down
10 changes: 8 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

sys.path.append(os.path.dirname(__file__))

from css_utils import Log, create_steam_symlink, Result, get_theme_path, store_read as util_store_read, store_write as util_store_write, store_or_file_config
from css_utils import Log, create_steam_symlink, Result, get_theme_path, store_read as util_store_read, store_write as util_store_write, store_or_file_config, is_steam_beta_active
from css_inject import ALL_INJECTS, initialize_class_mappings
from css_theme import CSS_LOADER_VER
from css_remoteinstall import install
Expand Down Expand Up @@ -34,7 +34,13 @@ async def fetch_class_mappings(css_translations_path : str, loader : Loader):
return

setting = util_store_read("beta_translations")
css_translations_url = "https://api.deckthemes.com/beta.json" if (setting == "1" or setting == "true") else "https://api.deckthemes.com/stable.json"

if ((len(setting.strip()) < 0 or setting == "-1" or setting == "auto") and is_steam_beta_active()) or (setting == "1" or setting == "true"):
css_translations_url = "https://api.deckthemes.com/beta.json"
else:
css_translations_url = "https://api.deckthemes.com/stable.json"

Log(f"Fetching CSS mappings from {css_translations_url}")

try:
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False), timeout=aiohttp.ClientTimeout(total=2)) as session:
Expand Down

0 comments on commit 44805c6

Please sign in to comment.