From 2c5beb4d7a77be6c5a0d08e1e29407b3f0dad995 Mon Sep 17 00:00:00 2001 From: JezerM Date: Mon, 12 Jul 2021 21:17:24 -0600 Subject: [PATCH] Added time and date --- themes/gruvbox/css/style.css | 13 +++++++++++++ themes/gruvbox/index.html | 7 ++++++- themes/gruvbox/js/debug.js | 22 +++++++++++++++------- themes/gruvbox/js/index.js | 12 +++++++----- themes/gruvbox/js/time-date.js | 26 ++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 themes/gruvbox/js/time-date.js diff --git a/themes/gruvbox/css/style.css b/themes/gruvbox/css/style.css index 4645812..002b6ca 100644 --- a/themes/gruvbox/css/style.css +++ b/themes/gruvbox/css/style.css @@ -253,6 +253,19 @@ input:focus, input:focus-visible { font-weight: bold; } +#time-date { + top: 0; + font-weight: bold; + font-size: calc(1em + 2px); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +#time-date span { + display: block; +} + .label-bar { position: absolute; display: flex; diff --git a/themes/gruvbox/index.html b/themes/gruvbox/index.html index d424eba..0d3ce3d 100644 --- a/themes/gruvbox/index.html +++ b/themes/gruvbox/index.html @@ -9,7 +9,7 @@ - Gruvbox greeter + Gruvbox theme
@@ -67,6 +67,10 @@
Lock
+
+ 20:00 + 12-07-21 +
@@ -92,6 +96,7 @@ + diff --git a/themes/gruvbox/js/debug.js b/themes/gruvbox/js/debug.js index c3a3a32..dad6616 100644 --- a/themes/gruvbox/js/debug.js +++ b/themes/gruvbox/js/debug.js @@ -7,15 +7,23 @@ class Debug { _init() { console.log("DEBUG") - window.theme_utils = {} - window.theme_utils.dirlist = function(path) { - return false + if (!window.theme_utils) { + window.theme_utils = {} + window.theme_utils.dirlist = function(path, mode, callback) { + callback([]) + } + window.theme_utils.bind_this = function(context) {return context} } - window.greeter_config = { - greeter: { - debug_mode: true, - } + if (!window.greeter_config) { + window.greeter_config = { + greeter: { + debug_mode: true, + }, + branding: { + background_images_dir: "", + } + } } if (!window.lightdm) { diff --git a/themes/gruvbox/js/index.js b/themes/gruvbox/js/index.js index 16caa04..99c56e9 100644 --- a/themes/gruvbox/js/index.js +++ b/themes/gruvbox/js/index.js @@ -34,6 +34,8 @@ async function initGreeter() { authenticate = new Authenticate() + time_date = new TimeDate() + power = new Power() battery = new Battery() @@ -48,9 +50,9 @@ async function initGreeter() { const notGreeter = false -if (notGreeter) { - debug = new Debug() - initGreeter() -} else { - window.addEventListener("GreeterReady", initGreeter) +if (window._ready_event === undefined) { + _ready_event = new Event("GreeterReady") + window.dispatchEvent(_ready_event) } + +window.addEventListener("GreeterReady", initGreeter) diff --git a/themes/gruvbox/js/time-date.js b/themes/gruvbox/js/time-date.js new file mode 100644 index 0000000..8e92208 --- /dev/null +++ b/themes/gruvbox/js/time-date.js @@ -0,0 +1,26 @@ +class TimeDate { + constructor() { + this._timeLabel = document.querySelector("#time-date #time-label") + this._dateLabel = document.querySelector("#time-date #date-label") + this._init() + } + + _updateTimeDate() { + let date = theme_utils.get_current_localized_date() + let time = theme_utils.get_current_localized_time() + + this._dateLabel.innerText = date + this._timeLabel.innerText = time + } + + _setTimer() { + this._updateTimeDate() + setInterval(() => { + this._updateTimeDate() + }, 1000) + } + + _init() { + this._setTimer() + } +}