Conversation
Edited 26 days ago
solved
Show content

(solved, thank you)
boosts_ok_gay 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)?

5
0
0

@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.

1
0
1
death threat jokes
Show content

@kemona_halftau given that this is wayland & gnome, I assume the answer is "no, kill yourself"

0
0
1
@kemona_halftau for the second: no, gnome hates you and wants you and your whole family dead for even suggesting a separate surface akin to layer-shell

As for changing it's own wallpaper, there might be something you can do trough gsettings but I'm not sure. I'd still start by looking trough the keys gnome has in dconf, though
0
0
1

@mir what command(s) would i need to run to test that?

1
0
0

@kemona_halftau
dconf 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/

0
0
1

boosts_ok_gay 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

3
3
0
probably missing the point
Show content
@kemona_halftau posix_spawn
0
0
0

@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

0
0
1

lesser scribe Anna of True Novembers, resident of the principality of ▓▓▓▓▓ in its XIV era‮

Edited 25 days ago

@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)

1
0
1

@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

1
0
0

lesser scribe Anna of True Novembers, resident of the principality of ▓▓▓▓▓ in its XIV era‮

Edited 25 days ago

@kemona_halftau@sharkey.skydevs.me

neocat_baa_256

maybe g_settings_sync() is needed afterwards to flush the changes ?
also the code isnt running in a sandbox or soemthing ?

1
0
0

@lystopad it’s running in an appimage (it’s a video game), is there a way to get appimages to have access to gsettings?

1
0
0

lesser scribe Anna of True Novembers, resident of the principality of ▓▓▓▓▓ in its XIV era‮

Edited 25 days ago

@kemona_halftau@sharkey.skydevs.me

neocat_thonk_256 if u run g_settings_get_string from ur code before u call set, does it return the current wallpaper or the default one ?

1
0
0

lesser scribe Anna of True Novembers, resident of the principality of ▓▓▓▓▓ in its XIV era‮

Edited 25 days ago

@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

0
0
1