Browse Source

Changed a few config options, bugfixes, and docs updated

sisyphus
JezerM 3 years ago
parent
commit
da6e1013ee
No known key found for this signature in database
GPG Key ID: 66BBC5D01388C6B5
  1. 8
      dist/web-greeter.yml
  2. 27
      docs/Greeter.js
  3. 26
      docs/GreeterConfig.js
  4. 83
      docs/ThemeUtils.js
  5. 78
      docs/bootstrap.js
  6. 4
      themes/_vendor/js/mock.js
  7. 11
      web-greeter/bridge/Greeter.py
  8. 12
      web-greeter/globals.py
  9. 4
      web-greeter/resources/js/ThemeUtils.js
  10. 4
      web-greeter/whither.yml

8
dist/web-greeter.yml vendored

@ -18,8 +18,8 @@ branding:
# screensaver_timeout: Blank the screen after this many seconds of inactivity.
# secure_mode: Don't allow themes to make remote http requests.
# theme: Greeter theme to use.
# icon_theme: Icon/cursor theme to use, located in /usr/share/icons/
# time_language: Language to use when displaying the date or time, i.e. "en-us", "es-419", "ko", "ja". Set to "" to use system's language.
# icon_theme: Icon/cursor theme to use, located in /usr/share/icons/, i.e. "Adwaita". Set to None to use default icon theme.
# time_language: Language to use when displaying the date or time, i.e. "en-us", "es-419", "ko", "ja". Set to None to use system's language.
#
# NOTE: See IANA subtags registry for time_language options: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
#
@ -29,8 +29,8 @@ greeter:
screensaver_timeout: 300
secure_mode: True
theme: gruvbox
icon_theme: Adwaita
time_language: ""
icon_theme:
time_language:
#
# features:

27
docs/Greeter.js vendored

