Skip to content

Commit

Permalink
Show total time studied in Rich Presence idle
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed May 4, 2024
1 parent 5bff74b commit abe6086
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/frames/pomodoro_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def update_rpc(self):
elif self.paused:
self.rpc.paused_state(self.start_time_timestamp)
else:
self.rpc.idling_state()
self.rpc.idling_state(self.seconds_studied)
else:
if self.discord_button.cget("state") == 'normal':
self.discord_button.configure(text=DISCONNECTED_TEXT, text_color=DISCONNECTED_COLOR)
Expand Down
8 changes: 5 additions & 3 deletions src/logic/richpresence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pypresence
from datetime import datetime
from src.utils import load_data

CLIENT_ID = '1215345125002059836'

Expand All @@ -11,6 +12,7 @@ def __init__(self):
# Can only update every 15 seconds
self.connected = False
self.connect()
self.total_seconds_studied = load_data().get('total_seconds_studied', 0)
self.idling_state()

def _handle_exceptions(func):
Expand Down Expand Up @@ -53,9 +55,9 @@ def format_time(self, seconds_studied):
return f"{round(total_hours, 1) if total_hours % 1 != 0 else int(total_hours)} hours"

@_handle_exceptions
def idling_state(self):
self.update(state="Idling", details=None, start=self.launch_time, large_image="graytomato",
large_text="github.com/freeram/pomodoro-discord")
def idling_state(self, seconds_studied=0):
self.update(state=f"Total time studied: {self.format_time(self.total_seconds_studied + seconds_studied)}",
details="Idling", start=self.launch_time, large_image="graytomato", large_text="github.com/freeram/pomodoro-discord")

@_handle_exceptions
def running_state(self, session, start_time, end_time):
Expand Down

0 comments on commit abe6086

Please sign in to comment.