(kemona_halftau)
(solved, thank you)
does anyone know if it’s possible to programmatically change the wallpaper (desktop background) in modern versions of gnome (without prompting the user)? ideally there would also be a way to get the current wallpaper to restore it later, but that isn’t strictly necessary for what i’m trying to do
bonus points if it’s possible from a shell script
(the wallpaper portal doesn’t work for this purpose because it prompts the user before changing the wallpaper and doesn’t seem to allow for restoring)
if this is not possible, is there a way to have a wayland surface that behaves like a wallpaper in mutter/gnome (similar to wlr-layer-shell)?
@kemona_halftau Yes, from a shell script with gsettings, no prompt (as long as you're not inside a Flatpak sandbox):
save: gsettings get org.gnome.desktop.background picture-uri
set: gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/img.png'
Since GNOME 42 there's a separate picture-uri-dark key used in dark style, so save/set both. picture-options controls zoom/scaled etc.
(kemona_halftau)
@smartbudgetsheets thanks, i will try this
@kemona_halftau given that this is wayland & gnome, I assume the answer is "no, kill yourself"
(kemona_halftau)
@mir what command(s) would i need to run to test that?
@kemona_halftaudconf dump /org/gnome/desktop/
should spit out a dconf-formatted list of gnome desktop settings. i dont remember whether it’s called [background] or [wallpaper] but the value can be set to a file:// uri by piping the same format into dconf load /org/gnome/desktop/
(kemona_halftau)
follow-up question: is there an easy way to do this from a c or c++ program without using fork and exec or system?
i need to be able to backup all values in the org.gnome.desktop.background schema, set picture-uri, picture-uri-dark, picture-options, and either primary-color or secondary-color or maybe both, then restore from the backup later, and all of this needs to apply in real-time
@kemona_halftau as far as I remember, and I don't remember much, but all these are just files, file references, and things you can just do if you have write permission on the relevant config files; updating the current may require a shell call, but it should be instant
@kemona_halftau@sharkey.skydevs.me
probably background_schema = g_settings_new("org.gnome.desktop.background") and g_settings_set_string(background_schema, "picture-uri", uri)
(kemona_halftau)
@lystopad doesn’t seem to work, reading it outputs file:///usr/share/backgrounds/gnome/adwaita-d.jxl (which is not the path of the wallpaper i have set) and writing to it does nothing
@kemona_halftau@sharkey.skydevs.me
maybe g_settings_sync() is needed afterwards to flush the changes ?
also the code isnt running in a sandbox or soemthing ?
(kemona_halftau)
@lystopad it’s running in an appimage (it’s a video game), is there a way to get appimages to have access to gsettings?
@kemona_halftau@sharkey.skydevs.me
if u run g_settings_get_string from ur code before u call set, does it return the current wallpaper or the default one ?
(kemona_halftau)
@lystopad it seems to return the default one
@kemona_halftau@sharkey.skydevs.me
probably need https://docs.gtk.org/gio/ctor.Settings.new_with_backend.html …
tho idk how to get the dconf backend, i will check when im with the laptop