diff --git a/src/setup/gaming/osu_lazer.py b/src/setup/gaming/osu_lazer.py index d5c118b..6056826 100644 --- a/src/setup/gaming/osu_lazer.py +++ b/src/setup/gaming/osu_lazer.py @@ -1,51 +1,19 @@ -from src.util import flatpak_install, paru_install, appimage_install, copy_file +from src.util import ( + paru_install, + appimage_install, + copy_file, + get_latest_appimage_url_from_github, +) from src.setup.system import system76_scheduler -from os.path import exists from os import system -import requests -import re + name = "osu!lazer" post_install = ["Install osu! skin from https://github.com/developomp/osu-pomp-skin"] -def get_latest_osu_lazer_appimage_url() -> str: - return ( - re.search( - "(?Phttps?://[^\s]+)", - [ - t - for t in requests.get( - "https://api.github.com/repos/ppy/osu/releases/latest" - ).text.split(",") - if "browser_download" in t and 'AppImage"' in t - ][0], - ) - .group("url") - .split(".AppImage")[0] - + ".AppImage" - ) - - -def setup(): - """ - A circle-clicking rhythm game. - """ - - # install the game - appimage_install( - get_latest_osu_lazer_appimage_url(), - "osu", - ) - - # give CPU scheduler priority - system76_scheduler.setup() - - # - # set up tablet driver - # - +def setup_open_tablet_driver(): paru_install("opentabletdriver-git") # apply settings @@ -73,3 +41,19 @@ def setup(): # Enable and start the user service system("systemctl --user enable opentabletdriver --now") + + +def setup(): + """ + A circle-clicking rhythm game. + """ + + # install the game + appimage_install( + get_latest_appimage_url_from_github("ppy/osu"), + "osu", + ) + + # give CPU scheduler priority + system76_scheduler.setup() + setup_open_tablet_driver() diff --git a/src/util.py b/src/util.py index 5ab14c0..f75247d 100644 --- a/src/util.py +++ b/src/util.py @@ -6,6 +6,7 @@ from pathlib import Path import requests import zipfile import shutil +import re from src.log import error, log import src.constants @@ -78,6 +79,24 @@ def appimage_install(file_url: str, file_name: str) -> None: shutil.copyfileobj(raw, output) +def get_latest_appimage_url_from_github(repo: str) -> str: + return ( + re.search( + "(?Phttps?://[^\s]+)", + [ + t + for t in requests.get( + f"https://api.github.com/repos/{repo}/releases/latest" + ).text.split(",") + if "browser_download" in t and 'AppImage"' in t + ][0], + ) + .group("url") + .split(".AppImage")[0] + + ".AppImage" + ) + + def smart_mkdir(path: str) -> None: """ Recursively create directories if it doesn't exist already.