Show ableton in Discord
This commit is contained in:
parent
2bb7060a79
commit
61ce060bf4
@ -6,11 +6,14 @@ import logging
|
||||
import subprocess
|
||||
import shutil
|
||||
import time
|
||||
import pypresence
|
||||
from pathlib import Path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
WINEASIO_SRC_PATH = Path("~/src/wineasio").expanduser()
|
||||
DISCORD_CLIENT_ID = 1175091631913963610
|
||||
DISCORD_ICON = "ableton_grey"
|
||||
|
||||
|
||||
def build_wineasio():
|
||||
@ -68,12 +71,18 @@ def main() -> int:
|
||||
ap = argparse.ArgumentParser(
|
||||
prog="ableton-linux", description="Executes Ableton on Linux"
|
||||
)
|
||||
ap.add_argument(
|
||||
"--no-presence", "-n", help="Hide activity from Discord", action="store_true"
|
||||
)
|
||||
ap.add_argument(
|
||||
"--bottle", "-b", help="Use the specified bottle", default="Ableton 11 Suite"
|
||||
)
|
||||
ap.add_argument(
|
||||
"--program", "-p", help="Program to run", default="Ableton Live 11 Suite"
|
||||
)
|
||||
ap.add_argument(
|
||||
"--dry-run", help="Don't actually launch Ableton", action="store_true"
|
||||
)
|
||||
ap.add_argument(
|
||||
"-v", "--verbose", help="Enable verbose logging", action="store_true"
|
||||
)
|
||||
@ -90,8 +99,18 @@ def main() -> int:
|
||||
logger.error("You can't do this without bottles installed")
|
||||
return 1
|
||||
|
||||
# Configure discord presence
|
||||
discord_presence = pypresence.Presence(DISCORD_CLIENT_ID)
|
||||
discord_presence.connect()
|
||||
launch_start = int(time.time())
|
||||
|
||||
# Ensure we have wineasio
|
||||
if not (WINEASIO_SRC_PATH / "build64").exists():
|
||||
discord_presence.update(
|
||||
start=launch_start,
|
||||
large_image=DISCORD_ICON,
|
||||
details="Compiling WineASIO...",
|
||||
)
|
||||
build_wineasio()
|
||||
|
||||
# Figure out the wineprefix
|
||||
@ -101,6 +120,11 @@ def main() -> int:
|
||||
# Ensure that the bottle has the wineasio dll
|
||||
if not (wineprefix / ".wineasio-installed").is_file():
|
||||
logger.info("Registering wineasio")
|
||||
discord_presence.update(
|
||||
start=launch_start,
|
||||
large_image=DISCORD_ICON,
|
||||
details="Registering WineASIO with Ableton...",
|
||||
)
|
||||
subprocess.check_call(
|
||||
[WINEASIO_SRC_PATH / "wineasio-register"],
|
||||
env={"WINEPREFIX": str(wineprefix)},
|
||||
@ -131,12 +155,36 @@ def main() -> int:
|
||||
}
|
||||
)
|
||||
|
||||
# Launch Ableton via bottles
|
||||
logger.info("Launching Ableton")
|
||||
return_code = subprocess.call(
|
||||
["bottles-cli", "run", "-b", args.bottle, "-p", args.program], env=ableton_env
|
||||
# Update the presence message
|
||||
discord_presence.update(
|
||||
start=launch_start,
|
||||
large_image=DISCORD_ICON,
|
||||
details="Working on a project",
|
||||
buttons=[
|
||||
{"label": "Check out my music!", "url": "https://ewpratten.com/music"}
|
||||
],
|
||||
)
|
||||
return return_code
|
||||
|
||||
# Immediately cancel the presence if requested
|
||||
if args.no_presence:
|
||||
discord_presence.close()
|
||||
|
||||
# Launch Ableton via bottles
|
||||
if not args.dry_run:
|
||||
logger.info("Launching Ableton")
|
||||
return_code = subprocess.call(
|
||||
["bottles-cli", "run", "-b", args.bottle, "-p", args.program],
|
||||
env=ableton_env,
|
||||
)
|
||||
discord_presence.close()
|
||||
return return_code
|
||||
|
||||
else:
|
||||
logger.info("Dry run, not launching Ableton")
|
||||
logger.info("Press enter to continue")
|
||||
input()
|
||||
discord_presence.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user