Browse Source

Added API documentation

sisyphus
JezerM 4 years ago
parent
commit
a7f5c9f6c5
  1. 6
      README.md
  2. 19
      docs/Battery.md
  3. 222
      docs/Greeter.md
  4. 53
      docs/GreeterConfig.md
  5. 18
      docs/Language.md
  6. 18
      docs/Layout.md
  7. 23
      docs/Session.md
  8. 39
      docs/ThemeUtils.md
  9. 43
      docs/User.md

6
README.md

@ -26,7 +26,9 @@ sudo make install
```
## Theme Javascript API
[Antergos][Antergos] documentation is no longer available. Although, you can see the man-pages `man web-greeter` for some documentation and explanation. Also, you can explore the provided [themes](./themes) for real use cases.
[Antergos][Antergos] documentation is no longer available, although it is accesible through [Web Archive][WebArchive]. Actual documentation is available in [Gitbook][ApiDoc].
You can access the man-pages `man web-greeter` for some documentation and explanation. Also, you can explore the provided [themes][./themes] for real use cases.
## Enable features
### Brightness control
@ -57,3 +59,5 @@ web-greeter --debug
[antergos]: https://github.com/Antergos "Antergos"
[whither]: https://github.com/JezerM/whither "Whither"
[acpilight]: https://gitlab.com/wavexx/acpilight "acpilight"
[WebArchive]: https://web.archive.org/web/20190524032923/https://doclets.io/Antergos/web-greeter/stable "Web Archive"
[ApiDoc]: https://amyuki4.gitbook.io/web-greeter/ "API Documentation"

19
docs/Battery.md vendored

@ -0,0 +1,19 @@
Interface for object that holds info about battery. Battery object is not created by the theme's code, but rather by the **LightDM.Greeter** class.
# Members
## level
**Type**: [String]
The battery level.
## name
**Type**: [String]
The battery's name.
## state
**Type**: [String]
The state for the battery.

222
docs/Greeter.md vendored

@ -0,0 +1,222 @@
Base class for the greeter's Theme JavaScript API. Greeter themes will interact directly with an object derived from this class to facilitate the user log-in process. The greeter will automatically create an instance when it starts. The instance can be accessed using the global variable: `lightdm`
# Methods
## authenticate(username)
Starts the authentication with the given `username`.
**Arguments**:
- `username` [String]
## authenticate_as_guest()
Authenticates as the guest user.
## batteryUpdate()
Updates the battery data.
## brightnessSet(quantity)
Set the brightness to `quantity`.
## brightnessIncrease(quantity)
Increase the brightness by `quantity`
## brightnessDecrease(quantity)
Decrease the brightness by `quantity`
## cancel_authentication()
Cancel the user authentication that is currently in progress.
## cancel_autologin()
Cancels the automatic login.
## get_hint(name)
Get the value of a hint.
**Arguments**:
- `name` [String]
**Returns**:
- [String | Boolean | Number | Null]
## hibernate()
Triggers the system to hibernate.
**Returns**:
- [Boolean]
`true` if hibernation initiated, otherwise `false`
## layout(value)
Set the active layout for the selected user.
**Arguments**:
- `value` [LightDM.layout]
## respond(response)
Provide a response to a greeter
**Arguments**:
- `response` [String]
## restart()
Triggers the system to restart.
**Returns**:
- [Boolean]
`true` if restart initiated, otherwise `false`
## set_language(language)
Set the language for the currently authenticated user.
**Arguments**:
- language [String]
The language specification (e.g 'de\_DE.UTF-8')
**Returns**:
- Boolean
`true` if successful, otherwise `false`
## shutdown()
Triggers the system to shutdown.
**Returns**:
- Boolean
`true` if successful, otherwise `false`
## start_session(session)
Starts a session for the authenticated user.
**Arguments**:
- `session` [String | Null]
The session to log into or null to use the default
**Returns**:
- Boolean
`true` if successful, otherwise `false`
## suspend()
Triggers the system to suspend/sleep.
**Returns**
- [Boolean]
`true` if suspend/sleep initiated, otherwise `false`
# Members
## authentication_user
**Type**: [String | Null]
The username of the user being authenticated or null if there is no authentication in progress.
## autologin_guest
**Type**: [Boolean]
Whether or not the guest account should be automatically logged into when the timer expires.
## autologin_timeout
**Type**: [Number]
The number of seconds to wait before automatically loggin in.
## autologin_user
**Type**: [Boolean]
The username with which to automatically log in when the timer expires.
## can_hibernate
**Type**: [Boolean]
Whether or not the greeter can make the system hibernate.
## can_restart
**Type**: [Boolean]
Whether or not the greeter can make the system restart.
## can_shutdown
**Type**: [Boolean]
Whether or not the greeter can make the system shutdown.
## can_suspend
**Type**: [Boolean]
Whether or not the greeter can make the system suspend/sleep.
## default_session
**Type**: [String]
The name of the default session
## has_guest_account
**Type**: [Boolean]
Whether or not guest sessions are supported
## hide_users
**Type**: [Boolean]
Whether or not user accounts should be hidden
## hostname
**Type**: [String]
The system's hostname
## in_authentication
**Type**: [Boolean]
Whether or not the greeter is in the process of authenticating.
## is_authenticated
**Type**: [Boolean]
Whether or not the greeter has succesfully authenticated.
## language
**Type**: [LightDM.Language | Null]
The current language or `null` if no language.
## languages
**Type**: [Array<LightDM.Language>]
A list of languages to present to the user.
## layout
**Type**: [LightDM.Layout]
The currently active layout for the selected user.
## layouts
**Type**: [Array<LightDM.Layout>]
A list of keyboard layouts to present to the user.
## lock_hint
**Type**: [Boolean]
Whether or not the greeter was started as a lock screen.
## num_users
**Type**: [Number]
The number of users able to log in
## select_guest_hint
**Type**: [Boolean]
Whether or not the guest account should be selected by default
## select_user_hint
**Type**: [String]
The username to select by default.
## sessions
**Type**: [String]
List of available sessions.
## users
**Type**: [Array<LightDM.User>]
List of available users.

53
docs/GreeterConfig.md vendored

@ -0,0 +1,53 @@
Provides greeter themes with a way to access values from the greeter's config file located at **/etc/lightdm/web-greeter.yml**. The greeter will create an instance of this class when it starts. The instance can be accessed with the global variable: `greeter_config`
# Members
## branding
**Type**: [Object]
Holds keys&values from the **branding** section of the config file.
**Properties**:
- **background_images_dir**
Path to directory that contains background images for use in greeter themes.
- **logo_image**
Path to distro logo image for use in greeter themes
- **user_image**
Default user image/avatar.
## greeter
**Type**: [Object]
Holds keys/values from the **greeter** section of the config file.
**Properties**:
- **debug_mode**
Greeter theme debug mode.
- **detect_theme_errors**
Provide an option to load default theme when theme errors are detected.
- **screensaver_timeout**
Blank the screen after this seconds of inactivity.
- **secure_mode**
Don't allow themes to make http requests.
- **time_format**
A moment.js format string to be used by the greeter to generate localized time for display.
- **time_language**
Language to use when displaying the time, or **auto** to use the system's language.
- **theme**
The name of the theme to be used by the greeter.
## features
**Type**: [Object]
Holds keys/values from the **features** section of the config file.
**Properties**:
- **battery**
Enable greeter and themes to get battery status.
- **backlight**
- **enabled**
Enable greeter and themes to control display backlight.
- **value**
The amount to increase/decrease brightness by greeter.
- **steps**
How many steps are needed to do the change. **0** for instant change

18
docs/Language.md vendored

@ -0,0 +1,18 @@
Interface for object that holds info about a language on the system. Language objects are not created by the theme's code, but rather by the **LightDM.Greeter** class.
# Members
## code
**Type**: [String]
The code for the language.
## name
**Type**: [String]
The name for the layout.
## territory
**Type**: [String]
The territory for the language.

18
docs/Layout.md vendored

@ -0,0 +1,18 @@
Interface for object that holds info about a keyboard layout on the system. Language objects are not created by the theme's code, but rather by the **LightDM.Greeter** class.
# Members
## description
**Type**: [String]
The description for the layout.
## name
**Type**: [String]
The name for the layout.
## short_description
**Type**: [String]
The territory for the layout.

23
docs/Session.md vendored

@ -0,0 +1,23 @@
Interface for object that holds info about a session. Session objects are not created by the theme's code, but rather by the **LightDM.Greeter** class.
# Members
## comment
**Type**: [String]
The comment for the session.
## key
**Type**: [String]
The key for the session.
## name
**Type**: [String]
The name for the session.
## Type
**Type**: [String]
The type for the sesion.

39
docs/ThemeUtils.md vendored

@ -0,0 +1,39 @@
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`
# Methods
## bind_this(context)
Bind **this** to class, **context**, for all of the class's methods.
**Arguments**:
- `context` [Object]
An ES6 class instance with at least one method.
**Returns**:
- Object
**context** with **this** bound to it for all of its methods.
## dirlist(path)
Returns the contents of a directory found at **path**, only if the **path** meets at least one of the following conditions:
- Is located whithin the greeter theme's root directory.
- Has been explicitly allowed in the greeter's config file.
- Is located within the greeter's shared data directory (**/var/lib/lightdm-data/**)
- Is located in **/tmp**.
**Arguments**:
- `path` [String]
The abs path to desired directory.
**Returns**:
- Array<String>
List of abs paths for the files and directories found in **path**
## get_current_localized_time()
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.
- **language** defaults to the system's language, but can be set manually in the config gile.
- 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.
**Returns**:
- String
The current localized time.

43
docs/User.md vendored

@ -0,0 +1,43 @@
Interface for object that holds info about a user account on the system. User objects are not created by the theme's code, but rather by the **LightDM.Greeter** class.
# Members
## display_name
**Type**: [String]
The display name for the user.
## home_directory
**Type**: [String]
The home directory for the user.
## image
**Type**: [String]
The image for the user.
## language
**Type**: [String]
The language for the user.
## layout
**Type**: [String]
The keyboard layout for the user.
## logged_in
**Type**: [Boolean]
Whether or not the user is currently logged in.
## session
**Type**: [String]
The last session that the user logged into.
## username
**Type**: [String]
The username for the user.
Loading…
Cancel
Save