Skip to content

Commit

Permalink
Make client id configurable
Browse files Browse the repository at this point in the history
This is a global configuration for now.
  • Loading branch information
FichteFoll committed May 9, 2023
1 parent c2ad499 commit de9d532
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions discordrp_mpris/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from .config import Config

CLIENT_ID = '435587535150907392'
PLAYER_ICONS = {
# Maps player identity name to icon name
# https://discord.com/developers/applications/435587535150907392/rich-presence/assets
Expand Down Expand Up @@ -328,13 +327,17 @@ def format_details(template: str, replacements: Dict[str, Any]) -> str:
return details


async def main_async(loop: asyncio.AbstractEventLoop):
async def main_async(loop: asyncio.AbstractEventLoop) -> int:
config = Config.load()
# TODO validate?
configure_logging(config)

mpris = await Mpris2Dbussy.create(loop=loop)
async with AsyncDiscordRpc.for_platform(CLIENT_ID) as discord:
client_id = config.raw_get('global.client_id')
if not client_id:
logger.error("client id missing!")
return 1
async with AsyncDiscordRpc.for_platform(client_id) as discord:
instance = DiscordMpris(mpris, discord, config)
return await instance.run()

Expand Down
7 changes: 7 additions & 0 deletions discordrp_mpris/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ log_level = "WARNING"
poll_interval = 5
reconnect_wait = 1

# [Advanced usage]
# Allows overriding the client id with your own.
# This affects the icon assets that will be available for use,
# as well as the main application name.
# You can register your own at https://discord.com/developers/applications/.
client_id = "435587535150907392"

# The following can be overridden per player.
[options]
# Whether to show status for paused players.
Expand Down

0 comments on commit de9d532

Please sign in to comment.