console command change wallpaper
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    console command change wallpaper

    I'm running fedora 20 and I've been trawling google trying to find a command that will work in a terminal to change the desktop wallpaper. Nothing works, anywhere. The closest I've come is
    gsettings set org.cinnamon.desktop.background picture-uri "file:///path/to/my-pic.jpg"
    but this throws an error:
    (process:5586): dconf-WARNING **: failed to commit changes to dconf: Error spawning command line 'dbus-launch --autolaunch=d0c47ea5cfb545ef9068c61d8ffe29ba --binary-syntax --close-stderr': Child process exited with code 1
    I don't know what this means or how to get this to work in fedora 20. thanks for any help.

  2. #2
    Join Date
    Oct 2011
    Posts
    1,823
    Linux Chrome 67.0.3396.87

    Re: console command change wallpaper

    You need to be logged in as user you want to change wallpaper for in order for this to work. Also, the configuration path is only for Cinnamon DE, for others you would need a different path.

  3. #3
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    I've tried the command logged in as the user:
    $ gsettings set org.gnome.desktop.background picture-uri "file:///path/to/my-pic.jpg"
    the command doesn't give any error, the cursor just drops to the next line but the wallpaper doesn't change.
    I've also tried:
    dbus-launch gsettings set org.gnome.desktop.background picture-uri "file:///path/to/my-pic.jpg"
    feh --bg-fill /path/to/my-pic.jpg

    same result as above. Thanks for any further ideas.

  4. #4
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    update: I've had partial success. This command:
    feh --bg-fill /path/to/my-pic.jpg
    does designate a new background but I have to log in and out again to make it appear. And yet if I change the wallpaper from the desktop I don't have to log in and out. What do I need to do to make the command do it without having to log in and out?

  5. #5
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    6,217
    Linux Firefox 61.0

    Re: console command change wallpaper

    Quote Originally Posted by tonjg
    update: I've had partial success. This command:
    feh --bg-fill /path/to/my-pic.jpg
    does designate a new background but I have to log in and out again to make it appear. And yet if I change the wallpaper from the desktop I don't have to log in and out. What do I need to do to make the command do it without having to log in and out?
    you'd probably have to kill the process renders the desktop (works with MATE, not sure about GNOME because of Wayland). with Wayland some commands issued from the terminal are denied for obvious security reasons. this is also likely why you have to logout and back in to see changes. please expand on why you want to use a terminal command to change wallpaper rather than the desktop dialogue which works?

    there may be a better way to achieve what you really want out of this

  6. #6
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    I like doing things one-shot with terminal commands, but more importantly I'm working with video and streaming the desktop so a single command that changes the wallpaper quickly is much preferred to messing about with windows in the gui.

  7. #7
    Join Date
    Oct 2011
    Posts
    1,823
    Linux Chrome 67.0.3396.87

    Re: console command change wallpaper

    Hi, knowing the DE you are using would probably help.

  8. #8
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    ok here's what I can rake up:
    OS fedora 20

    # ls /usr/bin/*session
    /usr/bin/gnome-session

    [root@localhost ~]# pgrep -l "gnome|kde|mate|cinnamon"
    25 kdevtmpfs
    694 gnome-session
    874 gnome-settings-
    925 gnome-keyring-d
    1194 gnome-shell
    1322 gnome-shell-cal


    $ wmctrl -m | grep "Name:" | awk '{print $2}'
    GNOME


    thanks for your help so far. I'm close now, I can change the designated background with a command but just need a way to switch it live without having to log in and out.

  9. #9
    Join Date
    Oct 2011
    Posts
    1,823
    Linux Chrome 67.0.3396.87

    Re: console command change wallpaper

    Seems like it is Gnome shell. Fedora 20 uses Gnome 3.10. issuing `gsettings` command should update the desktop background immediately, at least it does on newer Gnome versions. Maybe there was a bug on older Gnome version.

    As a workaround you could try reloading Gnome after changing the `picture-uri` path. Maybe with the following command:

    Code:
    killall -3 gnome-shell
    Reference: https://askubuntu.com/questions/4553...-freeze/496999

  10. #10
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    thanks but killall -3 gnome-shell only gave me a crash of the desktop and commands didn't work after that.
    I have made further progress: though almost there.
    I found a script here: https://stackoverflow.com/questions/...66729#19666729

    #!/bin/bash

    # TODO: At night only dark wallpapers.

    # Wallpaper's directory.
    dir="${HOME}/images/wallpapers/"

    # export DBUS_SESSION_BUS_ADDRESS environment variable
    PID=$(pgrep gnome-session)
    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

    # Random wallpaper.
    wallpaper=`find "${dir}" -type f | shuf -n1`

    # Change wallpaper.
    # http://bit.ly/HYEU9H
    gsettings set org.gnome.desktop.background picture-options "spanned"
    gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"


    this script works and changes the background wallpaper when I run it but it chooses a random wallpaper. I haven't been able to work out how it does it but I'd like to either extract the correct command from it or modify this script so it chooses the image file I want.

  11. #11
    Join Date
    Oct 2011
    Posts
    1,823
    Linux Chrome 67.0.3396.87

    Re: console command change wallpaper

    There is nothing special about the script. It sets the DBus environment variable for use from a crontab for example. Searches for files and randomly selects one of them. In the end it sets the wallpaper using the same command.

  12. #12
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    in that case I'm puzzled as to why this script works and yet the commands I use don't.

  13. #13
    Join Date
    Oct 2011
    Posts
    1,823
    Linux Chrome 67.0.3396.87

    Re: console command change wallpaper

    Maybe there is an issue with environment, try the following simplified script. Modify `picture-uri` to point to an existing image.

    Code:
    #!/bin/bash
    PID=$(pgrep gnome-session)
    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
    
    gsettings set org.gnome.desktop.background picture-uri "file:///path/to/my-pic.jpg"

  14. #14
    Join Date
    Oct 2009
    Posts
    94
    Windows NT 10.0 Chrome 67.0.3396.99

    Re: console command change wallpaper

    yeah your script works and changes the background image to the one I want. Thankyou for that. I can work with this now.
    One little thing....
    the change over to the new wallpaper background takes the form of a fade-over. Is it possible to get an instant cut to the next wallpaper change?

Similar Threads

  1. Can't change the lockscreen wallpaper
    By Theeeo in forum Using Fedora
    Replies: 2
    Last Post: 4th February 2017, 03:03 AM
  2. Fedora 23, change wallpaper in GDM
    By damaro in forum Using Fedora
    Replies: 3
    Last Post: 22nd July 2016, 08:01 PM
  3. Change wallpaper
    By janmi23 in forum Fedora Spins & Remixes
    Replies: 1
    Last Post: 8th March 2011, 06:21 PM
  4. add wallpaper to console
    By mouse_runner in forum Using Fedora
    Replies: 3
    Last Post: 1st December 2009, 07:59 AM
  5. Replies: 3
    Last Post: 11th July 2009, 08:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •