mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-08-17 11:50:40 +03:00
Added "relative-timestamps" config to switch between "25 minutes ago" and "2023-06-25T20:05:27-07" (#286)
Co-authored-by: Erik Reider <35975961+ErikReider@users.noreply.github.com>
This commit is contained in:
parent
98240489ba
commit
9bac0d09af
@ -124,16 +124,22 @@ config file to be able to detect config errors
|
||||
default: true ++
|
||||
description: Whether the control center should expand vertically to fill the screen
|
||||
|
||||
*relative-timestamps* ++
|
||||
type: bool ++
|
||||
default: true ++
|
||||
description: Display notification timestamps relative to now e.g. \"26 minutes ago\". ++
|
||||
If false, a local iso8601-formatted absolute timestamp is displayed.
|
||||
|
||||
*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"
|
||||
description: The control center height in pixels ++
|
||||
This setting is ignored when _fit-to-screen_ is set to "true".
|
||||
|
||||
*control-center-width* ++
|
||||
type: integer ++
|
||||
default: 500 ++
|
||||
description: The control centers width in pixels
|
||||
description: The control center width in pixels
|
||||
|
||||
*notification-visibility* ++
|
||||
type: object ++
|
||||
|
@ -19,6 +19,7 @@
|
||||
"timeout-low": 5,
|
||||
"timeout-critical": 0,
|
||||
"fit-to-screen": true,
|
||||
"relative-timestamps": true,
|
||||
"control-center-width": 500,
|
||||
"control-center-height": 600,
|
||||
"notification-window-width": 500,
|
||||
|
@ -523,6 +523,12 @@ namespace SwayNotificationCenter {
|
||||
/** Whether to expand the notification center across both edges of the screen */
|
||||
public bool fit_to_screen { get; set; default = true; }
|
||||
|
||||
/**
|
||||
* Display notification timestamp relative to now e.g. "26 minutes ago".
|
||||
* If false, a local iso8601-formatted absolute timestamp is displayed.
|
||||
*/
|
||||
public bool relative_timestamps { get; set; default = true; }
|
||||
|
||||
/**
|
||||
* Notification center's height, in pixels.
|
||||
* Set `fit_to_screen` to true to ignore the height setting.
|
||||
|
@ -128,6 +128,11 @@
|
||||
"description": "If the control center should expand to both edges of the screen",
|
||||
"default": true
|
||||
},
|
||||
"relative-timestamps": {
|
||||
"type": "boolean",
|
||||
"description": "Display notification timestamps relative to now e.g. \"26 minutes ago\". If false, a local iso8601-formatted absolute timestamp is displayed.",
|
||||
"default": true
|
||||
},
|
||||
"control-center-height": {
|
||||
"type": "integer",
|
||||
"description": "Height of the control center in pixels. Ignored when 'fit-to-screen' is set to 'true'",
|
||||
|
@ -556,10 +556,14 @@ namespace SwayNotificationCenter {
|
||||
}
|
||||
|
||||
public void set_time () {
|
||||
this.time.set_text (get_readable_time ());
|
||||
if (ConfigModel.instance.relative_timestamps) {
|
||||
this.time.set_text (get_relative_time ());
|
||||
} else {
|
||||
this.time.set_text (get_iso8601_time ());
|
||||
}
|
||||
}
|
||||
|
||||
private string get_readable_time () {
|
||||
private string get_relative_time () {
|
||||
string value = "";
|
||||
|
||||
double diff = (get_real_time () * 0.000001) - param.time;
|
||||
@ -590,6 +594,11 @@ namespace SwayNotificationCenter {
|
||||
return value;
|
||||
}
|
||||
|
||||
private string get_iso8601_time () {
|
||||
var dtime = new DateTime.from_unix_local (param.time);
|
||||
return dtime.format_iso8601 ();
|
||||
}
|
||||
|
||||
public void close_notification (bool is_timeout = false) {
|
||||
remove_noti_timeout ();
|
||||
this.revealer.set_reveal_child (false);
|
||||
|
Loading…
Reference in New Issue
Block a user