Skip to content

Commit

Permalink
feat: Added option to disable elapsed time (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
PenguinBoi12 authored Jan 18, 2023
1 parent c13e60c commit 771d83b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions DiscordRichPresence.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// Whether to change the timestamp when switching to/editing another file.
"time_per_file": true,

// Whether or not to show the elapsed time
"show_elapsed_time": true,

// Whether or not to use the small icon (changes for every language) in the presence.
"small_icon": false,

Expand Down
12 changes: 10 additions & 2 deletions drp.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def base_activity(started = False):
'raku'
}


def get_icon(file, ext, _scope):
main_scope = _scope.split()[0]
base_scope = main_scope.split('.')[0]
Expand All @@ -154,6 +155,7 @@ def get_icon(file, ext, _scope):

return 'https://raw.githubusercontent.com/Snazzah/SublimeDiscordRP/master/icons/lang-%s.png' % icon


def yield_subscopes(scope):
last_dot = len(scope)
while last_dot > 0:
Expand Down Expand Up @@ -224,7 +226,10 @@ def handle_activity(view, is_write=False, idle=False):
elif settings.get('small_icon'):
act['assets']['small_image'] = icon
act['assets']['small_text'] = language
act['timestamps'] = {'start': stamp}

if settings.get('show_elapsed_time'):
act['timestamps'] = {'start': stamp}

logger.info(window.folders())
try:
ipc.set_activity(act)
Expand Down Expand Up @@ -314,7 +319,9 @@ def connect(silent=False, retry=True):
return

act = base_activity(True)
act['timestamps'] = {'start': start_time}
if settings.get('show_elapsed_time'):
act['timestamps'] = {'start': start_time}

try:
ipc.set_activity(act)
except OSError as e:
Expand Down Expand Up @@ -367,6 +374,7 @@ def on_close(self, view):
else: reset_activity()
else: reset_activity()


class DiscordrpConnectCommand(sublime_plugin.ApplicationCommand):

def is_enabled(self):
Expand Down

0 comments on commit 771d83b

Please sign in to comment.