Dustin Falgout
8 years ago
22 changed files with 134 additions and 3570 deletions
@ -1,25 +1,21 @@ |
|||||||
# Top-most EditorConfig file |
# Top-most EditorConfig file |
||||||
root = true |
root = true |
||||||
|
|
||||||
# Unix-style newlines with a newline ending every file |
|
||||||
[*] |
[*] |
||||||
end_of_line = lf |
charset = utf-8 |
||||||
insert_final_newline = true |
|
||||||
trim_trailing_whitespace = true |
|
||||||
|
|
||||||
# Indent With Tabs |
|
||||||
indent_style = tab |
|
||||||
indent_size = tab |
|
||||||
tab_width = 4 |
|
||||||
|
|
||||||
# UTF-8 |
|
||||||
charset = utf-8 |
|
||||||
|
|
||||||
|
|
||||||
max_line_length = 99 |
|
||||||
continuation_indent_size = 4 |
continuation_indent_size = 4 |
||||||
indent_brace_style = 1TBS |
curly_bracket_next_line = false |
||||||
curly_bracket_next_line = false |
end_of_line = lf |
||||||
|
indent_brace_style = 1TBS |
||||||
|
indent_size = 4 |
||||||
|
indent_style = tab |
||||||
|
insert_final_newline = true |
||||||
|
max_line_length = 99 |
||||||
|
tab_width = 4 |
||||||
|
trim_trailing_whitespace = true |
||||||
|
|
||||||
[*.py] |
[*.py] |
||||||
indent_style = space |
indent_style = space |
||||||
|
|
||||||
|
[*.yml] |
||||||
|
indent_style = space |
||||||
|
@ -1,71 +1,140 @@ |
|||||||
#!/bin/bash |
#!/bin/bash |
||||||
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
BUILD_DIR="$(realpath $(dirname "${BASH_SOURCE[0]}"))" |
||||||
|
REPO_DIR="$(dirname "${BUILD_DIR}")" |
||||||
|
INSTALL_ROOT="${BUILD_DIR}/install_root" |
||||||
|
PKGNAME='web-greeter' |
||||||
|
DESTDIR='' |
||||||
|
|
||||||
|
|
||||||
|
_handle_error() { |
||||||
|
LASTLINE="$1" |
||||||
|
LASTERR="$2" |
||||||
|
echo "${BASH_SOURCE[0]}: line ${LASTLINE}: exit status of last command: ${LASTERR}" |
||||||
|
exit 1 |
||||||
|
} |
||||||
|
|
||||||
clean_build_dir() { |
clean_build_dir() { |
||||||
(cd "${DIR}" \ |
find "${BUILD_DIR}" -type f ! -path '*/ci/*' ! -name utils.sh -delete |
||||||
&& find . -type f ! -path './ci*' ! -name '.gitignore' ! -name utils.sh -delete \ |
find "${BUILD_DIR}" -type d ! -name build ! -path '*/ci' -delete |
||||||
&& find . -type d ! -path './ci' -delete \ |
|
||||||
&& { rm ../src/gresource/js/bundle.js || true; }) |
|
||||||
} |
} |
||||||
|
|
||||||
combine_javascript_sources() { |
combine_javascript_sources() { |
||||||
cd "${MESON_SOURCE_ROOT}/src/gresource/js" && { |
cd "${BUILD_DIR}/${PKGNAME}/resources/js" |
||||||
cat _vendor/moment-with-locales.min.js \ |
cat _vendor/moment-with-locales.min.js \ |
||||||
LightDMObjects.js \ |
ThemeUtils.js \ |
||||||
Greeter.js \ |
bootstrap.js > bundle.js |
||||||
GreeterConfig.js \ |
|
||||||
ThemeUtils.js > "${MESON_SOURCE_ROOT}/src/gresource/js/bundle.js" |
|
||||||
} |
|
||||||
} |
} |
||||||
|
|
||||||
do_build() { |
do_build() { |
||||||
(cd "$(dirname "${DIR}")" \ |
cd "${BUILD_DIR}" |
||||||
&& meson build \ |
|
||||||
&& cd build \ |
# Compile Resources |
||||||
&& ninja) |
(combine_javascript_sources \ |
||||||
|
&& pyrcc5 -o ../../resources.py ../resources.qrc) |
||||||
|
|
||||||
|
# Create "Zip Application" |
||||||
|
(cd "${PKGNAME}" \ |
||||||
|
&& mv greeter.py __main__.py \ |
||||||
|
&& zip -rq ../"${PKGNAME}.zip" . -x '**__pycache__**' 'resources/*' \ |
||||||
|
&& cd - >/dev/null \ |
||||||
|
&& mkdir -p "${INSTALL_ROOT}"/usr/{bin,share} \ |
||||||
|
&& echo '#!/bin/python' >> "${INSTALL_ROOT}/usr/bin/web-greeter" \ |
||||||
|
&& cat web-greeter.zip >> "${INSTALL_ROOT}/usr/bin/web-greeter" \ |
||||||
|
&& chmod +x "${INSTALL_ROOT}/usr/bin/web-greeter") |
||||||
|
} |
||||||
|
|
||||||
|
do_install() { |
||||||
|
cd "${BUILD_DIR}" |
||||||
|
mkdir -p \ |
||||||
|
"${INSTALL_ROOT}"/usr/share/{man/man1,metainfo,web-greeter,xgreeters} \ |
||||||
|
"${INSTALL_ROOT}/etc/lightdm" |
||||||
|
|
||||||
|
# Themes |
||||||
|
(cp -R "${REPO_DIR}/themes" "${INSTALL_ROOT}/usr/share/web-greeter" \ |
||||||
|
&& cd "${INSTALL_ROOT}/usr/share/web-greeter" \ |
||||||
|
&& mv themes/_vendor .) |
||||||
|
|
||||||
|
# Man Page |
||||||
|
cp "${REPO_DIR}/dist/${PKGNAME}.1" "${INSTALL_ROOT}/usr/share/man/man1" |
||||||
|
|
||||||
|
# Greeter Config |
||||||
|
cp "${REPO_DIR}/dist/${PKGNAME}.conf" "${INSTALL_ROOT}/etc/lightdm" |
||||||
|
|
||||||
|
# AppData File |
||||||
|
cp "${REPO_DIR}/dist/com.antergos.${PKGNAME}.appdata.xml" "${INSTALL_ROOT}/usr/share/metainfo" |
||||||
|
|
||||||
|
# Desktop File |
||||||
|
cp "${REPO_DIR}/dist/com.antergos.${PKGNAME}.desktop" "${INSTALL_ROOT}/usr/share/xgreeters" |
||||||
|
|
||||||
|
# Do Install! |
||||||
|
[[ -e "${DESTDIR}" ]] || mkdir -p "${DESTDIR}" |
||||||
|
cp -R "${INSTALL_ROOT}"/* "${DESTDIR}" |
||||||
|
|
||||||
|
# Fix Permissions |
||||||
|
chown -R "${SUDO_UID}:${SUDO_GID}" "${BUILD_DIR}" |
||||||
} |
} |
||||||
|
|
||||||
do_quick_install() { |
do_success() { |
||||||
(cd "${DIR}/src" \ |
NO_COLOR=\x1b[0m |
||||||
&& sudo cp lightdm-webkit2-greeter /usr/bin \ |
SUCCESS_COLOR=\x1b[32;01m |
||||||
&& sudo cp liblightdm-webkit2-greeter-webext.so /usr/lib/lightdm-webkit2-greeter \ |
SUCCESS="${SUCCESS_COLOR}[SUCCESS!]${NO_COLOR}" |
||||||
&& sudo cp -R ../../themes/antergos /usr/share/lightdm-webkit/themes) |
echo "${SUCCESS}" |
||||||
} |
} |
||||||
|
|
||||||
generate_pot_file() { |
generate_pot_file() { |
||||||
REPO_ROOT="$(dirname "${DIR}")" |
REPO_ROOT="$(dirname "${REPO_DIR}")" |
||||||
xgettext --from-code UTF-8 -o "${REPO_ROOT}/po/lightdm-webkit2-greeter.pot" -d lightdm-webkit2-greeter "${REPO_ROOT}"/src/*.c |
xgettext --from-code UTF-8 -o "${REPO_ROOT}/po/lightdm-webkit2-greeter.pot" -d lightdm-webkit2-greeter "${REPO_ROOT}"/src/*.c |
||||||
} |
} |
||||||
|
|
||||||
list_javascript_sources() { |
init_build_dir() { |
||||||
cd "${MESON_SOURCE_ROOT}/src" && find gresource/js -type f -name '*.js' -print |
[[ -e "${BUILD_DIR}/web-greeter" ]] && return 0 |
||||||
|
cp -R "${REPO_DIR}/web-greeter" "${BUILD_DIR}" |
||||||
} |
} |
||||||
|
|
||||||
|
set_config() { |
||||||
|
( [[ -z "$1" ]] || [[ -z "$2" && -z "$3" ]] ) && return 1 |
||||||
|
local KEY VALUE |
||||||
|
|
||||||
|
KEY="$1" |
||||||
|
[[ '' != "$2" ]] && VALUE="$2" || VALUE="$3" |
||||||
|
|
||||||
|
sed -i "s|@${KEY}@|@${VALUE}@|g" "${BUILD_DIR}/web-greeter/whither.yml" |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
# Catch Command Errors |
||||||
|
trap '_handle_error ${LINENO} ${$?}' ERR |
||||||
|
|
||||||
|
cd "${REPO_DIR}/build" >/dev/null |
||||||
|
|
||||||
case "$1" in |
case "$1" in |
||||||
combine-js) |
combine-js) |
||||||
combine_javascript_sources |
combine_javascript_sources |
||||||
;; |
;; |
||||||
|
|
||||||
get-js-files) |
clean) |
||||||
list_javascript_sources |
|
||||||
;; |
|
||||||
|
|
||||||
clean-build-dir) |
|
||||||
clean_build_dir |
clean_build_dir |
||||||
;; |
;; |
||||||
|
|
||||||
build) |
build) |
||||||
clean_build_dir && do_build |
do_build |
||||||
;; |
;; |
||||||
|
|
||||||
build-dev) |
build-init) |
||||||
clean_build_dir && do_build && do_quick_install |
init_build_dir |
||||||
;; |
;; |
||||||
|
|
||||||
gen-pot) |
gen-pot) |
||||||
generate_pot_file |
generate_pot_file |
||||||
;; |
;; |
||||||
|
|
||||||
|
install) |
||||||
|
DESTDIR="$2" |
||||||
|
do_install |
||||||
|
;; |
||||||
|
|
||||||
|
set-config) |
||||||
|
set_config "$2" "$3" "$4" |
||||||
|
;; |
||||||
esac |
esac |
||||||
|
@ -1,104 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<!-- Copyright 2017 Dustin Falgout <dustin@antergos.com> --> |
|
||||||
<component type="desktop"> |
|
||||||
<id>com.antergos.webkit2-greeter</id> |
|
||||||
<metadata_license>CC0-1.0</metadata_license> |
|
||||||
<project_license>GPL-3.0+</project_license> |
|
||||||
<name>LightDM WebKit2 Greeter</name> |
|
||||||
<summary>A greeter for LightDM</summary> |
|
||||||
<description> |
|
||||||
<p> |
|
||||||
LightDM WebKit2 Greeter supports themes built with HTML/JavaScript. |
|
||||||
</p> |
|
||||||
<p> |
|
||||||
LightDM WebKit2 Greeter themes provide modern, visually appealing, and feature-rich |
|
||||||
login screens. It includes two themes by default. There is also a growing number of |
|
||||||
3rd-Party themes available online. |
|
||||||
</p> |
|
||||||
</description> |
|
||||||
<screenshots> |
|
||||||
<screenshot height="412" width="800" type="default"> |
|
||||||
<image>https://github.com/Antergos/lightdm-webkit2-greeter/raw/master/themes/antergos/img/screenshot1.jpg</image> |
|
||||||
<caption>Login screen (default theme)</caption> |
|
||||||
</screenshot> |
|
||||||
<screenshot height="412" width="800"> |
|
||||||
<image>https://github.com/Antergos/lightdm-webkit2-greeter/raw/master/themes/antergos/img/screenshot2.jpg</image> |
|
||||||
<caption>Login screen background switcher (default theme)</caption> |
|
||||||
</screenshot> |
|
||||||
<screenshot height="412" width="800"> |
|
||||||
<image>https://github.com/Antergos/lightdm-webkit2-greeter/raw/master/themes/antergos/img/screenshot3.jpg</image> |
|
||||||
<caption>Login screen user selection (default theme)</caption> |
|
||||||
</screenshot> |
|
||||||
</screenshots> |
|
||||||
|
|
||||||
<!-- |
|
||||||
Validate with `appstream-util validate *.appdata.xml` |
|
||||||
--> |
|
||||||
|
|
||||||
<releases> |
|
||||||
<release date="2016-12-26" version="2.2.1"> |
|
||||||
<description> |
|
||||||
<p>This is a maintenance release in the 2.2 series, with the following improvements:</p> |
|
||||||
<ul> |
|
||||||
<li>Increased the timeout for the "theme loaded" check to ensure themes are given enough time to load (when running on less powerful systems). (GH #98)</li> |
|
||||||
<li>Fixed issue where users' custom .face image failed to load. (GH #98)</li> |
|
||||||
</ul> |
|
||||||
</description> |
|
||||||
</release> |
|
||||||
<release date="2016-12-18" version="2.2"> |
|
||||||
<description> |
|
||||||
<p>This is a milestone release with the following improvements:</p> |
|
||||||
<ul> |
|
||||||
<li>The JavaScript API for themes is now fully documented: https://goo.gl/0iPzA4</li> |
|
||||||
<li>New Theme Error Recovery System that will alert the user when errors are detected during JavaScript execution and give them the option to to load a fallback theme.</li> |
|
||||||
<li>New config option: secure_mode (enabled by default). When enabled, only local http requests are allowed in themes. All non-local requests will be blocked.</li> |
|
||||||
<li>It is now possible to override the language and format used by the greeter when displaying the current time. See the greeter config file for details.</li> |
|
||||||
<li>A new utility method for getting the current localized time is available to themes.</li> |
|
||||||
<li>Simple theme now has a fade out exit animation.</li> |
|
||||||
</ul> |
|
||||||
<ul> |
|
||||||
<li>Switched build systems from Autotools to Meson.</li> |
|
||||||
<li>Updated API usage for LightDM 1.19.2+.</li> |
|
||||||
<li>Updated bundled JS & CSS vendor libs to their latest versions.</li> |
|
||||||
<li>Updated translations with latest changes contributed by the Antergos Community on Transifex.</li> |
|
||||||
<li>Default theme: |
|
||||||
<ul> |
|
||||||
<li>Buttons and user list-box items received some minor style enhancements.</li> |
|
||||||
<li>Theme is now compatible with the latest jQuery.</li> |
|
||||||
</ul> |
|
||||||
</li> |
|
||||||
<li>Simple theme: |
|
||||||
<ul> |
|
||||||
<li>Removed deprecated HTML4 tags.</li> |
|
||||||
<li>Improved styles for the input field.</li> |
|
||||||
</ul> |
|
||||||
</li> |
|
||||||
</ul> |
|
||||||
<ul> |
|
||||||
<li>The ugly default X cursor will no longer be shown after the greeter exits.</li> |
|
||||||
<li>Default theme: |
|
||||||
<ul> |
|
||||||
<li>The error messages container will now appear correctly (size and position).</li> |
|
||||||
<li>It is now once again possible to skip straight to password entry by pressing either the spacebar or the enter key.</li> |
|
||||||
</ul> |
|
||||||
</li> |
|
||||||
</ul> |
|
||||||
</description> |
|
||||||
</release> |
|
||||||
</releases> |
|
||||||
<kudos> |
|
||||||
<kudo>ModernToolkit</kudo> |
|
||||||
</kudos> |
|
||||||
<url type="bugtracker">https://github.com/Antergos/lightdm-webkit2-greeter/issues</url> |
|
||||||
<url type="donation">https://antergos.com/donate</url> |
|
||||||
<url type="help"/> |
|
||||||
<url type="homepage">https://github.com/Antergos/lightdm-webkit2-greeter</url> |
|
||||||
<url type="translate">https://www.transifex.com/faidoc/antergos/lightdm-webkit2-greeter</url> |
|
||||||
<suggests> |
|
||||||
<id>apps.light-locker</id> |
|
||||||
</suggests> |
|
||||||
<update_contact>dustin_at_antergos.com</update_contact> |
|
||||||
<translation type="gettext">lightdm-webkit2-greeter</translation> |
|
||||||
<developer_name>The Antergos Project</developer_name> |
|
||||||
</component> |
|
||||||
|
|
@ -1,6 +0,0 @@ |
|||||||
[Desktop Entry] |
|
||||||
Name=LightDM WebKit2 Greeter |
|
||||||
Comment=LightDM Greeter |
|
||||||
Exec=lightdm-webkit2-greeter |
|
||||||
Type=Application |
|
||||||
X-Ubuntu-Gettext-Domain=lightdm-webkit2-greeter |
|
@ -1,19 +0,0 @@ |
|||||||
id = 'com.antergos.webkit2-greeter' |
|
||||||
appdata_file = '@0@.appdata.xml'.format(id) |
|
||||||
desktop_file = '@0@.desktop'.format(id) |
|
||||||
|
|
||||||
|
|
||||||
install_data( |
|
||||||
desktop_file, |
|
||||||
install_dir: get_option('with-desktop-dir') |
|
||||||
) |
|
||||||
|
|
||||||
install_data( |
|
||||||
'webkit2-greeter.conf', |
|
||||||
install_dir: get_option('with-config-dir') |
|
||||||
) |
|
||||||
|
|
||||||
install_data( |
|
||||||
appdata_file, |
|
||||||
install_dir: join_paths(get_option('datadir'), 'metainfo', appdata_file) |
|
||||||
) |
|
@ -1,35 +0,0 @@ |
|||||||
# |
|
||||||
# [greeter] |
|
||||||
# debug_mode = Greeter theme debug mode. |
|
||||||
# detect_theme_errors = Provide an option to load a fallback theme when theme errors are detected. |
|
||||||
# screensaver_timeout = Blank the screen after this many seconds of inactivity. |
|
||||||
# secure_mode = Don't allow themes to make remote http requests. |
|
||||||
# time_format = A moment.js format string so the greeter can generate localized time for display. |
|
||||||
# time_language = Language to use when displaying the time or "auto" to use the system's language. |
|
||||||
# webkit_theme = Webkit theme to use. |
|
||||||
# |
|
||||||
# NOTE: See moment.js documentation for format string options: http://momentjs.com/docs/#/displaying/format/ |
|
||||||
# |
|
||||||
|
|
||||||
[greeter] |
|
||||||
debug_mode = false |
|
||||||
detect_theme_errors = true |
|
||||||
screensaver_timeout = 300 |
|
||||||
secure_mode = true |
|
||||||
time_format = LT |
|
||||||
time_language = auto |
|
||||||
webkit_theme = antergos |
|
||||||
|
|
||||||
# |
|
||||||
# [branding] |
|
||||||
# background_images = Path to directory that contains background images for use by themes. |
|
||||||
# logo = Path to logo image for use by greeter themes. |
|
||||||
# user_image = Default user image/avatar. This is used by themes for users that have no .face image. |
|
||||||
# |
|
||||||
# NOTE: Paths must be accessible to the lightdm system user account (so they cannot be anywhere in /home) |
|
||||||
# |
|
||||||
|
|
||||||
[branding] |
|
||||||
background_images = /usr/share/backgrounds |
|
||||||
logo = /usr/share/lightdm-webkit/themes/antergos/img/antergos.png |
|
||||||
user_image = /usr/share/lightdm-webkit/themes/antergos/img/antergos-logo-user.png |
|
@ -1,308 +0,0 @@ |
|||||||
.TH "lightdm-webkit2-greeter" "1" "2016.01.10" |
|
||||||
.nh |
|
||||||
.ad l |
|
||||||
.SH "NAME" |
|
||||||
lightdm-webkit2-greeter |
|
||||||
.SH "SYNOPSIS" |
|
||||||
.PP |
|
||||||
LightDM greeter that uses webkit2 for theming via HTML/JavaScript\&. |
|
||||||
.PP |
|
||||||
.SH "DESCRIPTION" |
|
||||||
.PP |
|
||||||
lightdm-webkit2-greeter is a LightDM greeter that uses webkit2 for theming\&. Themes can be written |
|
||||||
using a combination of HTML and Javascript\&. |
|
||||||
.PP |
|
||||||
.SH "THEME JAVASCRIPT API" |
|
||||||
Please note that all properties and functions which are marked as "deprecated" are |
|
||||||
only available for backwards compatibility and will be removed in a future version of |
|
||||||
lightdm-webkit2-greeter\&. Theme authors should not use any deprecated properties or |
|
||||||
functions in new works and should update any existing works which make use of |
|
||||||
deprecated properties and/or functions to ensure continued proper functionality\&. |
|
||||||
.PP |
|
||||||
The following functions \fBmust\fR be provided by the greeter theme and callable on the global "window" object\&. |
|
||||||
.PP |
|
||||||
\fBshow_prompt(text, type)\fR |
|
||||||
.RS 4 |
|
||||||
This will be called when LightDM needs to prompt the user for some reason, such |
|
||||||
as asking for a password\&. The "text" parameter will be the text of the |
|
||||||
prompt, and the "type" parameter will either be "text" for a visible prompt, or |
|
||||||
"password" for a prompt that the input should be hidden\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBshow_message(text, type)\fR |
|
||||||
.RS 4 |
|
||||||
This will be called when LightDM needs to display some info for the user\&. |
|
||||||
The "text" parameter will be the text of the |
|
||||||
message, and the "type" parameter will either be "info" for an information |
|
||||||
message, or "error" for an error message that LightDM has encountered\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBauthentication_complete()\fR |
|
||||||
.RS 4 |
|
||||||
This function is called by LightDM when authentication has completed\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBautologin_timer_expired()\fR |
|
||||||
.RS 4 |
|
||||||
This function is called by LightDM when an autologin user's login timer has |
|
||||||
expired\&. The greeter should reset the authentication process\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
The following functions are available for the greeter to call to execute |
|
||||||
actions within LightDM\&. |
|
||||||
.PP |
|
||||||
\fBlightdm\&.authenticate(username)\fR |
|
||||||
.RS 4 |
|
||||||
Specifies the username of the user we'd like to start authenticating as\&. Note that |
|
||||||
if you call lightdm.authenticate with no argument, LightDM (via PAM) will issue |
|
||||||
a show_prompt() call to ask for the username\&. The older function |
|
||||||
lightdm\&.start_authentication() has been deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.authenticate_as_guest()\fR |
|
||||||
.RS 4 |
|
||||||
Authenticates as the guest user\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.cancel_authentication()\fR |
|
||||||
.RS 4 |
|
||||||
Cancels the authentication of any user currently in the process of |
|
||||||
authenticating\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.cancel_autologin()\fR |
|
||||||
.RS 4 |
|
||||||
Cancels the authentication of the autologin user\&. The older function |
|
||||||
lightdm\&.cancel_timed_login() has been deprecated. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.get_hint(hint_name)\fR |
|
||||||
.RS 4 |
|
||||||
Returns the value of a named hint provided by LightDM\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.suspend()\fR |
|
||||||
.RS 4 |
|
||||||
Suspends the system, if the greeter has the authority to do so\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.hibernate()\fR |
|
||||||
.RS 4 |
|
||||||
Hibernates the system, if the greeter has the authority to do so\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.start_session_sync(session)\fR |
|
||||||
.RS 4 |
|
||||||
Once LightDM has successfully authenticated the user, start the user's session |
|
||||||
by calling this function\&. "session" is the authenticated user's session\&. |
|
||||||
If no session is passed, start the authenticated user with the system default |
|
||||||
session. The older function lightdm\&.login(user, session) has been |
|
||||||
deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.respond(text)\fR |
|
||||||
.RS 4 |
|
||||||
When LightDM has prompted for input, provide the response to LightDM\&. |
|
||||||
The deprecated function was "provide_secret"\&. This is still available for |
|
||||||
backwards compatibility, but authors of greeters should move to using |
|
||||||
lightdm.respond()\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.restart()\fR |
|
||||||
.RS 4 |
|
||||||
Restarts the system, if the greeter has the authority to do so\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.set_language(lang)\fR |
|
||||||
.RS 4 |
|
||||||
Will set the language for the current LightDM session\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.shutdown()\fR |
|
||||||
.RS 4 |
|
||||||
Shuts down the system, if the greeter has the authority to do so\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
Variables available within the greeter are: |
|
||||||
.PP |
|
||||||
\fBlightdm\&.authentication_user\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The username of the authentication user being authenticated or null if no |
|
||||||
authentication is in progress\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.autologin_guest\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Indicates the guest user should be used for autologin\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.autologin_timeout\fR |
|
||||||
.RS 4 |
|
||||||
Number\&. The number of seconds to wait before automatically logging in\&. The |
|
||||||
older variable lightdm\&.timed_user_delay has been deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.autologin_user\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The name of the user account that should be logged into |
|
||||||
automatically after timed login delay has passed\&. The older variable |
|
||||||
lightdm\&.timed_login_user has been deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.can_hibernate\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Whether or not the system can be made to hibernate by the greeter\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.can_restart\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Whether or not the system can be restarted by the greeter\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.can_shutdown\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Whether or not the system can be shutdown by the greeter\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.can_suspend\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Whether or not the system can be suspended by the greeter\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.default_session\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The name of the default session (as configured in lightdm.conf)\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.has_guest_account\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. A guest account is available for login\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.hide_users\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. The whole list of users should not be displayed\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.hostname\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The hostname of the system\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.is_authenticated\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Indicates if the user has successfully authenticated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.in_authentication\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. Indicates if lightdm is currently in the authentication phase\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.language\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The currently selected language\&. The older variable name |
|
||||||
lightdm\&.default_language is deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.layout\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The name of the currently active keyboard layout\&. To change the |
|
||||||
layout, assign a valid layout name to this variable\&. The older variable name |
|
||||||
lightdm\&.default_layout is deprecated\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.layouts\fR |
|
||||||
.RS 4 |
|
||||||
Array\&. The keyboard layouts that are available on the system\&. Returns an Array |
|
||||||
of LightDMLayout objects\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.num_users\fR |
|
||||||
.RS 4 |
|
||||||
Number\&. The number of users able to log in\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.select_guest\fR |
|
||||||
.RS 4 |
|
||||||
Boolean\&. The guest user should be selected by default for login\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.select_user\fR |
|
||||||
.RS 4 |
|
||||||
String\&. The username that should be selected by default for login\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.sessions\fR |
|
||||||
.RS 4 |
|
||||||
Array\&. The sessions that are available on the system\&. Returns an Array of |
|
||||||
LightDMSession objects\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
\fBlightdm\&.users\fR |
|
||||||
.RS 4 |
|
||||||
Array\&. The users that are able to log in\&. Returns an Array of LightDMUser |
|
||||||
objects\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
The following calls can be made to read configuration keys out of the |
|
||||||
lightdm-webkit2-greeter configuration file\&. |
|
||||||
.PP |
|
||||||
config\&.get_str(section, key)\fR |
|
||||||
.RS 4 |
|
||||||
Returns the string value associated with key under the "section" in the configuration file\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
config\&.get_num(section, key)\fR |
|
||||||
.RS 4 |
|
||||||
Returns the numeric value associated with key under the "section" in the configuration file\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
config\&.get_bool(section, key)\fR |
|
||||||
.RS 4 |
|
||||||
Returns the boolean value associated with key under the "section" in the configuration file\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
The greeterutil object has some utility functions associated with it which |
|
||||||
are intended to make a theme author's work easier\&. |
|
||||||
.PP |
|
||||||
greeterutil\&.dirlist(path)\fR |
|
||||||
.RS 4 |
|
||||||
Returns an array of strings of filenames present at "path", or Null if the |
|
||||||
path does not exist\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
greeterutil\&.txt2html(txt)\fR |
|
||||||
.RS 4 |
|
||||||
Returns a simple HTML conversion of the passed text\&. Newlines are replaced |
|
||||||
with <br>, and the characters \&&, <, >, and " are replaced with their HTML |
|
||||||
equivalents\&. |
|
||||||
.RE |
|
||||||
.PP |
|
||||||
Please see the LightDM API documentation for the complete list of calls |
|
||||||
available\&. The lightdm-webkit2-greeter implements all of the LightDM API\&. |
|
||||||
.PP |
|
||||||
.SH "CONFIGURATION" |
|
||||||
.PP |
|
||||||
\fB/etc/lightdm/lightdm-webkit2-greeter\&.conf\fR |
|
||||||
.RS 4 |
|
||||||
Keyfile that contains one key: webkit-theme\&. This should point to which |
|
||||||
theme the greeter should use\&. |
|
||||||
.RE |
|
||||||
.SH "FILES" |
|
||||||
.PP |
|
||||||
\fB/usr/share/lightdm-webkit/themes\fR |
|
||||||
.RS 4 |
|
||||||
Directory where themes should be stored\&. |
|
||||||
.RE |
|
||||||
.SH "EXAMPLES" |
|
||||||
.PP |
|
||||||
Please see the "antergos" and "simple" themes that are shipped with lightdm-webkit2-greeter\&. |
|
||||||
.SH "SEE ALSO" |
|
||||||
.PP |
|
||||||
http://people\&.ubuntu\&.com/~robert-ancell/lightdm/reference/core\&.html |
|
||||||
.SH "AUTHOR" |
|
||||||
.PP |
|
||||||
The legacy lightdm-webkit-greeter was written by Robert Ancell <robert\&.ancell\&@canonical\&.com\&>\&. |
|
||||||
It was ported to webkit2 by the Antergos Developers <dev@antergos\&.com>\&. Also includes code improvements |
|
||||||
contributed by Scott Balneaves <sbalneav@ltsp\&.org>\&. |
|
@ -1,105 +0,0 @@ |
|||||||
project('web-greeter', 'python', version: '3.0.0alpha1', license: 'GPL-3') |
|
||||||
|
|
||||||
# ================================== # |
|
||||||
# ------->>> Version Vars <<<------- # |
|
||||||
# ================================== # |
|
||||||
|
|
||||||
version = meson.project_version() |
|
||||||
version_parts = as_version.split('.') |
|
||||||
|
|
||||||
major_version = version_parts[0] |
|
||||||
minor_version = version_parts[1] |
|
||||||
micro_version = version_parts[2] |
|
||||||
|
|
||||||
|
|
||||||
# ======================================= # |
|
||||||
# ------->>> Dependency Checks <<<------- # |
|
||||||
# ======================================= # |
|
||||||
|
|
||||||
python_dep = join(meson.build_root(), 'python_dep.py') |
|
||||||
|
|
||||||
dbus_glib = dependency('dbus-glib-1') |
|
||||||
lightdm_gobject = dependency('liblightdm-gobject-1') |
|
||||||
x11 = dependency('x11') |
|
||||||
web_engine = dependency('qt5', modules: ['WebEngine', 'WebEngineWidgets', 'WebChannel']) |
|
||||||
|
|
||||||
|
|
||||||
pyqt5_check = run_command(python_dep, 'PyQt5') |
|
||||||
|
|
||||||
if pyqt5_check.return_code() == 0: |
|
||||||
pyqt5 = declare_dependency(version: pyqt5_check.stdout().strip()) |
|
||||||
else |
|
||||||
pyqt5 = declare_dependency(version: '0.0.1') |
|
||||||
endif |
|
||||||
|
|
||||||
|
|
||||||
yaml_check = run_command(python_dep, 'ruamel.yaml') |
|
||||||
|
|
||||||
if yaml_check.return_code() == 0: |
|
||||||
yaml = declare_dependency(version: yaml_check.stdout().strip()) |
|
||||||
else |
|
||||||
yaml = declare_dependency(version: '0.0.1') |
|
||||||
endif |
|
||||||
|
|
||||||
|
|
||||||
python_dependencies = [ |
|
||||||
['pyqt5', pyqt5], |
|
||||||
['ruamel.yaml', yaml] |
|
||||||
] |
|
||||||
|
|
||||||
foreach dep: python_dependencies |
|
||||||
if not dep.get(1).version().version_compare(>0.0.1): |
|
||||||
error('Missing Dependency: @0@'.format(dep.get(0))) |
|
||||||
endif |
|
||||||
endforeach |
|
||||||
|
|
||||||
|
|
||||||
greeter_deps = [dbus_glib, lightdm_gobject, web_engine, x11] |
|
||||||
has_lightdm_1_19_2 = lightdm_gobject.version().version_compare('>=1.19.2') |
|
||||||
|
|
||||||
|
|
||||||
# =================================== # |
|
||||||
# ------->>> Configuration <<<------- # |
|
||||||
# =================================== # |
|
||||||
|
|
||||||
conf = configuration_data() |
|
||||||
config_file = 'whither.yaml' |
|
||||||
logo_image = get_option('with-logo-image', join_paths(get_option('with-themes-dir'), 'antergos/img/antergos.png')) |
|
||||||
user_image = get_option('with-user-image', join_paths(get_option('with-themes-dir'), 'antergos/img/antergos-logo-user.png')) |
|
||||||
|
|
||||||
conf.set('full_version', version) |
|
||||||
conf.set('major_version', major_version) |
|
||||||
conf.set('minor_version', minor_version) |
|
||||||
conf.set('micro_version', micro_version) |
|
||||||
|
|
||||||
conf.set('locale_dir', get_option('with-locale-dir')) |
|
||||||
|
|
||||||
conf.set('themes_dir', get_option('with-themes-dir')) |
|
||||||
|
|
||||||
conf.set('config_dir', get_option('with-config-dir')) |
|
||||||
|
|
||||||
conf.set('greeters_dir', get_option('with-greeters-dir')) |
|
||||||
|
|
||||||
conf.set('background_images_dir', get_option('with-background-images-dir')) |
|
||||||
|
|
||||||
conf.set('logo_image', logo_image) |
|
||||||
|
|
||||||
conf.set('user_image', user_image) |
|
||||||
|
|
||||||
if has_lightdm_1_19_2 |
|
||||||
conf.set('has_lightdm_1_19_2', 'True') |
|
||||||
else |
|
||||||
conf.set('has_lightdm_1_19_2', 'False') |
|
||||||
endif |
|
||||||
|
|
||||||
|
|
||||||
# ===================================== # |
|
||||||
# ------->>> Sub Directories <<<------- # |
|
||||||
# ===================================== # |
|
||||||
|
|
||||||
subdirs = ['web-greeter', 'man', 'themes', 'dist', 'po'] |
|
||||||
|
|
||||||
foreach s : subdirs |
|
||||||
subdir(s) |
|
||||||
endforeach |
|
||||||
|
|
@ -1,24 +0,0 @@ |
|||||||
option('with-themes-dir', |
|
||||||
type: 'string', |
|
||||||
value: '/usr/share/lightdm-webkit/themes', |
|
||||||
description: 'Directory to use for greeter themes') |
|
||||||
|
|
||||||
option('with-config-dir', |
|
||||||
type: 'string', |
|
||||||
value: '/etc/lightdm', |
|
||||||
description: 'LightDM configuration directory') |
|
||||||
|
|
||||||
option('with-desktop-dir', |
|
||||||
type: 'string', |
|
||||||
value: '/usr/share/xgreeters', |
|
||||||
description: 'LightDM greeters directory') |
|
||||||
|
|
||||||
option('with-webext-dir', |
|
||||||
type: 'string', |
|
||||||
value: '/usr/lib/lightdm-webkit2-greeter', |
|
||||||
description: 'Directory for the greeter webkit extension') |
|
||||||
|
|
||||||
option('with-locale-dir', |
|
||||||
type: 'string', |
|
||||||
value: '/usr/share/locale', |
|
||||||
description: 'Locale directory') |
|
@ -1,29 +0,0 @@ |
|||||||
i18n = import('i18n') |
|
||||||
|
|
||||||
i18n.gettext( |
|
||||||
meson.project_name(), |
|
||||||
args: [ |
|
||||||
'--default-domain=' + meson.project_name(), |
|
||||||
'--from-code=UTF-8', |
|
||||||
'--add-comments', |
|
||||||
|
|
||||||
'--keyword=_', |
|
||||||
'--keyword=N_', |
|
||||||
'--keyword=C_:1c,2', |
|
||||||
'--keyword=NC_:1c,2', |
|
||||||
'--keyword=g_dcgettext:2', |
|
||||||
'--keyword=g_dngettext:2,3', |
|
||||||
'--keyword=g_dpgettext2:2c,3', |
|
||||||
|
|
||||||
'--flag=N_:1:pass-c-format', |
|
||||||
'--flag=C_:2:pass-c-format', |
|
||||||
'--flag=NC_:2:pass-c-format', |
|
||||||
'--flag=g_dngettext:2:pass-c-format', |
|
||||||
'--flag=g_strdup_printf:1:c-format', |
|
||||||
'--flag=g_string_printf:2:c-format', |
|
||||||
'--flag=g_string_append_printf:2:c-format', |
|
||||||
'--flag=g_error_new:3:c-format', |
|
||||||
'--flag=g_set_error:4:c-format', |
|
||||||
]) |
|
||||||
|
|
||||||
|
|
@ -1,255 +0,0 @@ |
|||||||
/*
|
|
||||||
* greeter-config.c |
|
||||||
* |
|
||||||
* Copyright © 2017 Antergos Developers <dev@antergos.com> |
|
||||||
* |
|
||||||
* This file is part of lightdm-webkit2-greeter. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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 lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
|
|
||||||
#include <string.h> |
|
||||||
#include <gtk/gtk.h> |
|
||||||
|
|
||||||
#include "greeter-config.h" |
|
||||||
#include "config.h" |
|
||||||
#include "greeter-resources.h" |
|
||||||
|
|
||||||
/* Work-around CLion bug */ |
|
||||||
#ifndef CONFIG_DIR |
|
||||||
#include "../build/src/config.h" |
|
||||||
#include "../build/src/greeter-resources.h" |
|
||||||
#endif |
|
||||||
|
|
||||||
static Config config_instance; |
|
||||||
static Config *config_instance_p = NULL; |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
apply_defaults(void) { |
|
||||||
config_instance.greeter->debug_mode = FALSE; |
|
||||||
config_instance.greeter->detect_theme_errors = TRUE; |
|
||||||
config_instance.greeter->secure_mode = TRUE; |
|
||||||
config_instance.greeter->screensaver_timeout = 300; |
|
||||||
config_instance.greeter->time_format = "LT"; |
|
||||||
config_instance.greeter->time_language = "auto"; |
|
||||||
config_instance.greeter->webkit_theme = "antergos"; |
|
||||||
|
|
||||||
config_instance.branding->background_images = BACKGROUND_IMAGES_DIR; |
|
||||||
config_instance.branding->logo = LOGO_IMAGE; |
|
||||||
config_instance.branding->user_image = USER_IMAGE; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static gchar * |
|
||||||
rtrim_comments(gchar *str) { |
|
||||||
gchar *ptr = NULL; |
|
||||||
|
|
||||||
ptr = strchr(str, '#'); |
|
||||||
|
|
||||||
if (NULL != ptr) { |
|
||||||
*ptr = '\0'; |
|
||||||
} |
|
||||||
|
|
||||||
return g_strstrip(str); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
Config* |
|
||||||
get_config(void) { |
|
||||||
if (NULL != config_instance_p) { |
|
||||||
return config_instance_p; |
|
||||||
} |
|
||||||
|
|
||||||
// Apply default config.
|
|
||||||
apply_defaults(); |
|
||||||
|
|
||||||
GError *err = NULL; |
|
||||||
GKeyFile *keyfile = g_key_file_new(); |
|
||||||
|
|
||||||
g_key_file_load_from_file(keyfile, CONFIG_FILE, G_KEY_FILE_NONE, &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
g_key_file_load_from_file(keyfile, CONFIG_FILE_LEGACY, G_KEY_FILE_NONE, &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
// Can't load config file. Bail.
|
|
||||||
goto cleanup; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> WebKit Theme <<<----- */ |
|
||||||
gchar *theme = g_key_file_get_string(keyfile, "greeter", "webkit_theme", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
theme = g_key_file_get_string(keyfile, "greeter", "webkit-theme", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->webkit_theme = rtrim_comments(theme); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Screensaver Timeout <<<----- */ |
|
||||||
gint screensaver_timeout = g_key_file_get_integer(keyfile, "greeter", "screensaver_timeout", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
screensaver_timeout = g_key_file_get_integer(keyfile, "greeter", "screensaver-timeout", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->screensaver_timeout = screensaver_timeout; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Debug Mode <<<----- */ |
|
||||||
gboolean debug_mode = g_key_file_get_boolean(keyfile, "greeter", "debug_mode", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
debug_mode = g_key_file_get_integer(keyfile, "greeter", "debug-mode", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->debug_mode = debug_mode; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Secure Mode <<<----- */ |
|
||||||
gboolean secure_mode = g_key_file_get_boolean(keyfile, "greeter", "secure_mode", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
secure_mode = g_key_file_get_integer(keyfile, "greeter", "secure-mode", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->secure_mode = secure_mode; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Theme Error Detection <<<----- */ |
|
||||||
gboolean detect_theme_errors = g_key_file_get_boolean(keyfile, "greeter", "detect_theme_errors", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
detect_theme_errors = g_key_file_get_integer(keyfile, "greeter", "detect-theme-errors", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->detect_theme_errors = detect_theme_errors; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Time Format <<<----- */ |
|
||||||
gchar *time_format = g_key_file_get_string(keyfile, "greeter", "time_format", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
time_format = g_key_file_get_string(keyfile, "greeter", "time-format", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->time_format = time_format; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Time Language <<<----- */ |
|
||||||
gchar *time_language = g_key_file_get_string(keyfile, "greeter", "time_language", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
time_language = g_key_file_get_string(keyfile, "greeter", "time-language", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.greeter->time_language = time_language; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Background Images Directory <<<----- */ |
|
||||||
gchar *background_images = g_key_file_get_string(keyfile, "branding", "background_images", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
background_images = g_key_file_get_string(keyfile, "branding", "background-images", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.branding->background_images = background_images; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> User Avatar Image <<<----- */ |
|
||||||
gchar *user_image = g_key_file_get_string(keyfile, "branding", "user_image", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
user_image = g_key_file_get_string(keyfile, "branding", "user-image", &err); |
|
||||||
} |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.branding->user_image = user_image; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* ----->>> Logo <<<----- */ |
|
||||||
gchar *logo = g_key_file_get_string(keyfile, "branding", "logo", &err); |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_clear_error(&err); |
|
||||||
} else { |
|
||||||
config_instance.branding->logo = logo; |
|
||||||
} |
|
||||||
|
|
||||||
goto cleanup; |
|
||||||
|
|
||||||
|
|
||||||
cleanup: |
|
||||||
config_instance_p = &config_instance; |
|
||||||
|
|
||||||
if (NULL != err) { |
|
||||||
g_error_free(err); |
|
||||||
} |
|
||||||
|
|
||||||
return config_instance_p; |
|
||||||
} |
|
@ -1,58 +0,0 @@ |
|||||||
/*
|
|
||||||
* greeter-config.h |
|
||||||
* |
|
||||||
* Copyright © 2017 Antergos Developers <dev@antergos.com> |
|
||||||
* |
|
||||||
* This file is part of lightdm-webkit2-greeter. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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 lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef LIGHTDM_WEBKIT2_GREETER_GREETER_CONFIG_H |
|
||||||
#define LIGHTDM_WEBKIT2_GREETER_GREETER_CONFIG_H |
|
||||||
|
|
||||||
#include <glib.h> |
|
||||||
|
|
||||||
typedef struct greeter_config { |
|
||||||
gboolean debug_mode; |
|
||||||
gboolean detect_theme_errors; |
|
||||||
gint screensaver_timeout; |
|
||||||
gboolean secure_mode; |
|
||||||
gchar *time_format; |
|
||||||
gchar *time_language; |
|
||||||
gchar *webkit_theme; |
|
||||||
} Greeter_Config; |
|
||||||
|
|
||||||
typedef struct branding_config { |
|
||||||
gchar *background_images; |
|
||||||
gchar *logo; |
|
||||||
gchar *user_image; |
|
||||||
} Branding_Config; |
|
||||||
|
|
||||||
typedef struct config { |
|
||||||
Greeter_Config *greeter; |
|
||||||
Branding_Config *branding; |
|
||||||
} Config; |
|
||||||
|
|
||||||
|
|
||||||
Config* get_config(void); |
|
||||||
|
|
||||||
|
|
||||||
#endif // LIGHTDM_WEBKIT2_GREETER_GREETER_CONFIG_H
|
|
@ -1,434 +0,0 @@ |
|||||||
/*
|
|
||||||
* greeter.c |
|
||||||
* |
|
||||||
* Copyright © 2014-2017 Antergos Developers <dev@antergos.com> |
|
||||||
* |
|
||||||
* Includes Code Contributed By: |
|
||||||
* Copyright © 2016 Scott Balneaves <sbalneav@ltsp.org> |
|
||||||
* |
|
||||||
* Based on code from lightdm-webkit-greeter: |
|
||||||
* Copyright © 2010-2015 Robert Ancell <robert.ancell@canonical.com> |
|
||||||
* |
|
||||||
* This file is part of lightdm-webkit2-greeter. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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. |
|
||||||
* |
|
||||||
* lightdm-webkit2-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 lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
#include <glib.h> |
|
||||||
#include <gtk/gtk.h> |
|
||||||
#include <gdk/gdkx.h> |
|
||||||
#include <glib/gprintf.h> |
|
||||||
#include <glib-unix.h> |
|
||||||
#include <webkit2/webkit2.h> |
|
||||||
#include <JavaScriptCore/JavaScript.h> |
|
||||||
#include <glib/gi18n.h> |
|
||||||
#include <sys/mman.h> |
|
||||||
|
|
||||||
#include "config.h" |
|
||||||
#include "greeter-resources.h" |
|
||||||
#include "greeter-config.h" |
|
||||||
|
|
||||||
|
|
||||||
static GtkWidget *web_view; |
|
||||||
static GtkWidget *window; |
|
||||||
static WebKitSettings *webkit_settings; |
|
||||||
static GdkDisplay *default_display; |
|
||||||
static GResource *greeter_resources; |
|
||||||
static WebKitUserContentManager *manager; |
|
||||||
|
|
||||||
/* Screensaver values */ |
|
||||||
static int |
|
||||||
timeout, |
|
||||||
interval, |
|
||||||
prefer_blanking, |
|
||||||
allow_exposures; |
|
||||||
|
|
||||||
static Config *conf; |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
initialize_web_extensions_cb(WebKitWebContext *context, gpointer user_data) { |
|
||||||
webkit_web_context_set_web_extensions_directory(context, WEBEXT_DIR); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
create_new_webkit_settings_object(void) { |
|
||||||
webkit_settings = webkit_settings_new_with_settings( |
|
||||||
"enable-developer-extras", TRUE, |
|
||||||
"javascript-can-open-windows-automatically", TRUE, |
|
||||||
"allow-file-access-from-file-urls", TRUE, |
|
||||||
"enable-write-console-messages-to-stdout", TRUE, |
|
||||||
#ifdef HAS_WEBKITGTK_2_14 |
|
||||||
"allow-universal-access-from-file-urls", TRUE, |
|
||||||
#endif |
|
||||||
NULL |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static gboolean |
|
||||||
context_menu_cb(WebKitWebView *view, |
|
||||||
WebKitContextMenu *context_menu, |
|
||||||
GdkEvent *event, |
|
||||||
WebKitHitTestResult *hit_test_result, |
|
||||||
gpointer user_data) { |
|
||||||
/* Returning true without creating a custom context menu results in no context
|
|
||||||
* menu being shown. Thus, we are returning the opposite of debug_mode to get |
|
||||||
* desired result (which is only show menu when debug_mode is enabled. |
|
||||||
*/ |
|
||||||
return (! conf->greeter->debug_mode); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes the greeter behave a bit more like a screensaver if it was launched as |
|
||||||
* a lock-screen by blanking the screen. |
|
||||||
*/ |
|
||||||
static void |
|
||||||
lock_hint_enabled_handler(void) { |
|
||||||
Display *display = gdk_x11_display_get_xdisplay(default_display); |
|
||||||
|
|
||||||
XGetScreenSaver(display, &timeout, &interval, &prefer_blanking, &allow_exposures); |
|
||||||
XForceScreenSaver(display, ScreenSaverActive); |
|
||||||
XSetScreenSaver(display, conf->greeter->screensaver_timeout, 0, PreferBlanking, DefaultExposures); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
show_theme_recovery_modal() { |
|
||||||
GtkWidget |
|
||||||
*dialog, |
|
||||||
*label, |
|
||||||
*content_area, |
|
||||||
*button, |
|
||||||
*button_box; |
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons( |
|
||||||
_("Greeter Theme Error Detected"), |
|
||||||
GTK_WINDOW(window), |
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, |
|
||||||
_("Load _Default Theme"), |
|
||||||
GTK_RESPONSE_ACCEPT, |
|
||||||
_("Load _Fallback Theme"), |
|
||||||
GTK_RESPONSE_OK, |
|
||||||
_("_Cancel"), |
|
||||||
GTK_RESPONSE_REJECT, |
|
||||||
NULL |
|
||||||
); |
|
||||||
|
|
||||||
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
|
||||||
button = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_REJECT); |
|
||||||
button_box = gtk_widget_get_parent(button); |
|
||||||
label = gtk_label_new( |
|
||||||
_("An error was detected in the current theme that could interfere with the system login process.") |
|
||||||
); |
|
||||||
|
|
||||||
gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_EXPAND); |
|
||||||
gtk_container_add(GTK_CONTAINER(content_area), label); |
|
||||||
gtk_widget_show_all(content_area); |
|
||||||
|
|
||||||
gint response = gtk_dialog_run(GTK_DIALOG(dialog)); |
|
||||||
|
|
||||||
if (GTK_RESPONSE_REJECT == response) { |
|
||||||
gtk_widget_destroy(dialog); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
gchar *log_msg = "[ERROR] :: A problem was detected with the current theme. Falling back to default theme..."; |
|
||||||
gchar *fallback_theme; |
|
||||||
|
|
||||||
if (GTK_RESPONSE_ACCEPT == response) { |
|
||||||
fallback_theme = "antergos"; |
|
||||||
|
|
||||||
} else { |
|
||||||
fallback_theme = "simple"; |
|
||||||
} |
|
||||||
|
|
||||||
g_warning("%s", log_msg); |
|
||||||
gtk_widget_destroy(dialog); |
|
||||||
|
|
||||||
webkit_web_view_load_uri( |
|
||||||
WEBKIT_WEB_VIEW(web_view), |
|
||||||
g_strdup_printf("file://%s/%s/index.html", THEME_DIR, fallback_theme) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
theme_function_exists_cb(GObject *object, |
|
||||||
GAsyncResult *result, |
|
||||||
gpointer user_data) { |
|
||||||
|
|
||||||
WebKitJavascriptResult *js_result; |
|
||||||
GError *error = NULL; |
|
||||||
JSValueRef value; |
|
||||||
JSGlobalContextRef context; |
|
||||||
gboolean result_as_bool; |
|
||||||
|
|
||||||
js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error); |
|
||||||
|
|
||||||
if (NULL != error) { |
|
||||||
g_warning ("Error running javascript: %s", error->message); |
|
||||||
g_error_free(error); |
|
||||||
return; |
|
||||||
|
|
||||||
} else { |
|
||||||
context = webkit_javascript_result_get_global_context(js_result); |
|
||||||
value = webkit_javascript_result_get_value(js_result); |
|
||||||
|
|
||||||
result_as_bool = JSValueToBoolean(context, value); |
|
||||||
} |
|
||||||
|
|
||||||
if (FALSE == result_as_bool) { |
|
||||||
show_theme_recovery_modal(); |
|
||||||
} |
|
||||||
|
|
||||||
webkit_javascript_result_unref(js_result); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
gboolean |
|
||||||
maybe_show_theme_fallback_dialog(void) { |
|
||||||
/* Check for existence of a function that themes must add to window object */ |
|
||||||
webkit_web_view_run_javascript( |
|
||||||
WEBKIT_WEB_VIEW(web_view), |
|
||||||
"(() => 'authentication_complete' in window)()", |
|
||||||
NULL, |
|
||||||
(GAsyncReadyCallback) theme_function_exists_cb, |
|
||||||
NULL |
|
||||||
); |
|
||||||
|
|
||||||
return FALSE; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Message received callback. |
|
||||||
* |
|
||||||
* Receives messages from our web extension process and calls appropriate handlers. |
|
||||||
* |
|
||||||
* @param manager The user content manager instance that was created in #main. |
|
||||||
* @param message The message sent from web extension process. |
|
||||||
* @param user_data Data that is private to the current user. |
|
||||||
*/ |
|
||||||
static void |
|
||||||
message_received_cb(WebKitUserContentManager *manager, |
|
||||||
WebKitJavascriptResult *message, |
|
||||||
gpointer user_data) { |
|
||||||
|
|
||||||
gchar *message_str; |
|
||||||
JSGlobalContextRef context; |
|
||||||
JSValueRef message_val; |
|
||||||
JSStringRef js_str_val; |
|
||||||
gsize message_str_length; |
|
||||||
|
|
||||||
context = webkit_javascript_result_get_global_context(message); |
|
||||||
message_val = webkit_javascript_result_get_value(message); |
|
||||||
|
|
||||||
if (JSValueIsString(context, message_val)) { |
|
||||||
js_str_val = JSValueToStringCopy(context, message_val, NULL); |
|
||||||
message_str_length = JSStringGetMaximumUTF8CStringSize(js_str_val); |
|
||||||
message_str = (gchar *)g_malloc (message_str_length); |
|
||||||
JSStringGetUTF8CString(js_str_val, message_str, message_str_length); |
|
||||||
JSStringRelease(js_str_val); |
|
||||||
|
|
||||||
} else { |
|
||||||
message_str = ""; |
|
||||||
printf("Error running javascript: unexpected return value"); |
|
||||||
} |
|
||||||
|
|
||||||
if (0 == g_strcmp0(message_str, "PageLoaded")) { |
|
||||||
/* Register callback to check if theme loaded successfully */ |
|
||||||
g_timeout_add_seconds(8, (GSourceFunc) maybe_show_theme_fallback_dialog, NULL); |
|
||||||
|
|
||||||
} else if (0 == g_strcmp0(message_str, "JavaScriptException")) { |
|
||||||
show_theme_recovery_modal(); |
|
||||||
|
|
||||||
} else if (0 == g_strcmp0(message_str, "LockHint")) { |
|
||||||
lock_hint_enabled_handler(); |
|
||||||
|
|
||||||
} else { |
|
||||||
printf("UI PROCESS - message_received_cb(): no match for: %s", message_str); |
|
||||||
} |
|
||||||
|
|
||||||
g_free(message_str); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
quit_cb(void) { |
|
||||||
gtk_widget_destroy(window); |
|
||||||
gtk_main_quit(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
static void |
|
||||||
javascript_bundle_injection_setup() { |
|
||||||
WebKitUserScript *bundle; |
|
||||||
GBytes *data; |
|
||||||
guint8 *data_as_guint; |
|
||||||
gsize data_size; |
|
||||||
gchar *script; |
|
||||||
|
|
||||||
data = g_resource_lookup_data( |
|
||||||
greeter_resources, |
|
||||||
GRESOURCE_PATH "/js/bundle.js", |
|
||||||
G_RESOURCE_LOOKUP_FLAGS_NONE, |
|
||||||
NULL |
|
||||||
); |
|
||||||
|
|
||||||
data_as_guint = g_bytes_unref_to_data(data, &data_size); |
|
||||||
script = g_strdup_printf("%s", data_as_guint); |
|
||||||
|
|
||||||
bundle = webkit_user_script_new( |
|
||||||
script, |
|
||||||
WEBKIT_USER_CONTENT_INJECT_TOP_FRAME, |
|
||||||
WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START, |
|
||||||
NULL, /* URL whitelist pattern */ |
|
||||||
NULL /* URL blacklist pattern */ |
|
||||||
); |
|
||||||
|
|
||||||
webkit_user_content_manager_add_script(WEBKIT_USER_CONTENT_MANAGER(manager), bundle); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
int |
|
||||||
main(int argc, char **argv) { |
|
||||||
GdkScreen *screen; |
|
||||||
GdkWindow *root_window; |
|
||||||
GdkRectangle geometry; |
|
||||||
GdkRGBA bg_color; |
|
||||||
WebKitWebContext *context; |
|
||||||
GtkCssProvider *css_provider; |
|
||||||
WebKitCookieManager *cookie_manager; |
|
||||||
|
|
||||||
/* Prevent memory from being swapped out, since we see unencrypted passwords. */ |
|
||||||
mlockall (MCL_CURRENT | MCL_FUTURE); |
|
||||||
|
|
||||||
/* https://goo.gl/vDFwFe */ |
|
||||||
g_setenv ("GDK_CORE_DEVICE_EVENTS", "1", TRUE); |
|
||||||
|
|
||||||
/* Temporary workaround until fixed upstream: https://goo.gl/wFJ4v7 */ |
|
||||||
g_setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", TRUE); |
|
||||||
|
|
||||||
/* Initialize i18n */ |
|
||||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); |
|
||||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
|
||||||
textdomain(GETTEXT_PACKAGE); |
|
||||||
|
|
||||||
gtk_init(&argc, &argv); |
|
||||||
|
|
||||||
g_unix_signal_add(SIGTERM, (GSourceFunc) quit_cb, NULL); |
|
||||||
g_unix_signal_add(SIGINT, (GSourceFunc) quit_cb, NULL); |
|
||||||
g_unix_signal_add(SIGHUP, (GSourceFunc) quit_cb, NULL); |
|
||||||
|
|
||||||
/* Initialize greeter config */ |
|
||||||
conf = get_config(); |
|
||||||
|
|
||||||
/* Set default cursor */ |
|
||||||
root_window = gdk_get_default_root_window(); |
|
||||||
default_display = gdk_display_get_default(); |
|
||||||
|
|
||||||
gdk_window_set_cursor(root_window, gdk_cursor_new_for_display(default_display, GDK_LEFT_PTR)); |
|
||||||
|
|
||||||
/* Setup the main window */ |
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
||||||
screen = gtk_window_get_screen(GTK_WINDOW(window)); |
|
||||||
|
|
||||||
gtk_window_set_decorated(GTK_WINDOW(window), FALSE); |
|
||||||
|
|
||||||
#ifdef HAS_GTK_3_22 |
|
||||||
GdkMonitor *monitor = gdk_display_get_primary_monitor(default_display); |
|
||||||
gdk_monitor_get_geometry(monitor, &geometry); |
|
||||||
#else |
|
||||||
gdk_screen_get_monitor_geometry(screen, gdk_screen_get_primary_monitor(screen), &geometry); |
|
||||||
#endif |
|
||||||
|
|
||||||
gtk_window_set_default_size(GTK_WINDOW(window), geometry.width, geometry.height); |
|
||||||
gtk_window_move(GTK_WINDOW(window), geometry.x, geometry.y); |
|
||||||
|
|
||||||
/* Setup CSS provider. We use CSS to set the window background to black instead
|
|
||||||
* of default white so the screen doesnt flash during startup. |
|
||||||
*/ |
|
||||||
greeter_resources = greeter_resources_get_resource(); |
|
||||||
css_provider = gtk_css_provider_new(); |
|
||||||
|
|
||||||
g_resources_register(greeter_resources); |
|
||||||
gtk_css_provider_load_from_resource( |
|
||||||
GTK_CSS_PROVIDER(css_provider), |
|
||||||
"/com/antergos/webkit2-greeter/css/style.css" |
|
||||||
); |
|
||||||
gtk_style_context_add_provider_for_screen( |
|
||||||
screen, |
|
||||||
GTK_STYLE_PROVIDER(css_provider), |
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION |
|
||||||
); |
|
||||||
|
|
||||||
/* Register and connect handler that will set the web extensions directory
|
|
||||||
* so webkit can find our extension. |
|
||||||
*/ |
|
||||||
context = webkit_web_context_get_default(); |
|
||||||
g_signal_connect(context, "initialize-web-extensions", G_CALLBACK(initialize_web_extensions_cb), NULL); |
|
||||||
webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); |
|
||||||
|
|
||||||
/* Set cookie policy */ |
|
||||||
cookie_manager = webkit_web_context_get_cookie_manager(context); |
|
||||||
webkit_cookie_manager_set_accept_policy(cookie_manager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); |
|
||||||
|
|
||||||
/* Register and connect handler of any messages we send from our web extension process. */ |
|
||||||
manager = webkit_user_content_manager_new(); |
|
||||||
g_signal_connect(manager, "script-message-received::GreeterBridge", G_CALLBACK(message_received_cb), NULL); |
|
||||||
webkit_user_content_manager_register_script_message_handler(manager, "GreeterBridge"); |
|
||||||
|
|
||||||
javascript_bundle_injection_setup(); |
|
||||||
|
|
||||||
/* Create the web_view */ |
|
||||||
web_view = webkit_web_view_new_with_user_content_manager(manager); |
|
||||||
|
|
||||||
/* Set the web_view's settings. */ |
|
||||||
create_new_webkit_settings_object(); |
|
||||||
webkit_web_view_set_settings(WEBKIT_WEB_VIEW(web_view), WEBKIT_SETTINGS(webkit_settings)); |
|
||||||
|
|
||||||
/* The default background color of the web_view is white which causes a flash effect when the greeter starts.
|
|
||||||
* We make it black instead. This only applies when the theme hasn't set the body background via CSS. |
|
||||||
*/ |
|
||||||
gdk_rgba_parse(&bg_color, "#000000"); |
|
||||||
webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(web_view), gdk_rgba_copy(&bg_color)); |
|
||||||
|
|
||||||
/* Maybe disable the context (right-click) menu. */ |
|
||||||
g_signal_connect(WEBKIT_WEB_VIEW(web_view), "context-menu", G_CALLBACK(context_menu_cb), NULL); |
|
||||||
|
|
||||||
/* There's no turning back now, let's go! */ |
|
||||||
gtk_container_add(GTK_CONTAINER(window), web_view); |
|
||||||
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), |
|
||||||
g_strdup_printf("file://%s/%s/index.html", THEME_DIR, conf->greeter->webkit_theme)); |
|
||||||
|
|
||||||
gtk_widget_show_all(window); |
|
||||||
gtk_widget_set_can_focus(GTK_WIDGET(web_view), TRUE); |
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(web_view)); |
|
||||||
|
|
||||||
g_debug("Entering Gtk loop..."); |
|
||||||
gtk_main(); |
|
||||||
g_debug("Exited Gtk loop."); |
|
||||||
|
|
||||||
return 0; |
|
||||||
} |
|
@ -1,5 +0,0 @@ |
|||||||
install_subdir('_vendor', install_dir : get_option('with-theme-dir')) |
|
||||||
|
|
||||||
install_subdir('antergos', install_dir : get_option('with-theme-dir')) |
|
||||||
|
|
||||||
install_subdir('simple', install_dir : get_option('with-theme-dir')) |
|
@ -1,41 +0,0 @@ |
|||||||
# ================================ # |
|
||||||
# ------->>> Resources <<<-------- # |
|
||||||
# ================================ # |
|
||||||
|
|
||||||
resource_dir = include_directories('resource') |
|
||||||
qt5 = import('qt5') |
|
||||||
utils = '@0@/utils.sh'.format(meson.build_root()) |
|
||||||
|
|
||||||
js_sources = run_command(utils, 'combine-js') |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ======================================= # |
|
||||||
# ------->>> WebKit2 Extension <<<------- # |
|
||||||
# ======================================= # |
|
||||||
|
|
||||||
webext_sources = ['webkit2-extension.c'] |
|
||||||
|
|
||||||
webext = library( |
|
||||||
'lightdm-webkit2-greeter-webext', |
|
||||||
webext_sources, |
|
||||||
dependencies: webext_deps, |
|
||||||
install: true, |
|
||||||
install_dir : extdir |
|
||||||
) |
|
||||||
|
|
||||||
|
|
||||||
# ============================= # |
|
||||||
# ------->>> Greeter <<<------- # |
|
||||||
# ============================= # |
|
||||||
|
|
||||||
greeter_sources = [gresources, 'greeter.c', 'greeter-config.c'] |
|
||||||
|
|
||||||
greeter = executable( |
|
||||||
'lightdm-webkit2-greeter', |
|
||||||
greeter_sources, |
|
||||||
dependencies: greeter_deps, |
|
||||||
install: true |
|
||||||
) |
|
||||||
|
|
Loading…
Reference in new issue