From 9aa310fd070338d060b5d733e428741350dd3952 Mon Sep 17 00:00:00 2001 From: faulTTY <70842597+FaulTTY@users.noreply.github.com> Date: Fri, 26 May 2023 08:57:02 +0200 Subject: [PATCH] Make datetime format configurable (#18) Co-authored-by: Sciu-Crak Co-authored-by: FaulTTY --- data/config | 3 +++ src/Config.cpp | 1 + src/Config.h | 1 + src/System.cpp | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/data/config b/data/config index 1f3cee9..af9dbfb 100644 --- a/data/config +++ b/data/config @@ -43,6 +43,9 @@ UseHyprlandIPC: false # This can cause issues, if there is not enough space on screen (e.g. when opening the text) CenterTime: true +# Set datetime style +# DateTimeStyle: %a %D - %H:%M:%S %Z + # Adds a audio input(aka. microphone) widget AudioInput: false diff --git a/src/Config.cpp b/src/Config.cpp index d8a666f..03bf7c8 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -165,6 +165,7 @@ void Config::Load() AddConfigVar("ExitCommand", config.exitCommand, lineView, foundProperty); AddConfigVar("BatteryFolder", config.batteryFolder, lineView, foundProperty); AddConfigVar("DefaultWorkspaceSymbol", config.defaultWorkspaceSymbol, lineView, foundProperty); + AddConfigVar("DateTimeStyle", config.dateTimeStyle, lineView, foundProperty); AddConfigVar("CheckPackagesCommand", config.checkPackagesCommand, lineView, foundProperty); for (int i = 1; i < 10; i++) { diff --git a/src/Config.h b/src/Config.h index 9cda230..db1bd34 100644 --- a/src/Config.h +++ b/src/Config.h @@ -15,6 +15,7 @@ public: std::string batteryFolder = ""; // this can be BAT0, BAT1, etc. Usually in /sys/class/power_supply std::vector workspaceSymbols = std::vector(9, ""); std::string defaultWorkspaceSymbol = ""; + std::string dateTimeStyle = "%a %D - %H:%M:%S %Z"; // A sane default // Script that returns how many packages are out-of-date. The script should only print a number! // See data/update.sh for a human-readable version diff --git a/src/System.cpp b/src/System.cpp index 903439d..ba6e83c 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -604,7 +604,7 @@ namespace System time_t stdTime = time(NULL); tm* localTime = localtime(&stdTime); std::stringstream str; - str << std::put_time(localTime, "%a %D - %H:%M:%S %Z"); + str << std::put_time(localTime, Config::Get().dateTimeStyle.c_str()); return str.str(); }