From 239231b5cfe500b17e654229ef2e9c75705ca13b Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:27:41 +0700 Subject: [PATCH] user config: add time format #307 --- .../modules/.commonwidgets/notification.js | 2 +- .config/ags/modules/bar/normal/system.js | 6 +- .../desktopbackground/timeandlaunches.js | 6 +- .config/ags/user_options.js | 63 ++++++++++--------- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/.config/ags/modules/.commonwidgets/notification.js b/.config/ags/modules/.commonwidgets/notification.js index 93fd686cb..251320db3 100644 --- a/.config/ags/modules/.commonwidgets/notification.js +++ b/.config/ags/modules/.commonwidgets/notification.js @@ -218,7 +218,7 @@ export default ({ let notifTime = ''; const messageTime = GLib.DateTime.new_from_unix_local(notifObject.time); if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year()) - notifTime = messageTime.format('%H:%M'); + notifTime = messageTime.format(userOptions.time.format); else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1) notifTime = 'Yesterday'; else diff --git a/.config/ags/modules/bar/normal/system.js b/.config/ags/modules/bar/normal/system.js index 9da2d5aed..ba0e4acf0 100644 --- a/.config/ags/modules/bar/normal/system.js +++ b/.config/ags/modules/bar/normal/system.js @@ -34,9 +34,9 @@ const BarClock = () => Widget.Box({ children: [ Widget.Label({ className: 'bar-clock', - label: GLib.DateTime.new_now_local().format("%H:%M"), - setup: (self) => self.poll(5000, label => { - label.label = GLib.DateTime.new_now_local().format("%H:%M"); + label: GLib.DateTime.new_now_local().format(userOptions.time.format), + setup: (self) => self.poll(userOptions.time.interval, label => { + label.label = GLib.DateTime.new_now_local().format(userOptions.time.format); }), }), Widget.Label({ diff --git a/.config/ags/modules/desktopbackground/timeandlaunches.js b/.config/ags/modules/desktopbackground/timeandlaunches.js index 05ca1ab13..4a4f19a36 100644 --- a/.config/ags/modules/desktopbackground/timeandlaunches.js +++ b/.config/ags/modules/desktopbackground/timeandlaunches.js @@ -17,9 +17,9 @@ const TimeAndDate = () => Box({ Label({ className: 'bg-time-clock', xalign: 0, - label: GLib.DateTime.new_now_local().format("%H:%M"), - setup: (self) => self.poll(5000, label => { - label.label = GLib.DateTime.new_now_local().format("%H:%M"); + label: GLib.DateTime.new_now_local().format(userOptions.time.format), + setup: (self) => self.poll(userOptions.time.interval, label => { + label.label = GLib.DateTime.new_now_local().format(userOptions.time.format); }), }), Label({ diff --git a/.config/ags/user_options.js b/.config/ags/user_options.js index 11ffd5f40..84b7f01a7 100644 --- a/.config/ags/user_options.js +++ b/.config/ags/user_options.js @@ -2,27 +2,27 @@ let userConfigOptions = { // General stuff 'ai': { - 'defaultGPTProvider': 'openai', + 'defaultGPTProvider': "openai", 'defaultTemperature': 0.9, - 'writingCursor': ' ...', // Warning: Using weird characters can mess up Markdown rendering + 'writingCursor': " ...", // Warning: Using weird characters can mess up Markdown rendering }, 'animations': { 'durationSmall': 110, 'durationLarge': 180, }, 'apps': { - 'imageViewer': 'loupe', - 'terminal': 'foot', // This is only for shell actions + 'imageViewer': "loupe", + 'terminal': "foot", // This is only for shell actions }, 'battery': { 'low': 20, 'critical': 10, }, 'music': { - 'preferredPlayer': 'plasma-browser-integration', + 'preferredPlayer': "plasma-browser-integration", }, 'onScreenKeyboard': { - 'layout': 'qwerty_full', // See modules/onscreenkeyboard/onscreenkeyboard.js for available layouts + 'layout': "qwerty_full", // See modules/onscreenkeyboard/onscreenkeyboard.js for available layouts }, 'overview': { 'scale': 0.18, // Relative to screen size @@ -32,14 +32,21 @@ let userConfigOptions = { 'wsNumMarginScale': 0.07, }, 'sidebar': { - 'imageColumns': 3, + 'imageColumns': 2, }, 'search': { - 'engineBaseUrl': 'https://www.google.com/search?q=', - 'excludedSites': ['quora.com'], + 'engineBaseUrl': "https://www.google.com/search?q=", + 'excludedSites': ["quora.com"], + }, + 'time': { + // See https://docs.gtk.org/glib/method.DateTime.format.html + // Here's the 12h format: "%I:%M%P" + // For seconds, add "%S" and set interval to 1000 + 'format': "%H:%M", + 'interval': 5000, }, 'weather': { - 'city': '', + 'city': "", }, 'workspaces': { 'shown': 10, @@ -47,15 +54,15 @@ let userConfigOptions = { // Longer stuff 'icons': { substitutions: { - 'code-url-handler': 'visual-studio-code', - 'Code': 'visual-studio-code', - 'GitHub Desktop': 'github-desktop', - 'Minecraft* 1.20.1': 'minecraft', - 'gnome-tweaks': 'org.gnome.tweaks', - 'pavucontrol-qt': 'pavucontrol', - 'wps': 'wps-office2019-kprometheus', - 'wpsoffice': 'wps-office2019-kprometheus', - '': 'image-missing', + 'code-url-handler': "visual-studio-code", + 'Code': "visual-studio-code", + 'GitHub Desktop': "github-desktop", + 'Minecraft* 1.20.1': "minecraft", + 'gnome-tweaks': "org.gnome.tweaks", + 'pavucontrol-qt': "pavucontrol", + 'wps': "wps-office2019-kprometheus", + 'wpsoffice': "wps-office2019-kprometheus", + '': "image-missing", } }, 'keybinds': { @@ -63,19 +70,19 @@ let userConfigOptions = { // Modifiers: Shift Ctrl Alt Hyper Meta // See https://docs.gtk.org/gdk3/index.html#constants for the other keys (they are listed as KEY_key) 'overview': { - 'altMoveLeft': 'Ctrl+b', - 'altMoveRight': 'Ctrl+f', - 'deleteToEnd': 'Ctrl+k', + 'altMoveLeft': "Ctrl+b", + 'altMoveRight': "Ctrl+f", + 'deleteToEnd': "Ctrl+k", }, 'sidebar': { 'apis': { - 'nextTab': 'Page_Down', - 'prevTab': 'Page_Up', + 'nextTab': "Page_Down", + 'prevTab': "Page_Up", }, - 'pin': 'Ctrl+p', - 'cycleTab': 'Ctrl+Tab', - 'nextTab': 'Ctrl+Page_Down', - 'prevTab': 'Ctrl+Page_Up', + 'pin': "Ctrl+p", + 'cycleTab': "Ctrl+Tab", + 'nextTab': "Ctrl+Page_Down", + 'prevTab': "Ctrl+Page_Up", }, }, }