Skip to content

Expand config abilities #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions elephant-greeter.conf.base
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ gtk-cursor-theme-name=Adwaita
ui-file-location=INSTALL_PATH/share/elephant-greeter/elephant-greeter.ui
x-icon-location=INSTALL_PATH/share/elephant-greeter/img/X.png
wayland-icon-location=INSTALL_PATH/share/elephant-greeter/img/wayland.png
background-file-location=
welcome-message=Welcome Back!
no-icon=False

23 changes: 21 additions & 2 deletions elephant-greeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
UI_FILE_LOCATION = "/usr/local/share/elephant-greeter/elephant-greeter.ui"
WAYLAND_ICON_LOCATION = "/usr/local/share/elephant-greeter/img/wayland.png"
X_ICON_LOCATION = "/usr/local/share/elephant-greeter/img/X.png"
BACKGROUND_FILE_LOCATION = ""
WELCOME_MESSAGE = ""
NO_ICON = True

# read the cache
cache_dir = (Path.home() / ".cache" / "elephant-greeter")
Expand Down Expand Up @@ -71,10 +74,14 @@ def read_config(gtk_settings, config_file="/etc/lightdm/elephant-greeter.conf"):

if "Greeter" in config:
global DEFAULT_SESSION, UI_FILE_LOCATION, X_ICON_LOCATION, WAYLAND_ICON_LOCATION
global BACKGROUND_FILE_LOCATION, WELCOME_MESSAGE, NO_ICON
DEFAULT_SESSION = config["Greeter"].get("default-session", DEFAULT_SESSION)
UI_FILE_LOCATION = config["Greeter"].get("ui-file-location", UI_FILE_LOCATION)
X_ICON_LOCATION = config["Greeter"].get("x-icon-location", X_ICON_LOCATION)
WAYLAND_ICON_LOCATION = config["Greeter"].get("wayland-icon-location", WAYLAND_ICON_LOCATION)
BACKGROUND_FILE_LOCATION = config["Greeter"].get("background-file-location", "")
WELCOME_MESSAGE = config["Greeter"].get("welcome-message", "Welcome Back!")
NO_ICON = config["Greeter"].get("no-icon", "False") == "True"


def write_cache():
Expand Down Expand Up @@ -206,6 +213,16 @@ def poweroff_click_handler(widget, data=None):
ui_file_path = UI_FILE_LOCATION
builder.add_from_file(ui_file_path)
login_window = builder.get_object("login_window")

if BACKGROUND_FILE_LOCATION != "":
backgroundcss = login_window.get_css_name()+""".background{
background-image: url('""" + BACKGROUND_FILE_LOCATION + """');
}"""
print(backgroundcss)
styleprovider = Gtk.CssProvider()
styleprovider.load_from_data(backgroundcss)
login_window.get_style_context().add_provider(provider=styleprovider, priority=Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

password_entry = builder.get_object("password_entry")
password_label = builder.get_object("password_label")
message_label = builder.get_object("message_label")
Expand All @@ -225,8 +242,10 @@ def poweroff_click_handler(widget, data=None):
password_entry.set_visibility(False)
if greeter_session_type is not None:
print(f"greeter session type: {greeter_session_type}", file=sys.stderr)
message_label.set_text("Welcome Back!")
if greeter_session_type.lower() == "wayland":
message_label.set_text(WELCOME_MESSAGE)
if NO_ICON:
icon.clear()
elif greeter_session_type.lower() == "wayland":
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(WAYLAND_ICON_LOCATION, 32, 32, False)
icon.set_from_pixbuf(pixbuf)
elif greeter_session_type.lower() == "x11":
Expand Down