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

Use dark wallpaper #1709

Merged
merged 4 commits into from Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/Background/BackgroundSource.vala
Expand Up @@ -23,6 +23,7 @@ namespace Gala {
"picture-opacity",
"picture-options",
"picture-uri",
"picture-uri-dark",
"primary-color",
"secondary-color"
};
Expand Down Expand Up @@ -67,6 +68,9 @@ namespace Gala {
}
}
});

unowned var granite_settings = Granite.Settings.get_default ();
granite_settings.notify["prefers-color-scheme"].connect (() => changed ());
}

private void monitors_changed () {
Expand All @@ -91,11 +95,7 @@ namespace Gala {

var style = settings.get_enum ("picture-options");
if (style != GDesktop.BackgroundStyle.NONE) {
var uri = settings.get_string ("picture-uri");
if (Uri.parse_scheme (uri) != null)
filename = File.new_for_uri (uri).get_path ();
else
filename = uri;
filename = get_background_path ();
}

// Animated backgrounds are (potentially) per-monitor, since
Expand All @@ -114,6 +114,24 @@ namespace Gala {
return backgrounds[monitor_index];
}

private string get_background_path () {
if (Granite.Settings.get_default ().prefers_color_scheme == DARK) {
var uri = settings.get_string ("picture-uri-dark");
var path = File.new_for_uri (uri).get_path ();
if (FileUtils.test (path, EXISTS)) {
return path;
}
}

var uri = settings.get_string ("picture-uri");
var path = File.new_for_uri (uri).get_path ();
if (FileUtils.test (path, EXISTS)) {
return path;
}

return uri;
}

private void background_changed (Background background) {
background.changed.disconnect (background_changed);
background.destroy ();
Expand Down