@ -193,6 +193,7 @@ class Greeter {
* @type {Layout}
*/
get layout() {}
set layout(layout) {}
/**
* A list of keyboard layouts to present to the user.
@ -345,7 +346,6 @@ class Greeter {
*/
suspend() {}
/**
* Gets emitted when the greeter has completed authentication.
* @type {Signal}
@ -391,31 +391,6 @@ class Greeter {
}
/**
* Moment.js instance - Loaded and instantiated automatically by the greeter.
* @name moment
* @type {object}
* @version 2.17.0
* @memberOf window
* @see [Moment.js Documentation](http://momentjs.com/docs)
*/
/**
* jQuery instance - Themes must manually load the included vendor script in order to use this object.
* @name jQuery
* @type {object}
* @version 3.1.1
* @memberOf window
* @see [jQuery Documentation](http://api.jquery.com)
*/
/**
* jQuery instance
* @name $
* @memberOf window
* @see {@link window.jQuery}
*/
/**
* JS-Cookie instance - Themes must manually load the included vendor script in order to use this object.
* @name Cookies

26
docs/GreeterConfig.js vendored

@ -38,11 +38,11 @@ class GreeterConfig {
/**
* Holds keys/values from the `branding` section of the config file.
*
* @type {object}
* @property {string} background_images_dir Path to directory that contains background images
* @type {Object}
* @property {String} background_images_dir Path to directory that contains background images
* for use in greeter themes.
* @property {string} logo Path to distro logo image for use in greeter themes.
* @property {string} user_image Default user image/avatar. This is used by greeter themes
* @property {String} logo Path to distro logo image for use in greeter themes.
* @property {String} user_image Default user image/avatar. This is used by greeter themes
* for users that have not configured a `.face` image.
* @readonly
*/
@ -51,17 +51,15 @@ class GreeterConfig {
/**
* Holds keys/values from the `greeter` section of the config file.
*
* @type {object}
* @property {boolean} debug_mode Greeter theme debug mode.
* @property {boolean} detect_theme_errors Provide an option to load a fallback theme when theme
* @type {Object}
* @property {Boolean} debug_mode Greeter theme debug mode.
* @property {Boolean} detect_theme_errors Provide an option to load a fallback theme when theme
* errors are detected.
* @property {number} screensaver_timeout Blank the screen after this many seconds of inactivity.
* @property {boolean} secure_mode Don't allow themes to make remote http requests.
* @property {string} time_format A moment.js format string to be used by the greeter to
* generate localized time for display.
* @property {string} time_language Language to use when displaying the time or `auto`
* to use the system's language.
* @property {string} theme The name of the theme to be used by the greeter.
* @property {Number} screensaver_timeout Blank the screen after this many seconds of inactivity.
* @property {Boolean} secure_mode Don't allow themes to make remote http requests.
* @property {String} theme The name of the theme to be used by the greeter.
* @property {String|Null} icon_theme Icon/cursor theme to use, located in /usr/share/icons, i.e "Adwaita". Set to Null to use default icon theme.
* @property {String|Null} time_language Language to use when displaying the date or time, i.e "en-us", "es-419", "ko", "ja". Set to Null to use system's language.
* @readonly
*/
get greeter() {}

83
docs/ThemeUtils.js vendored

@ -26,16 +26,14 @@
*/
let localized_invalid_date = null,
time_language = null,
time_format = null,
let time_language = null,
_ThemeUtils = null;
/**
* Provides various utility methods for use in greeter themes. The greeter will automatically
* create an instance of this class when it starts. The instance can be accessed
* with the global variable: `theme_utils`.
* with the global variable: [`theme_utils`](#dl-window-theme_utils).
*
* @memberOf LightDM
*/
@ -46,18 +44,15 @@ class ThemeUtils {
return _ThemeUtils;
}
moment.locale( window.navigator.languages );
localized_invalid_date = moment('today', '!@#');
_ThemeUtils = instance;
}
/**
* Binds `this` to class, `context`, for all of the class's methods.
*
* @param {Object} context An ES6 class instance with at least one method.
* @arg {object} context An ES6 class instance with at least one method.
*
* @return {Object} `context` with `this` bound to it for all of its methods.
* @return {object} `context` with `this` bound to it for all of its methods.
*/
bind_this( context ) {
let excluded_methods = ['constructor'];
@ -94,9 +89,9 @@ class ThemeUtils {
* * Is located within the greeter's shared data directory (`/var/lib/lightdm-data`).
* * Is located in `/tmp`.
*
* @param {String} path The abs path to desired directory.
* @param {Boolean} only_images Include only images in the results. Default `true`.
* @param {function(String[])} callback Callback function to be called with the result.
* @param {string} path The abs path to desired directory.
* @param {boolean} only_images Include only images in the results. Default `true`.
* @param {function(string[])} callback Callback function to be called with the result.
*/
dirlist( path, only_images = true, callback ) {
if ( '' === path || 'string' !== typeof path ) {
@ -122,36 +117,60 @@ class ThemeUtils {
}
/**
* Get the current time in a localized format. Time format and language are auto-detected
* by default, but can be set manually in the greeter config file.
* Get the current date in a localized format. Local language is autodetected by default, but can be set manually in the greeter config file.
* * `language` defaults to the system's language, but can be set manually in the config file.
* * When `time_format` config file option has a valid value, time will be formatted
* according to that value.
* * When `time_format` does not have a valid value, the time format will be `LT`
* which is `1:00 PM` or `13:00` depending on the system's locale.
*
* @return {String} The current localized time.
* @returns {Object} The current date.
*/
get_current_localized_time() {
if ( null === time_language ) {
let config = greeter_config.greeter,
manual_language = ( '' !== config.time_language && 'auto' !== config.time_language ),
manual_time_format = ( '' !== config.time_format && 'auto' !== config.time_format );
get_current_localized_date() {
let config = greeter_config.greeter
time_language = manual_language ? config.time_language : window.navigator.language;
time_format = manual_time_format ? config.time_format : 'LT';
var locale = []
if ( manual_language ) {
moment.locale( time_language );
if (time_language === null) {
time_language = config.time_language || ""
}
if (time_language != "") {
locale.push(time_language)
}
let local_time = moment().format( time_format );
let optionsDate = { day: "2-digit", month: "2-digit", year: "2-digit" }
let fmtDate = Intl.DateTimeFormat(locale, optionsDate)
let now = new Date()
var date = fmtDate.format(now)
if ( local_time === localized_invalid_date ) {
local_time = moment().format( 'LT' );
return date
}
return local_time;
/**
* Get the current time in a localized format. Local language is autodetected by default, but can be set manually in the greeter config file.
* * `language` defaults to the system's language, but can be set manually in the config file.
*
* @returns {Object} The current time.
*/
get_current_localized_time() {
let config = greeter_config.greeter
var locale = []
if (time_language === null) {
time_language = config.time_language || ""
}
if (time_language != "") {
locale.push(time_language)
}
let optionsTime = { hour: "2-digit", minute: "2-digit" }
let fmtTime = Intl.DateTimeFormat(locale, optionsTime)
let now = new Date()
var time = fmtTime.format(now)
return time
}
}

78
docs/bootstrap.js vendored

@ -0,0 +1,78 @@
/*
* bootstrap.js
*
* Copyright © 2017 Antergos Developers <dev@antergos.com>
*
* This file is part of Web Greeter.
*
* Web Greeter is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Web Greeter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* The following additional terms are in effect as per Section 7 of the license:
*
* The preservation of all legal notices and author attributions in
* the material or in the Appropriate Legal Notices displayed
* by works containing it is required.
*
* You should have received a copy of the GNU General Public License
* along with web-greeter; If not, see <http://www.gnu.org/licenses/>.
*/
(() => {
let _channel;
/**
* Greeter Ready Event. Themes should not initialize until this event has fired.
* @event window#GreeterReady
* @name GreeterReady
* @type Event
* @memberOf window
*/
window._ready_event = new Event( 'GreeterReady' );
function channel_ready_cb( channel ) {
_channel = channel;
/**
* Greeter Instance
* @name lightdm
* @type {LightDM.Greeter}
* @memberOf window
*/
window.lightdm = _channel.objects.LightDMGreeter;
/**
* Greeter Config - Access values from the greeter's config file.
* @name greeter_config
* @type {LightDM.GreeterConfig}
* @memberOf window
*/
window.greeter_config = _channel.objects.Config;
/**
* Theme Utils - various utility methods for use in greeter themes.
* @name theme_utils
* @type {LightDM.ThemeUtils}
* @memberOf window
*/
window.theme_utils = new ThemeUtils( _channel.objects.ThemeUtils );
setTimeout( function () {
window.dispatchEvent( _ready_event );
}, 2 );
}
document.addEventListener( 'DOMContentLoaded', ( event ) => {
new QWebChannel( qt.webChannelTransport, channel_ready_cb );
});
})();

4
themes/_vendor/js/mock.js vendored

@ -899,7 +899,7 @@ class ThemeUtils {
var locale = []
if (time_language === null) {
time_language = config.time_language
time_language = config.time_language || ""
}
if (time_language != "") {
@ -928,7 +928,7 @@ class ThemeUtils {
var locale = []
if (time_language === null) {
time_language = config.time_language
time_language = config.time_language || ""
}
if (time_language != "") {

11
web-greeter/bridge/Greeter.py

@ -242,6 +242,17 @@ class Greeter(BridgeObject):
def layout(self):
return layout_to_dict(LightDM.get_layout())
@layout.setter
def layout(self, layout):
if type(layout) != dict:
return False
lay = dict(
name = layout.get("name") or "",
description = layout.get("description") or "",
short_description = layout.get("short_description") or ""
)
return LightDM.set_layout(LightDM.Layout(**lay))
@bridge.prop(Variant, notify=noop_signal)
def layouts(self):
return [layout_to_dict(layout) for layout in LightDM.get_layouts()]

12
web-greeter/globals.py

@ -105,6 +105,15 @@ def resetScreenSaver():
else:
logger.debug("Screensaver reset")
def getDefaultCursor():
cursor_theme = ""
try:
child = subprocess.Popen(["cat", "/usr/share/icons/default/index.theme"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
awk = subprocess.run(["awk", "-F=", "/Inherits/ {print $2}"], stdout=subprocess.PIPE, stdin=child.stdout, text=True)
cursor_theme = awk.stdout.replace("\n", "")
except Exception as err:
logger.error("Default cursor couldn't be get")
return cursor_theme
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG_FILE = os.path.join(BASE_DIR, 'whither.yml')
@ -166,7 +175,8 @@ class WebGreeter(App):
self.config.greeter.update(greeter_config)
self.config.features.update(features_config)
os.environ["XCURSOR_THEME"] = greeter_config["icon_theme"]
cursor_theme = greeter_config["icon_theme"]
os.environ["XCURSOR_THEME"] = cursor_theme if cursor_theme != None else getDefaultCursor()
self._config.debug_mode = greeter_config['debug_mode']
self._config.allow_remote_urls = not greeter_config['secure_mode']

4
web-greeter/resources/js/ThemeUtils.js

@ -128,7 +128,7 @@ class ThemeUtils {
var locale = []
if (time_language === null) {
time_language = config.time_language
time_language = config.time_language || ""
}
if (time_language != "") {
@ -157,7 +157,7 @@ class ThemeUtils {
var locale = []
if (time_language === null) {
time_language = config.time_language
time_language = config.time_language || ""
}
if (time_language != "") {

4
web-greeter/whither.yml

@ -38,8 +38,8 @@ WebGreeter:
screensaver_timeout: 300
secure_mode: True
theme: gruvbox
icon_theme: Adwaita
time_language: ""
icon_theme:
time_language:
features:
battery: False
backlight:

Loading…
Cancel
Save