Skip to content
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

Greet Now Support Dark_Mode #563

Open
wants to merge 3 commits into
base: master
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
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo rm -fr build/
sudo meson build
cd build/
sudo ninja
sudo ninja install
cd ../
sudo service lightdm restart
4 changes: 4 additions & 0 deletions lightdm-greeter-capture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
sleep 30
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/$DISPLAY xwd -root > /tmp/greeter.xwd
convert /tmp/greeter.xwd /home/$(whoami)/Pictures/greeter.png
3 changes: 3 additions & 0 deletions src/Cards/BaseCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public abstract class Greeter.BaseCard : Gtk.Revealer {
public bool connecting { get; set; default = false; }
public bool need_password { get; set; default = false; }
public bool use_fingerprint { get; set; default = false; }

public int prefers_color_scheme { get; set; default = 0; }
public int prefers_accent_color { get; set; default = 0; }

protected const int ERROR_SHAKE_DURATION = 450;

Expand Down
13 changes: 9 additions & 4 deletions src/Cards/UserCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ public class Greeter.UserCard : Greeter.BaseCard {
private void update_style () {
var gtksettings = Gtk.Settings.get_default ();
gtksettings.gtk_theme_name = "io.elementary.stylesheet." + accent_to_string (prefers_accent_color);

var style_provider = Gtk.CssProvider.get_named (gtksettings.gtk_theme_name, null);
password_entry_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}

private string accent_to_string (int i) {
Expand Down Expand Up @@ -350,11 +347,12 @@ public class Greeter.UserCard : Greeter.BaseCard {
);

is_24h = greeter_act.time_format != "12h";
prefers_accent_color = greeter_act.prefers_accent_color;
sleep_inactive_ac_timeout = greeter_act.sleep_inactive_ac_timeout;
sleep_inactive_ac_type = greeter_act.sleep_inactive_ac_type;
sleep_inactive_battery_timeout = greeter_act.sleep_inactive_battery_timeout;
sleep_inactive_battery_type = greeter_act.sleep_inactive_battery_type;
prefers_color_scheme = greeter_act.prefers_color_scheme;
prefers_accent_color = greeter_act.prefers_accent_color;

((GLib.DBusProxy) greeter_act).g_properties_changed.connect ((changed_properties, invalidated_properties) => {
string time_format;
Expand All @@ -366,6 +364,13 @@ public class Greeter.UserCard : Greeter.BaseCard {
changed_properties.lookup ("SleepInactiveACType", "i", out _sleep_inactive_ac_type);
changed_properties.lookup ("SleepInactiveBatteryTimeout", "i", out _sleep_inactive_battery_timeout);
changed_properties.lookup ("SleepInactiveBatteryType", "i", out _sleep_inactive_battery_type);

int prefers_color_scheme_out;
changed_properties.lookup ("PrefersColorScheme", "i", out prefers_color_scheme_out);
prefers_color_scheme = prefers_color_scheme_out;
int prefers_accent_color_out;
changed_properties.lookup ("PrefersColorScheme", "i", out prefers_accent_color_out);
prefers_accent_color = prefers_accent_color_out;
});
} catch (Error e) {
critical (e.message);
Expand Down
48 changes: 48 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
var rect = monitor.get_geometry ();
resize (rect.width, rect.height);
move (rect.x, rect.y);
user_style ();
}

private void create_session_selection_action () {
Expand Down Expand Up @@ -540,6 +541,8 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
if (binding != null) {
binding.unbind ();
}

user_style ();

user_card.set_keyboard_layouts ();

Expand Down Expand Up @@ -623,4 +626,49 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
carousel.scroll_to (next_card);
}
}


private void user_style () {
var gtksettings = Gtk.Settings.get_default ();
if (current_card.prefers_color_scheme == 1) {
gtksettings.gtk_application_prefer_dark_theme = true;
} else {
gtksettings.gtk_application_prefer_dark_theme = false;
}
switch (current_card.prefers_accent_color) {
case 1:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.strawberry";
break;
case 2:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.orange";
break;
case 3:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.banana";
break;
case 4:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.lime";
break;
case 5:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.mint";
break;
case 6:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.blueberry";
break;
case 7:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.grape";
break;
case 8:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.bubblegum";
break;
case 9:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.cocoa";
break;
case 10:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.slate";
break;
default:
gtksettings.gtk_theme_name = "io.elementary.stylesheet.blueberry";
break;
}
}
}
8 changes: 6 additions & 2 deletions src/PantheonAccountsServicePlugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
interface Pantheon.AccountsService : Object {
public abstract string time_format { owned get; set; }

public abstract int prefers_accent_color { get; set; }

[DBus (name = "SleepInactiveACTimeout")]
public abstract int sleep_inactive_ac_timeout { get; set; }
[DBus (name = "SleepInactiveACType")]
public abstract int sleep_inactive_ac_type { get; set; }

public abstract int sleep_inactive_battery_timeout { get; set; }
public abstract int sleep_inactive_battery_type { get; set; }

[DBus (name = "PrefersColorScheme")]
public abstract int prefers_color_scheme { get; set; }

[DBus (name = "PrefersAccentColor")]
public abstract int prefers_accent_color { get; set; }
}

[DBus (name = "io.elementary.SettingsDaemon.AccountsService")]
Expand Down