2

I need to change the file permissions of an image downloaded from Unsplash API in order to use it as a Greeter (elementary OS login) background.

I've tried with Flags like FileCopyFlags.OVERWRITE, FileCopyFlags.ALL_METADATA, FileCopyFlags.TARGET_DEFAULT_PERMS and FileCopyFlags.NONE in the File.copy_async method but when the file is downloaded, its permissions are set to 600.

The reason which I need to change the permissions is that Greeter uses an image in the folder /var/lib/lightdm-data/user/wallpaper/image.jpg and needs the read permission for that image.

var file_path = File.new_for_path ("/home/user/.local/share/backgrounds/background.jpg");
var file_from_uri = File.new_for_uri ("https://images.unsplash.com/photo-1560613717-c793db79055e?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb2176");

if (!file_path.query_exists ()) {
  file_from_uri.copy_async.begin (file_path, 
    FileCopyFlags.OVERWRITE | 
    FileCopyFlags.ALL_METADATA, 
    GLib.Priority.DEFAULT, 
    null, (current_num_bytes, total_num_bytes) => {
       // show progress
    }, (obj, res) => {
       // detect end
    });
} else {
    print ("Picture already exist\n");
}

The downloaded image has [600] -rw------- permissions, however, [664] -rw-rw-r-- is required to use it for Greeter.

My undesirable result

I need this

Alexander Leithner
  • 3,169
  • 22
  • 33
Carlos Lopez
  • 133
  • 4
  • 1
    The only solution that I find was using Poxis: Posix.chmod (Path.build_filename (greeter_data_dir, img_file_name), 0644); – Carlos Lopez Jun 22 '19 at 02:06

0 Answers0