From df67d344b23a270a262366f5d17a582e5f5ed800 Mon Sep 17 00:00:00 2001 From: JezerM Date: Sat, 7 Aug 2021 16:03:22 -0600 Subject: [PATCH] Added guest account support to Gruvbox theme --- themes/gruvbox/js/accounts.js | 11 +++++++++++ themes/gruvbox/js/authenticate.js | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/themes/gruvbox/js/accounts.js b/themes/gruvbox/js/accounts.js index ef307ac..15698fc 100644 --- a/themes/gruvbox/js/accounts.js +++ b/themes/gruvbox/js/accounts.js @@ -35,6 +35,17 @@ class Accounts { this._setAccountDefault() } + _setGuestAccount() { + if (lightdm.has_guest_account) { + this._guestAccount = `guest-account-${Math.floor(Math.random() * 1000)}` + this._usersObject.push({ + username: this._guestAccount, + display_name: "Guest", + image: "" + }) + } + } + _setAccountList() { var dropdown = this._accountsList.querySelector(".dropdown") dropdown.innerHTML = "" diff --git a/themes/gruvbox/js/authenticate.js b/themes/gruvbox/js/authenticate.js index 1353e41..e8445c7 100644 --- a/themes/gruvbox/js/authenticate.js +++ b/themes/gruvbox/js/authenticate.js @@ -28,19 +28,25 @@ class Authenticate { _respond() { var input = document.querySelector("#input-password") + let username = accounts.getDefaultUserName() input.blur() input.disabled = true - lightdm.respond(this._password) + if (username == accounts._guestAccount && lightdm.has_guest_account) { + lightdm.authenticate_as_guest() + } else { + lightdm.respond(this._password) + } } startAuthentication() { lightdm.cancel_authentication() + let username = accounts.getDefaultUserName() + if (username == accounts._guestAccount && lightdm.has_guest_account) return lightdm.authenticate(String(accounts.getDefaultUserName())) } async _authentication_done() { var form = document.querySelector("#login-form") - var input = document.querySelector("#input-password") form.classList.add("success") await wait(500)