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. # screensaver_timeout: Blank the screen after this many seconds of inactivity.
# secure_mode: Don't allow themes to make remote http requests. # secure_mode: Don't allow themes to make remote http requests.
# theme: Greeter theme to use. # theme: Greeter theme to use.
# icon_theme: Icon/cursor theme to use, located in /usr/share/icons/ # 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 "" to use system's language. # 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 # 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 screensaver_timeout: 300
secure_mode: True secure_mode: True
theme: gruvbox theme: gruvbox
icon_theme: Adwaita icon_theme:
time_language: "" time_language:
# #
# features: # features:

27
docs/Greeter.js vendored

@ -193,6 +193,7 @@ class Greeter {
* @type {Layout} * @type {Layout}
*/ */
get layout() {} get layout() {}
set layout(layout) {}
/** /**
* A list of keyboard layouts to present to the user. * A list of keyboard layouts to present to the user.
@ -345,7 +346,6 @@ class Greeter {
*/ */
suspend() {} suspend() {}
/** /**
* Gets emitted when the greeter has completed authentication. * Gets emitted when the greeter has completed authentication.
* @type {Signal} * @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. * JS-Cookie instance - Themes must manually load the included vendor script in order to use this object.
* @name Cookies * @name Cookies

26
docs/GreeterConfig.js vendored

@ -38,11 +38,11 @@ class GreeterConfig {
/** /**
* Holds keys/values from the `branding` section of the config file. * Holds keys/values from the `branding` section of the config file.
* *
* @type {object} * @type {Object}
* @property {string} background_images_dir Path to directory that contains background images * @property {String} background_images_dir Path to directory that contains background images
* for use in greeter themes. * for use in greeter themes.
* @property {string} logo Path to distro logo image 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} user_image Default user image/avatar. This is used by greeter themes
* for users that have not configured a `.face` image. * for users that have not configured a `.face` image.
* @readonly * @readonly
*/ */
@ -51,17 +51,15 @@ class GreeterConfig {
/** /**
* Holds keys/values from the `greeter` section of the config file. * Holds keys/values from the `greeter` section of the config file.
* *
* @type {object} * @type {Object}
* @property {boolean} debug_mode Greeter theme debug mode. * @property {Boolean} debug_mode Greeter theme debug mode.
* @property {boolean} detect_theme_errors Provide an option to load a fallback theme when theme * @property {Boolean} detect_theme_errors Provide an option to load a fallback theme when theme
* errors are detected. * errors are detected.
* @property {number} screensaver_timeout Blank the screen after this many seconds of inactivity. * @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 {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 * @property {String} theme The name of the theme to be used by the greeter.
* generate localized time for display. * @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} time_language Language to use when displaying the time or `auto` * @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.
* to use the system's language.
* @property {string} theme The name of the theme to be used by the greeter.
* @readonly * @readonly
*/ */
get greeter() {} get greeter() {}

83
docs/ThemeUtils.js vendored

@ -26,16 +26,14 @@
*/ */
let localized_invalid_date = null, let time_language = null,
time_language = null,
time_format = null,
_ThemeUtils = null; _ThemeUtils = null;
/** /**
* Provides various utility methods for use in greeter themes. The greeter will automatically * 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 * 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 * @memberOf LightDM
*/ */
@ -46,18 +44,15 @@ class ThemeUtils {
return _ThemeUtils; return _ThemeUtils;
} }
moment.locale( window.navigator.languages );
localized_invalid_date = moment('today', '!@#');
_ThemeUtils = instance; _ThemeUtils = instance;
} }
/** /**
* Binds `this` to class, `context`, for all of the class's methods. * 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 ) { bind_this( context ) {
let excluded_methods = ['constructor']; 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 within the greeter's shared data directory (`/var/lib/lightdm-data`).
* * Is located in `/tmp`. * * Is located in `/tmp`.
* *
* @param {String} path The abs path to desired directory. * @param {string} path The abs path to desired directory.
* @param {Boolean} only_images Include only images in the results. Default `true`. * @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 {function(string[])} callback Callback function to be called with the result.
*/ */
dirlist( path, only_images = true, callback ) { dirlist( path, only_images = true, callback ) {
if ( '' === path || 'string' !== typeof path ) { 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 * Get the current date in a localized format. Local language is autodetected by default, but can be set manually in the greeter config file.
* 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. * * `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() { get_current_localized_date() {
if ( null === time_language ) { let config = greeter_config.greeter
let config = greeter_config.greeter,
manual_language = ( '' !== config.time_language && 'auto' !== config.time_language ),
manual_time_format = ( '' !== config.time_format && 'auto' !== config.time_format );
time_language = manual_language ? config.time_language : window.navigator.language; var locale = []
time_format = manual_time_format ? config.time_format : 'LT';
if ( manual_language ) { if (time_language === null) {
moment.locale( time_language ); 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 ) { return date
local_time = moment().format( 'LT' );
} }
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 = [] var locale = []
if (time_language === null) { if (time_language === null) {
time_language = config.time_language time_language = config.time_language || ""
} }
if (time_language != "") { if (time_language != "") {
@ -928,7 +928,7 @@ class ThemeUtils {
var locale = [] var locale = []
if (time_language === null) { if (time_language === null) {
time_language = config.time_language time_language = config.time_language || ""
} }
if (time_language != "") { if (time_language != "") {

11
web-greeter/bridge/Greeter.py

@ -242,6 +242,17 @@ class Greeter(BridgeObject):
def layout(self): def layout(self):
return layout_to_dict(LightDM.get_layout()) 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) @bridge.prop(Variant, notify=noop_signal)
def layouts(self): def layouts(self):
return [layout_to_dict(layout) for layout in LightDM.get_layouts()] return [layout_to_dict(layout) for layout in LightDM.get_layouts()]

12
web-greeter/globals.py

@ -105,6 +105,15 @@ def resetScreenSaver():
else: else:
logger.debug("Screensaver reset") 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__)) BASE_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG_FILE = os.path.join(BASE_DIR, 'whither.yml') CONFIG_FILE = os.path.join(BASE_DIR, 'whither.yml')
@ -166,7 +175,8 @@ class WebGreeter(App):
self.config.greeter.update(greeter_config) self.config.greeter.update(greeter_config)
self.config.features.update(features_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.debug_mode = greeter_config['debug_mode']
self._config.allow_remote_urls = not greeter_config['secure_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 = [] var locale = []
if (time_language === null) { if (time_language === null) {
time_language = config.time_language time_language = config.time_language || ""
} }
if (time_language != "") { if (time_language != "") {
@ -157,7 +157,7 @@ class ThemeUtils {
var locale = [] var locale = []
if (time_language === null) { if (time_language === null) {
time_language = config.time_language time_language = config.time_language || ""
} }
if (time_language != "") { if (time_language != "") {

4
web-greeter/whither.yml

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

Loading…
Cancel
Save