diff --git a/gh/extension.py b/gh/extension.py index 6e091a0..6bc8e95 100644 --- a/gh/extension.py +++ b/gh/extension.py @@ -58,6 +58,7 @@ def __init__(self): self.subscribe(ItemEnterEvent, ItemEnterEventListener()) self.icon_path = 'images/icon.png' + self.os_notifs = None self.github: Github = None self.user: AuthenticatedUser = None self.cache = Cache(CACHE_DIR) @@ -83,7 +84,7 @@ def fetch_data_from_github(self): sync_service = GitHubDataSync(self.github, self.cache) try: - + self.preferences self.show_notification("Indexing GitHub data") start_time = time.time() @@ -116,11 +117,12 @@ def show_message_no_results(self, search_query): def show_notification(self, text: str): """ - Shows a notification + Shows a notification, if notifications are enabled Args: text (str): The text to display on the notification """ - Notify.Notification.new("Ulauncher GitHub", text).show() + if self.os_notifs == "true": + Notify.Notification.new("Ulauncher GitHub", text).show() def handle_github_exception(self, e: GithubException): logger.error(e) diff --git a/gh/listeners/preferences.py b/gh/listeners/preferences.py index 2ccf74f..765ec4c 100644 --- a/gh/listeners/preferences.py +++ b/gh/listeners/preferences.py @@ -11,6 +11,8 @@ class PreferencesEventListener(EventListener): def on_event(self, event, extension): """ Handle event """ + extension.os_notifs = event.preferences['os_notifs'] + logger.error(extension.os_notifs) extension.github = Github(event.preferences['access_token']) try: extension.refresh_user() diff --git a/manifest.json b/manifest.json index e881063..e071976 100644 --- a/manifest.json +++ b/manifest.json @@ -105,6 +105,14 @@ "name": "GitHub access token", "description": "The Personal Access token to authenticate on GitHub API", "default_value": "" + }, + { + "id": "os_notifs", + "type": "select", + "name": "Enable Notifications?", + "description": "Should a notification be sent", + "options": [true, false], + "default_value": true } ] }