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

Rely on settings-daemon to copy wallpaper to greeter #361

Merged
merged 4 commits into from
Jul 20, 2023
Merged
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
54 changes: 0 additions & 54 deletions set-wallpaper-contract/set-wallpaper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ namespace SetWallpaperContractor {

private int delay_value = 60;

[DBus (name = "org.freedesktop.DisplayManager.AccountsService")]
interface AccountsServiceUser : Object {
[DBus (name = "BackgroundFile")]
public abstract string background_file { owned get; set; }
}

private void update_slideshow (string path, List<File> files, int duration) {
var wallpapers = "";
var len = files.length ();
Expand Down Expand Up @@ -141,50 +135,9 @@ namespace SetWallpaperContractor {
return dest;
}

private File? copy_for_greeter (File source) {
File? dest = null;
try {
string greeter_data_dir = Path.build_filename (Environment.get_variable ("XDG_GREETER_DATA_DIR"), "wallpaper");
if (greeter_data_dir == "") {
greeter_data_dir = Path.build_filename ("/var/lib/lightdm-data/", Environment.get_user_name (), "wallpaper");
}

var folder = File.new_for_path (greeter_data_dir);
if (folder.query_exists ()) {
var enumerator = folder.enumerate_children ("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
FileInfo? info = null;
while ((info = enumerator.next_file ()) != null) {
enumerator.get_child (info).@delete ();
}
} else {
folder.make_directory_with_parents ();
}

dest = File.new_for_path (Path.build_filename (greeter_data_dir, source.get_basename ()));
source.copy (dest, FileCopyFlags.OVERWRITE | FileCopyFlags.ALL_METADATA);
// Ensure wallpaper is readable by greeter user (owner rw, others r)
FileUtils.chmod (dest.get_path (), 0604);
} catch (Error e) {
warning ("%s\n", e.message);
return null;
}

return dest;
}

public static int main (string[] args) {
Gtk.init (ref args);

AccountsServiceUser? accounts_service = null;
try {
string uid = "%d".printf ((int) Posix.getuid ());
accounts_service = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts/User" + uid);
} catch (Error e) {
warning (e.message);
}

var folder = ensure_local_bg_exists ();
var files = new List<File> ();
for (var i = 1; i < args.length; i++) {
Expand All @@ -202,13 +155,6 @@ namespace SetWallpaperContractor {
}

files.append (append_file);

var greeter_file = copy_for_greeter (file);
if (greeter_file != null) {
path = greeter_file.get_path ();
}

accounts_service.background_file = path;
}
}

Expand Down
57 changes: 0 additions & 57 deletions src/Views/Wallpaper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
*
*/

[DBus (name = "org.freedesktop.DisplayManager.AccountsService")]
interface PantheonShell.AccountsServiceUser : Object {
[DBus (name = "BackgroundFile")]
public abstract string background_file { owned get; set; }
}

public class PantheonShell.Wallpaper : Gtk.Grid {
public enum ColumnType {
ICON,
Expand All @@ -44,9 +38,6 @@ public class PantheonShell.Wallpaper : Gtk.Grid {
private static GLib.Settings gnome_background_settings;
private static GLib.Settings gala_background_settings;

//Instance of the AccountsServices-Interface for this user
private AccountsServiceUser? accountsservice = null;

private Gtk.ScrolledWindow wallpaper_scrolled_window;
private Gtk.FlowBox wallpaper_view;
private Gtk.Overlay view_overlay;
Expand Down Expand Up @@ -74,17 +65,6 @@ public class PantheonShell.Wallpaper : Gtk.Grid {
}

construct {
// DBus connection needed in update_wallpaper for
// passing the wallpaper-information to accountsservice.
try {
int uid = (int)Posix.getuid ();
accountsservice = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts/User%i".printf (uid));
} catch (Error e) {
warning (e.message);
}

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);

wallpaper_view = new Gtk.FlowBox ();
Expand Down Expand Up @@ -248,13 +228,7 @@ public class PantheonShell.Wallpaper : Gtk.Grid {
}
}

var greeter_file = copy_for_greeter (file);
if (greeter_file != null) {
path = greeter_file.get_path ();
}

gnome_background_settings.set_string ("picture-uri", uri);
accountsservice.background_file = path;
}

private void update_checked_wallpaper (Gtk.FlowBox box, Gtk.FlowBoxChild child) {
Expand Down Expand Up @@ -494,37 +468,6 @@ public class PantheonShell.Wallpaper : Gtk.Grid {
return dest;
}

private static File? copy_for_greeter (File source) {
File? dest = null;
try {
string greeter_data_dir = Path.build_filename (Environment.get_variable ("XDG_GREETER_DATA_DIR"), "wallpaper");
if (greeter_data_dir == "") {
greeter_data_dir = Path.build_filename ("/var/lib/lightdm-data/", Environment.get_user_name (), "wallpaper");
}

var folder = File.new_for_path (greeter_data_dir);
if (folder.query_exists ()) {
var enumerator = folder.enumerate_children ("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
FileInfo? info = null;
while ((info = enumerator.next_file ()) != null) {
enumerator.get_child (info).@delete ();
}
} else {
folder.make_directory_with_parents ();
}

dest = File.new_for_path (Path.build_filename (greeter_data_dir, source.get_basename ()));
source.copy (dest, FileCopyFlags.OVERWRITE | FileCopyFlags.ALL_METADATA);
// Ensure wallpaper is readable by greeter user (owner rw, others r)
FileUtils.chmod (dest.get_path (), 0604);
} catch (Error e) {
warning (e.message);
return null;
}

return dest;
}

private void on_drag_data_received (Gtk.Widget widget, Gdk.DragContext ctx, int x, int y, Gtk.SelectionData sel, uint information, uint timestamp) {
if (sel.get_length () > 0) {
try {
Expand Down