From 29226d2ef23afd09d340ec82fe151cd72f78739a Mon Sep 17 00:00:00 2001 From: freeram Date: Thu, 7 Mar 2024 11:08:39 -0700 Subject: [PATCH] Add boilerplate Rich Presence integration --- pomodorodiscord/src/pomodoro_frame.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pomodorodiscord/src/pomodoro_frame.py b/pomodorodiscord/src/pomodoro_frame.py index aeb30d7..04935ae 100644 --- a/pomodorodiscord/src/pomodoro_frame.py +++ b/pomodorodiscord/src/pomodoro_frame.py @@ -1,8 +1,10 @@ import os import json +import threading import customtkinter as ctk from datetime import datetime from src.utils import load_config, DEF_POMODORO_MINS, DEF_SB_MINS, DEF_LB_MINS, beep +from src.richpresence import RichPresence BREAK_BTN_COLOR = "#9a9a9a" BREAK_HOVER = "#adaaaa" @@ -16,6 +18,9 @@ def __init__(self, master): self.data_file = 'data.json' config = load_config() + # Rich presence in separate thread + threading.Thread(target=self.init_rpc, daemon=True).start() + # Helper text that appears when a break is running self.break_text = ctk.StringVar(value="") self.break_label = ctk.CTkLabel(self, textvariable=self.break_text, font=("Roboto", 15)) @@ -48,6 +53,9 @@ def __init__(self, master): self.next_timer_update = None self.remaining_time = self.pomodoro_time + def init_rpc(self): + self.rpc = RichPresence() + def start_timer(self): if self.next_timer_update: self.after_cancel(self.next_timer_update)