From f400e4a134f521ffcbe45581cf723af20bd579d3 Mon Sep 17 00:00:00 2001 From: Nicolas Berbiche Date: Sun, 17 Apr 2022 16:25:22 -0400 Subject: [PATCH] Make notification center width and height configurable (#38) --- man/swaync.5.scd | 16 +++++++ src/config.json.in | 2 + src/configModel/configModel.vala | 32 +++++++++++++ src/configSchema.json | 19 +++++++- src/controlCenter/controlCenter.ui | 1 - src/controlCenter/controlCenter.vala | 68 +++++++++++++++------------- src/notification/notification.ui | 1 - 7 files changed, 104 insertions(+), 35 deletions(-) diff --git a/man/swaync.5.scd b/man/swaync.5.scd index 505408b..d416f2c 100644 --- a/man/swaync.5.scd +++ b/man/swaync.5.scd @@ -87,6 +87,22 @@ config file to be able to detect config errors default: true ++ description: Hides the control center when clicking on notification action +*fit-to-screen* ++ + type: bool ++ + default: true ++ + description: Whether the control center should expand vertically to fill the screen + +*control-center-height* ++ + type: integer ++ + default: 500 ++ + description: The control centers height in pixels. + This setting is ignored when _fit-to-screen_ it set to "true" + +*control-center-width* ++ + type: integer ++ + default: 500 ++ + description: The control centers width in pixels + *notification-visibility* ++ type: object ++ visibility object properties: ++ diff --git a/src/config.json.in b/src/config.json.in index 5991faf..fcdd9f7 100644 --- a/src/config.json.in +++ b/src/config.json.in @@ -9,6 +9,8 @@ "timeout": 10, "timeout-low": 5, "timeout-critical": 0, + "fit-to-screen": true, + "control-center-width": 500, "notification-window-width": 500, "keyboard-shortcuts": true, "image-visibility": "always", diff --git a/src/configModel/configModel.vala b/src/configModel/configModel.vala index aae5c6a..dd4bd8b 100644 --- a/src/configModel/configModel.vala +++ b/src/configModel/configModel.vala @@ -413,6 +413,38 @@ namespace SwayNotificationCenter { public bool script_fail_notify { get; set; default = true; } #endif + /** Whether to expand the notification center across both edges of the screen */ + public bool fit_to_screen { get; set; default = true; } + + /** + * Notification center's height, in pixels. + * Set `fit_to_screen` to true to ignore the height setting. + */ + private const int control_center_minimum_height = 300; + private int _control_center_height = control_center_minimum_height; + public int control_center_height { + get { + return _control_center_height; + } + set { + _control_center_height = value > control_center_minimum_height ? value : control_center_minimum_height; + } + } + + /** + * Notification center's width, in pixels. + */ + private const int control_center_minimum_width = 300; + private int _control_center_width = control_center_minimum_width; + public int control_center_width { + get { + return _control_center_width; + } + set { + _control_center_width = value > control_center_minimum_width ? value : control_center_minimum_width; + } + } + /* Methods */ /** diff --git a/src/configSchema.json b/src/configSchema.json index e596ad5..1dbf817 100644 --- a/src/configSchema.json +++ b/src/configSchema.json @@ -11,7 +11,7 @@ "type": "string", "description": "Horizontal position of control center and notification window", "default": "right", - "enum": ["right", "left"] + "enum": ["right", "left", "center"] }, "positionY": { "type": "string", @@ -59,6 +59,23 @@ "description": "Width of the notification in pixels", "default": 500 }, + "fit-to-screen": { + "type": "boolean", + "description": "If the control center should expand to both edges of the screen", + "default": true + }, + "control-center-height": { + "type": "integer", + "description": "Height of the control center in pixels. Ignored when 'fit-to-screen' is set to 'true'", + "default": 600, + "minimum": 300 + }, + "control-center-width": { + "type": "integer", + "description": "Width of the control center in pixels", + "default": 500, + "minimum": 300 + }, "keyboard-shortcuts": { "type": "boolean", "description": "If control center should use keyboard shortcuts", diff --git a/src/controlCenter/controlCenter.ui b/src/controlCenter/controlCenter.ui index c38f00e..fa648dd 100644 --- a/src/controlCenter/controlCenter.ui +++ b/src/controlCenter/controlCenter.ui @@ -5,7 +5,6 @@