From 28ed6342cc059c5aacdaf8d864d9522973d91e00 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sun, 14 May 2023 13:03:42 +0200 Subject: [PATCH] Added ability to toggle parsing of notification 2fa codes (#260) --- src/config.json.in | 1 + src/configModel/configModel.vala | 5 +++++ src/configSchema.json | 5 +++++ src/notification/notification.vala | 1 + 4 files changed, 12 insertions(+) diff --git a/src/config.json.in b/src/config.json.in index b6dc3fe..1f5e5af 100644 --- a/src/config.json.in +++ b/src/config.json.in @@ -8,6 +8,7 @@ "control-center-margin-bottom": 0, "control-center-margin-right": 0, "control-center-margin-left": 0, + "notification-2fa-action": true, "notification-icon-size": 64, "notification-body-image-height": 100, "notification-body-image-width": 200, diff --git a/src/configModel/configModel.vala b/src/configModel/configModel.vala index 8ed9a83..80aac8b 100644 --- a/src/configModel/configModel.vala +++ b/src/configModel/configModel.vala @@ -541,6 +541,11 @@ namespace SwayNotificationCenter { } } + /** + * If each notification should display a 'COPY \"1234\"' action + */ + public bool notification_2fa_action { get; set; default = true; } + /** * Notification icon size, in pixels. */ diff --git a/src/configSchema.json b/src/configSchema.json index 2131b90..d79453b 100644 --- a/src/configSchema.json +++ b/src/configSchema.json @@ -64,6 +64,11 @@ "description": "The margin (in pixels) at the left of the notification center. 0 to disable", "default": 0 }, + "notification-2fa-action": { + "type": "boolean", + "description": "If each notification should display a 'COPY \"1234\"' action", + "default": true + }, "notification-icon-size": { "type": "integer", "description": "The notification icon size (in pixels)", diff --git a/src/notification/notification.vala b/src/notification/notification.vala index 67c10b8..a867f80 100644 --- a/src/notification/notification.vala +++ b/src/notification/notification.vala @@ -293,6 +293,7 @@ namespace SwayNotificationCenter { /** Returns the first code found, else null */ private string ? parse_body_codes () { + if (!ConfigModel.instance.notification_2fa_action) return null; string body = this.body.get_text ().strip (); if (body.length == 0) return null;