(Xubuntu) How to set the wallpaper using the command line?












11















I've done a lot of googling but haven't been able to find a solution to my problem.



I am a teacher and I'm using Xubuntu on some student computers. I have everything locked down pretty good, but I can't figure out how to restrict users from changing the wallpaper without having to out the whole machine in Kiosk mode. I don't care if they change it during their work session, but I would like to create a crontab that resets back to the original .png at reboot.



I'm hoping for a simple cron entry but I'm willing to ease into the world of shell scripts if that's what it takes.



Any ideas?










share|improve this question



























    11















    I've done a lot of googling but haven't been able to find a solution to my problem.



    I am a teacher and I'm using Xubuntu on some student computers. I have everything locked down pretty good, but I can't figure out how to restrict users from changing the wallpaper without having to out the whole machine in Kiosk mode. I don't care if they change it during their work session, but I would like to create a crontab that resets back to the original .png at reboot.



    I'm hoping for a simple cron entry but I'm willing to ease into the world of shell scripts if that's what it takes.



    Any ideas?










    share|improve this question

























      11












      11








      11


      1






      I've done a lot of googling but haven't been able to find a solution to my problem.



      I am a teacher and I'm using Xubuntu on some student computers. I have everything locked down pretty good, but I can't figure out how to restrict users from changing the wallpaper without having to out the whole machine in Kiosk mode. I don't care if they change it during their work session, but I would like to create a crontab that resets back to the original .png at reboot.



      I'm hoping for a simple cron entry but I'm willing to ease into the world of shell scripts if that's what it takes.



      Any ideas?










      share|improve this question














      I've done a lot of googling but haven't been able to find a solution to my problem.



      I am a teacher and I'm using Xubuntu on some student computers. I have everything locked down pretty good, but I can't figure out how to restrict users from changing the wallpaper without having to out the whole machine in Kiosk mode. I don't care if they change it during their work session, but I would like to create a crontab that resets back to the original .png at reboot.



      I'm hoping for a simple cron entry but I'm willing to ease into the world of shell scripts if that's what it takes.



      Any ideas?







      xubuntu cron wallpaper






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '13 at 22:11









      JohnJohn

      61114




      61114






















          6 Answers
          6






          active

          oldest

          votes


















          9














          In Xfce land, that's



          xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


          (Substitute the file path you want, of course.)



          xfconf-query --channel xfce4-desktop --list


          lists all related properties, in case screen0/monitor0 isn't the one.






          share|improve this answer
























          • When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

            – John
            Nov 22 '13 at 4:10













          • How about enclosing the whole thing in a shell script and run the shell script using cron instead?

            – Chester
            Nov 22 '13 at 5:21











          • Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

            – John
            Nov 22 '13 at 12:28











          • @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

            – kamil
            Feb 13 '14 at 17:06






          • 1





            For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

            – Ilmari Karonen
            May 9 '15 at 19:39



















          9














          For xfce4 in Xubuntu 14.04, use property /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image instead of /backdrop/screen0/monitor0/image-path



          You also need to set DBUS_SESSION_BUS_ADDRESS environment variable like this:



          PID=$(pgrep xfce4-session)
          export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)


          In my case I wanted to rotate the wallpaper (random image from a selected folder) once a day, but I turn-on my PC irregularly, so I solved it by running a script from cron every half-hour, but only take effect once a day.



          entry in crontab (add it via crontab -e command):



          0,30 * * * * /home/lucifer/scripts/rotate-wallpaper.sh


          rotate-wallpaper.sh:



          #!/bin/bash
          wallpaperdir="/home/lucifer/Pictures/wallpapers"
          datefile="/home/lucifer/.wallsw"
          thisday=$( date +%j )
          wallfiles=($wallpaperdir/*)
          randompic=`printf "%sn" "${wallfiles[RANDOM % ${#wallfiles[@]}]}"`
          PID=$(pgrep xfce4-session)
          export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

          if [ -f "$datefile" ]
          then
          lastday=$( cat "$datefile" )
          if [ "$lastday" != "$thisday" ]
          then
          date +%j > "$datefile"
          xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
          fi
          else
          date +%j > "$datefile"
          xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
          fi


          Note:
          -If you are using non-English system locale, the property can have a different name. The best way to find out the property name, open a terminal window, and run this command:



          xfconf-query -c xfce4-desktop -m


          This will turn on monitoring of xfce4-desktop properties. Now change your background manually. You should see the property name which was affected by this change in the terminal window. Use this property name if it's different from /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image






          share|improve this answer

































            0














            Try



            gsettings set org.gnome.desktop.background picture-uri file:///your/picture/location.jpg


            The file:// is required.






            share|improve this answer


























            • I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

              – John
              Nov 22 '13 at 1:50



















            0














            Don't use cron. Instead use the startup script. Although you can use cron but I don't prefer it in this situation because it is user specific.



            Do it this way:



            sudo vi /etc/rc.local


            add the following at the end of file



            sudo -u YOURUSERNAME -g $( id -g YOURUSERNAME ) xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


            and make sure you replace YOURUSERNAME with your current user. And replace /usr/share/backgrounds/xfce/xfce-blue.jpg by the real path of the new background image and make sure your user has permission to read the image






            share|improve this answer



















            • 1





              Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

              – Stéphane Gourichon
              Oct 31 '16 at 11:10



















            0














            to set xfce background color in bash script:



            d=0; r=$d; g=$d; b=$d; 
            xfconf-query -c xfce4-desktop
            -p /backdrop/screen0/monitor0/workspace0/color1
            -s $r -s $g -s $b -s 65535


            colors:



            black: d=0;
            white: d=65535;
            red: r=65535; g=0; b=0;


            etc.



            r g b are 16bit decimal RGB components.



            65535 = 255*257. 255 = 0xFF in hex.



            to convert from 8bit hex color code, to 16bit decimal RGB components:



            x='C31717' # dark red
            r=$((16#${x:0:2} * 257))
            g=$((16#${x:2:2} * 257))
            b=$((16#${x:4:2} * 257))


            if background color does not change,
            set image style to none



            xfconf-query -c xfce4-desktop 
            -p /backdrop/screen0/monitor0/workspace0/image-style
            -s 0


            .... and set fill style to solid



            xfconf-query -c xfce4-desktop 
            -p /backdrop/screen0/monitor0/workspace0/color-style
            -s 0


            to set a different color for every workspace:



            xfconf-query -c xfce4-desktop 
            -p /backdrop/single-workspace-mode
            -s false

            i=1; # workspace id
            xfconf-query -c xfce4-desktop
            -p /backdrop/screen0/monitor0/workspace$i/image-style
            -s 0
            xfconf-query -c xfce4-desktop
            -p /backdrop/screen0/monitor0/workspace$i/color-style
            -s 0
            x=0; r=$x; g=$x; b=$x;
            xfconf-query -c xfce4-desktop
            -p /backdrop/screen0/monitor0/workspace$i/color1
            -s $r -s $g -s $b -s 65535


            nuff said ^^






            share|improve this answer































              0














              Setting image-path has no effect at my system (XFCE 4.12, Debian buster/sid).



              I use the following for setting the background image of all workspaces:



              xfconf-query --channel xfce4-desktop --list | grep last-image | while read path; do
              xfconf-query --channel xfce4-desktop --property $path --set <path>
              done





              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f380550%2fxubuntu-how-to-set-the-wallpaper-using-the-command-line%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                6 Answers
                6






                active

                oldest

                votes








                6 Answers
                6






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                9














                In Xfce land, that's



                xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                (Substitute the file path you want, of course.)



                xfconf-query --channel xfce4-desktop --list


                lists all related properties, in case screen0/monitor0 isn't the one.






                share|improve this answer
























                • When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                  – John
                  Nov 22 '13 at 4:10













                • How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                  – Chester
                  Nov 22 '13 at 5:21











                • Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                  – John
                  Nov 22 '13 at 12:28











                • @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                  – kamil
                  Feb 13 '14 at 17:06






                • 1





                  For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                  – Ilmari Karonen
                  May 9 '15 at 19:39
















                9














                In Xfce land, that's



                xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                (Substitute the file path you want, of course.)



                xfconf-query --channel xfce4-desktop --list


                lists all related properties, in case screen0/monitor0 isn't the one.






                share|improve this answer
























                • When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                  – John
                  Nov 22 '13 at 4:10













                • How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                  – Chester
                  Nov 22 '13 at 5:21











                • Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                  – John
                  Nov 22 '13 at 12:28











                • @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                  – kamil
                  Feb 13 '14 at 17:06






                • 1





                  For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                  – Ilmari Karonen
                  May 9 '15 at 19:39














                9












                9








                9







                In Xfce land, that's



                xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                (Substitute the file path you want, of course.)



                xfconf-query --channel xfce4-desktop --list


                lists all related properties, in case screen0/monitor0 isn't the one.






                share|improve this answer













                In Xfce land, that's



                xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                (Substitute the file path you want, of course.)



                xfconf-query --channel xfce4-desktop --list


                lists all related properties, in case screen0/monitor0 isn't the one.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '13 at 3:02









                SaltSalt

                70133




                70133













                • When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                  – John
                  Nov 22 '13 at 4:10













                • How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                  – Chester
                  Nov 22 '13 at 5:21











                • Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                  – John
                  Nov 22 '13 at 12:28











                • @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                  – kamil
                  Feb 13 '14 at 17:06






                • 1





                  For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                  – Ilmari Karonen
                  May 9 '15 at 19:39



















                • When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                  – John
                  Nov 22 '13 at 4:10













                • How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                  – Chester
                  Nov 22 '13 at 5:21











                • Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                  – John
                  Nov 22 '13 at 12:28











                • @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                  – kamil
                  Feb 13 '14 at 17:06






                • 1





                  For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                  – Ilmari Karonen
                  May 9 '15 at 19:39

















                When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                – John
                Nov 22 '13 at 4:10







                When I run that in the command line, it works like a charm. When I try to add it to cron though, it doesn't do anything. Any ideas? `

                – John
                Nov 22 '13 at 4:10















                How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                – Chester
                Nov 22 '13 at 5:21





                How about enclosing the whole thing in a shell script and run the shell script using cron instead?

                – Chester
                Nov 22 '13 at 5:21













                Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                – John
                Nov 22 '13 at 12:28





                Created the shell script and made it executable. It runs when double clicked and I can run it in the command line. I tried adding it to cron with @reboot as the time but it doesn't seem to be working. Do I need to add something to cron other than just the path to the script?

                – John
                Nov 22 '13 at 12:28













                @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                – kamil
                Feb 13 '14 at 17:06





                @John It doesn't work in cron because cron work under root privilege and this is a user specific background. try changing the command to run as your user

                – kamil
                Feb 13 '14 at 17:06




                1




                1





                For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                – Ilmari Karonen
                May 9 '15 at 19:39





                For me, --property /backdrop/screen0/monitorLVDS1/workspace0/last-image did the trick.

                – Ilmari Karonen
                May 9 '15 at 19:39













                9














                For xfce4 in Xubuntu 14.04, use property /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image instead of /backdrop/screen0/monitor0/image-path



                You also need to set DBUS_SESSION_BUS_ADDRESS environment variable like this:



                PID=$(pgrep xfce4-session)
                export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)


                In my case I wanted to rotate the wallpaper (random image from a selected folder) once a day, but I turn-on my PC irregularly, so I solved it by running a script from cron every half-hour, but only take effect once a day.



                entry in crontab (add it via crontab -e command):



                0,30 * * * * /home/lucifer/scripts/rotate-wallpaper.sh


                rotate-wallpaper.sh:



                #!/bin/bash
                wallpaperdir="/home/lucifer/Pictures/wallpapers"
                datefile="/home/lucifer/.wallsw"
                thisday=$( date +%j )
                wallfiles=($wallpaperdir/*)
                randompic=`printf "%sn" "${wallfiles[RANDOM % ${#wallfiles[@]}]}"`
                PID=$(pgrep xfce4-session)
                export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

                if [ -f "$datefile" ]
                then
                lastday=$( cat "$datefile" )
                if [ "$lastday" != "$thisday" ]
                then
                date +%j > "$datefile"
                xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                fi
                else
                date +%j > "$datefile"
                xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                fi


                Note:
                -If you are using non-English system locale, the property can have a different name. The best way to find out the property name, open a terminal window, and run this command:



                xfconf-query -c xfce4-desktop -m


                This will turn on monitoring of xfce4-desktop properties. Now change your background manually. You should see the property name which was affected by this change in the terminal window. Use this property name if it's different from /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image






                share|improve this answer






























                  9














                  For xfce4 in Xubuntu 14.04, use property /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image instead of /backdrop/screen0/monitor0/image-path



                  You also need to set DBUS_SESSION_BUS_ADDRESS environment variable like this:



                  PID=$(pgrep xfce4-session)
                  export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)


                  In my case I wanted to rotate the wallpaper (random image from a selected folder) once a day, but I turn-on my PC irregularly, so I solved it by running a script from cron every half-hour, but only take effect once a day.



                  entry in crontab (add it via crontab -e command):



                  0,30 * * * * /home/lucifer/scripts/rotate-wallpaper.sh


                  rotate-wallpaper.sh:



                  #!/bin/bash
                  wallpaperdir="/home/lucifer/Pictures/wallpapers"
                  datefile="/home/lucifer/.wallsw"
                  thisday=$( date +%j )
                  wallfiles=($wallpaperdir/*)
                  randompic=`printf "%sn" "${wallfiles[RANDOM % ${#wallfiles[@]}]}"`
                  PID=$(pgrep xfce4-session)
                  export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

                  if [ -f "$datefile" ]
                  then
                  lastday=$( cat "$datefile" )
                  if [ "$lastday" != "$thisday" ]
                  then
                  date +%j > "$datefile"
                  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                  fi
                  else
                  date +%j > "$datefile"
                  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                  fi


                  Note:
                  -If you are using non-English system locale, the property can have a different name. The best way to find out the property name, open a terminal window, and run this command:



                  xfconf-query -c xfce4-desktop -m


                  This will turn on monitoring of xfce4-desktop properties. Now change your background manually. You should see the property name which was affected by this change in the terminal window. Use this property name if it's different from /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image






                  share|improve this answer




























                    9












                    9








                    9







                    For xfce4 in Xubuntu 14.04, use property /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image instead of /backdrop/screen0/monitor0/image-path



                    You also need to set DBUS_SESSION_BUS_ADDRESS environment variable like this:



                    PID=$(pgrep xfce4-session)
                    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)


                    In my case I wanted to rotate the wallpaper (random image from a selected folder) once a day, but I turn-on my PC irregularly, so I solved it by running a script from cron every half-hour, but only take effect once a day.



                    entry in crontab (add it via crontab -e command):



                    0,30 * * * * /home/lucifer/scripts/rotate-wallpaper.sh


                    rotate-wallpaper.sh:



                    #!/bin/bash
                    wallpaperdir="/home/lucifer/Pictures/wallpapers"
                    datefile="/home/lucifer/.wallsw"
                    thisday=$( date +%j )
                    wallfiles=($wallpaperdir/*)
                    randompic=`printf "%sn" "${wallfiles[RANDOM % ${#wallfiles[@]}]}"`
                    PID=$(pgrep xfce4-session)
                    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

                    if [ -f "$datefile" ]
                    then
                    lastday=$( cat "$datefile" )
                    if [ "$lastday" != "$thisday" ]
                    then
                    date +%j > "$datefile"
                    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                    fi
                    else
                    date +%j > "$datefile"
                    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                    fi


                    Note:
                    -If you are using non-English system locale, the property can have a different name. The best way to find out the property name, open a terminal window, and run this command:



                    xfconf-query -c xfce4-desktop -m


                    This will turn on monitoring of xfce4-desktop properties. Now change your background manually. You should see the property name which was affected by this change in the terminal window. Use this property name if it's different from /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image






                    share|improve this answer















                    For xfce4 in Xubuntu 14.04, use property /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image instead of /backdrop/screen0/monitor0/image-path



                    You also need to set DBUS_SESSION_BUS_ADDRESS environment variable like this:



                    PID=$(pgrep xfce4-session)
                    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)


                    In my case I wanted to rotate the wallpaper (random image from a selected folder) once a day, but I turn-on my PC irregularly, so I solved it by running a script from cron every half-hour, but only take effect once a day.



                    entry in crontab (add it via crontab -e command):



                    0,30 * * * * /home/lucifer/scripts/rotate-wallpaper.sh


                    rotate-wallpaper.sh:



                    #!/bin/bash
                    wallpaperdir="/home/lucifer/Pictures/wallpapers"
                    datefile="/home/lucifer/.wallsw"
                    thisday=$( date +%j )
                    wallfiles=($wallpaperdir/*)
                    randompic=`printf "%sn" "${wallfiles[RANDOM % ${#wallfiles[@]}]}"`
                    PID=$(pgrep xfce4-session)
                    export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

                    if [ -f "$datefile" ]
                    then
                    lastday=$( cat "$datefile" )
                    if [ "$lastday" != "$thisday" ]
                    then
                    date +%j > "$datefile"
                    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                    fi
                    else
                    date +%j > "$datefile"
                    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image --set $randompic
                    fi


                    Note:
                    -If you are using non-English system locale, the property can have a different name. The best way to find out the property name, open a terminal window, and run this command:



                    xfconf-query -c xfce4-desktop -m


                    This will turn on monitoring of xfce4-desktop properties. Now change your background manually. You should see the property name which was affected by this change in the terminal window. Use this property name if it's different from /backdrop/screen0/monitorDisplayPort-1/workspace0/last-image







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 12 '16 at 6:23

























                    answered Aug 11 '16 at 17:23









                    LucifLucif

                    9112




                    9112























                        0














                        Try



                        gsettings set org.gnome.desktop.background picture-uri file:///your/picture/location.jpg


                        The file:// is required.






                        share|improve this answer


























                        • I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                          – John
                          Nov 22 '13 at 1:50
















                        0














                        Try



                        gsettings set org.gnome.desktop.background picture-uri file:///your/picture/location.jpg


                        The file:// is required.






                        share|improve this answer


























                        • I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                          – John
                          Nov 22 '13 at 1:50














                        0












                        0








                        0







                        Try



                        gsettings set org.gnome.desktop.background picture-uri file:///your/picture/location.jpg


                        The file:// is required.






                        share|improve this answer















                        Try



                        gsettings set org.gnome.desktop.background picture-uri file:///your/picture/location.jpg


                        The file:// is required.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 22 '13 at 2:45









                        Braiam

                        52.4k20138223




                        52.4k20138223










                        answered Nov 22 '13 at 0:40









                        ChesterChester

                        720313




                        720313













                        • I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                          – John
                          Nov 22 '13 at 1:50



















                        • I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                          – John
                          Nov 22 '13 at 1:50

















                        I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                        – John
                        Nov 22 '13 at 1:50





                        I tried it without any luck. Since I'm running XFCE, do I even have gsettings? The syntax of the command makes sense to me, but I don't know how to make it apply to Xubuntu.

                        – John
                        Nov 22 '13 at 1:50











                        0














                        Don't use cron. Instead use the startup script. Although you can use cron but I don't prefer it in this situation because it is user specific.



                        Do it this way:



                        sudo vi /etc/rc.local


                        add the following at the end of file



                        sudo -u YOURUSERNAME -g $( id -g YOURUSERNAME ) xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                        and make sure you replace YOURUSERNAME with your current user. And replace /usr/share/backgrounds/xfce/xfce-blue.jpg by the real path of the new background image and make sure your user has permission to read the image






                        share|improve this answer



















                        • 1





                          Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                          – Stéphane Gourichon
                          Oct 31 '16 at 11:10
















                        0














                        Don't use cron. Instead use the startup script. Although you can use cron but I don't prefer it in this situation because it is user specific.



                        Do it this way:



                        sudo vi /etc/rc.local


                        add the following at the end of file



                        sudo -u YOURUSERNAME -g $( id -g YOURUSERNAME ) xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                        and make sure you replace YOURUSERNAME with your current user. And replace /usr/share/backgrounds/xfce/xfce-blue.jpg by the real path of the new background image and make sure your user has permission to read the image






                        share|improve this answer



















                        • 1





                          Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                          – Stéphane Gourichon
                          Oct 31 '16 at 11:10














                        0












                        0








                        0







                        Don't use cron. Instead use the startup script. Although you can use cron but I don't prefer it in this situation because it is user specific.



                        Do it this way:



                        sudo vi /etc/rc.local


                        add the following at the end of file



                        sudo -u YOURUSERNAME -g $( id -g YOURUSERNAME ) xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                        and make sure you replace YOURUSERNAME with your current user. And replace /usr/share/backgrounds/xfce/xfce-blue.jpg by the real path of the new background image and make sure your user has permission to read the image






                        share|improve this answer













                        Don't use cron. Instead use the startup script. Although you can use cron but I don't prefer it in this situation because it is user specific.



                        Do it this way:



                        sudo vi /etc/rc.local


                        add the following at the end of file



                        sudo -u YOURUSERNAME -g $( id -g YOURUSERNAME ) xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitor0/image-path --set /usr/share/backgrounds/xfce/xfce-blue.jpg


                        and make sure you replace YOURUSERNAME with your current user. And replace /usr/share/backgrounds/xfce/xfce-blue.jpg by the real path of the new background image and make sure your user has permission to read the image







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Feb 13 '14 at 17:13









                        kamilkamil

                        5,31062954




                        5,31062954








                        • 1





                          Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                          – Stéphane Gourichon
                          Oct 31 '16 at 11:10














                        • 1





                          Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                          – Stéphane Gourichon
                          Oct 31 '16 at 11:10








                        1




                        1





                        Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                        – Stéphane Gourichon
                        Oct 31 '16 at 11:10





                        Why was this downvoted? The OP requested a way that effects at reboot. Perhaps the OP needed to apply it to several users, but hasn't explicitly stated so. This answer seems okay (haven't tested it, though). So, why the downvote?

                        – Stéphane Gourichon
                        Oct 31 '16 at 11:10











                        0














                        to set xfce background color in bash script:



                        d=0; r=$d; g=$d; b=$d; 
                        xfconf-query -c xfce4-desktop
                        -p /backdrop/screen0/monitor0/workspace0/color1
                        -s $r -s $g -s $b -s 65535


                        colors:



                        black: d=0;
                        white: d=65535;
                        red: r=65535; g=0; b=0;


                        etc.



                        r g b are 16bit decimal RGB components.



                        65535 = 255*257. 255 = 0xFF in hex.



                        to convert from 8bit hex color code, to 16bit decimal RGB components:



                        x='C31717' # dark red
                        r=$((16#${x:0:2} * 257))
                        g=$((16#${x:2:2} * 257))
                        b=$((16#${x:4:2} * 257))


                        if background color does not change,
                        set image style to none



                        xfconf-query -c xfce4-desktop 
                        -p /backdrop/screen0/monitor0/workspace0/image-style
                        -s 0


                        .... and set fill style to solid



                        xfconf-query -c xfce4-desktop 
                        -p /backdrop/screen0/monitor0/workspace0/color-style
                        -s 0


                        to set a different color for every workspace:



                        xfconf-query -c xfce4-desktop 
                        -p /backdrop/single-workspace-mode
                        -s false

                        i=1; # workspace id
                        xfconf-query -c xfce4-desktop
                        -p /backdrop/screen0/monitor0/workspace$i/image-style
                        -s 0
                        xfconf-query -c xfce4-desktop
                        -p /backdrop/screen0/monitor0/workspace$i/color-style
                        -s 0
                        x=0; r=$x; g=$x; b=$x;
                        xfconf-query -c xfce4-desktop
                        -p /backdrop/screen0/monitor0/workspace$i/color1
                        -s $r -s $g -s $b -s 65535


                        nuff said ^^






                        share|improve this answer




























                          0














                          to set xfce background color in bash script:



                          d=0; r=$d; g=$d; b=$d; 
                          xfconf-query -c xfce4-desktop
                          -p /backdrop/screen0/monitor0/workspace0/color1
                          -s $r -s $g -s $b -s 65535


                          colors:



                          black: d=0;
                          white: d=65535;
                          red: r=65535; g=0; b=0;


                          etc.



                          r g b are 16bit decimal RGB components.



                          65535 = 255*257. 255 = 0xFF in hex.



                          to convert from 8bit hex color code, to 16bit decimal RGB components:



                          x='C31717' # dark red
                          r=$((16#${x:0:2} * 257))
                          g=$((16#${x:2:2} * 257))
                          b=$((16#${x:4:2} * 257))


                          if background color does not change,
                          set image style to none



                          xfconf-query -c xfce4-desktop 
                          -p /backdrop/screen0/monitor0/workspace0/image-style
                          -s 0


                          .... and set fill style to solid



                          xfconf-query -c xfce4-desktop 
                          -p /backdrop/screen0/monitor0/workspace0/color-style
                          -s 0


                          to set a different color for every workspace:



                          xfconf-query -c xfce4-desktop 
                          -p /backdrop/single-workspace-mode
                          -s false

                          i=1; # workspace id
                          xfconf-query -c xfce4-desktop
                          -p /backdrop/screen0/monitor0/workspace$i/image-style
                          -s 0
                          xfconf-query -c xfce4-desktop
                          -p /backdrop/screen0/monitor0/workspace$i/color-style
                          -s 0
                          x=0; r=$x; g=$x; b=$x;
                          xfconf-query -c xfce4-desktop
                          -p /backdrop/screen0/monitor0/workspace$i/color1
                          -s $r -s $g -s $b -s 65535


                          nuff said ^^






                          share|improve this answer


























                            0












                            0








                            0







                            to set xfce background color in bash script:



                            d=0; r=$d; g=$d; b=$d; 
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace0/color1
                            -s $r -s $g -s $b -s 65535


                            colors:



                            black: d=0;
                            white: d=65535;
                            red: r=65535; g=0; b=0;


                            etc.



                            r g b are 16bit decimal RGB components.



                            65535 = 255*257. 255 = 0xFF in hex.



                            to convert from 8bit hex color code, to 16bit decimal RGB components:



                            x='C31717' # dark red
                            r=$((16#${x:0:2} * 257))
                            g=$((16#${x:2:2} * 257))
                            b=$((16#${x:4:2} * 257))


                            if background color does not change,
                            set image style to none



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/screen0/monitor0/workspace0/image-style
                            -s 0


                            .... and set fill style to solid



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/screen0/monitor0/workspace0/color-style
                            -s 0


                            to set a different color for every workspace:



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/single-workspace-mode
                            -s false

                            i=1; # workspace id
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/image-style
                            -s 0
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/color-style
                            -s 0
                            x=0; r=$x; g=$x; b=$x;
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/color1
                            -s $r -s $g -s $b -s 65535


                            nuff said ^^






                            share|improve this answer













                            to set xfce background color in bash script:



                            d=0; r=$d; g=$d; b=$d; 
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace0/color1
                            -s $r -s $g -s $b -s 65535


                            colors:



                            black: d=0;
                            white: d=65535;
                            red: r=65535; g=0; b=0;


                            etc.



                            r g b are 16bit decimal RGB components.



                            65535 = 255*257. 255 = 0xFF in hex.



                            to convert from 8bit hex color code, to 16bit decimal RGB components:



                            x='C31717' # dark red
                            r=$((16#${x:0:2} * 257))
                            g=$((16#${x:2:2} * 257))
                            b=$((16#${x:4:2} * 257))


                            if background color does not change,
                            set image style to none



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/screen0/monitor0/workspace0/image-style
                            -s 0


                            .... and set fill style to solid



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/screen0/monitor0/workspace0/color-style
                            -s 0


                            to set a different color for every workspace:



                            xfconf-query -c xfce4-desktop 
                            -p /backdrop/single-workspace-mode
                            -s false

                            i=1; # workspace id
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/image-style
                            -s 0
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/color-style
                            -s 0
                            x=0; r=$x; g=$x; b=$x;
                            xfconf-query -c xfce4-desktop
                            -p /backdrop/screen0/monitor0/workspace$i/color1
                            -s $r -s $g -s $b -s 65535


                            nuff said ^^







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Oct 1 '18 at 9:50









                            Mila NautikusMila Nautikus

                            11




                            11























                                0














                                Setting image-path has no effect at my system (XFCE 4.12, Debian buster/sid).



                                I use the following for setting the background image of all workspaces:



                                xfconf-query --channel xfce4-desktop --list | grep last-image | while read path; do
                                xfconf-query --channel xfce4-desktop --property $path --set <path>
                                done





                                share|improve this answer




























                                  0














                                  Setting image-path has no effect at my system (XFCE 4.12, Debian buster/sid).



                                  I use the following for setting the background image of all workspaces:



                                  xfconf-query --channel xfce4-desktop --list | grep last-image | while read path; do
                                  xfconf-query --channel xfce4-desktop --property $path --set <path>
                                  done





                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    Setting image-path has no effect at my system (XFCE 4.12, Debian buster/sid).



                                    I use the following for setting the background image of all workspaces:



                                    xfconf-query --channel xfce4-desktop --list | grep last-image | while read path; do
                                    xfconf-query --channel xfce4-desktop --property $path --set <path>
                                    done





                                    share|improve this answer













                                    Setting image-path has no effect at my system (XFCE 4.12, Debian buster/sid).



                                    I use the following for setting the background image of all workspaces:



                                    xfconf-query --channel xfce4-desktop --list | grep last-image | while read path; do
                                    xfconf-query --channel xfce4-desktop --property $path --set <path>
                                    done






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Mar 16 at 13:58









                                    scaiscai

                                    1014




                                    1014






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f380550%2fxubuntu-how-to-set-the-wallpaper-using-the-command-line%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        數位音樂下載

                                        When can things happen in Etherscan, such as the picture below?

                                        格利澤436b