Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: HowTo: Wallpaper Changer for Xubuntu (Xfce)

  1. #1
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    HowTo: Wallpaper Changer for Xubuntu (Xfce)

    Hiya

    I have switched to Xubuntu a few months ago coming from Kubuntu. I liked there the (already available) option of setting up a list of image files and have them randomly displayed. This was one of the things I have missed so far in Xfce.

    As former Windows user I have aquired quite a large number of wallpapers (thx goes to HTTrack for downloading over 18k wallpapers...) and I like to have them displayed on the background. That's more or the less the only major change I do on a theme (if you can call that a change...)

    Anyway, thx to TheSheep from the #xubuntu channel on irc.freenode.org (he's a really helpful guy and has helped me countless time) I can provide you with this small howto.

    (1) Build your list of images
    - Right-click on your desktop
    - Select "Desktop settings"
    - Make sure that "Allow Xfce to manage the desktop" and "Show Image" boxes are checked (they are by default)
    - Click then on "New list"
    - Add the image files by clicking on the "+"
    - Once you are done, save the list
    - You are back in the previous screen and your newly created list should be selected in the "File" input box
    - Then close that interface

    (2) Creating Cronjob for Wallpaper Changer functionality
    - Open a terminal
    - If you already have a "cron-command" file for your user, open that one in a text editor if not execute this command: nano cron.txt
    - Enter the following two lines to the cron file:
    # Reload Background Image
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * killall -USR1 xfdesktop
    This will change the image every 5 minutes. You can also change the behaviour. Please refer here: Cron HowTo
    - Exit nano by pressing ctrl-x
    - Press [y] to save the file

    (3) Adding the Cronjob for Wallpapcher Changer
    - Before you overwrite any existing user cronjobs please execute this command:
    crontab -l
    If nothing is returned then it's fine to add you wallpaper changer script!
    - Add the cron.txt file that we created under section (2) by issuing the following command in the shell:
    crontab cron.txt
    - Enter now again crontab -l and you should have this output:
    hyper@xubi:~$ crontab -l
    # Reload Background Image
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * killall -USR1 xfdesktop
    (4) That's it
    - Get some coffee or whatever and enjoy your desktop bakground wallpaper changer

  2. #2
    Join Date
    Oct 2005
    Beans
    36

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    ah, nice one, I will try it later night.. this is 1 hell of the hack I want to have in xfce..

  3. #3
    Join Date
    Nov 2006
    Location
    NRW, Germany
    Beans
    21
    Distro
    Xubuntu 7.04 Feisty Fawn

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    Thanks for the hint, works out great.

    Just as a little addition, the crontab line could be also written as:
    Code:
    */5 * * * * killall -USR1 xfdesktop
    to change the background every 5 minutes

  4. #4
    Join Date
    Nov 2006
    Location
    NRW, Germany
    Beans
    21
    Distro
    Xubuntu 7.04 Feisty Fawn

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    somebody might find this script useful.
    you will need to have at least php4-cli installed to run it.

    PHP Code:
    #!/usr/bin/env php
    <?php

    /**
     * xfce4-background-changer
     *
     * a bit of automating for the xfce4 desktop
     *
     * it recreates the background list automaticly as I found the gui
     * not comfortable enough and "reloads" afterwards the desktop causing a
     * new background picture being randomly displayed
     * you can put it in your crontab to change the background every
     * now and then (man crontab)
     * f.e. "* * * * * ~/scripts/xfce4-background-changer.php"
     * or you might place a desktop starter to change the background
     * everytime you activate the starter
     *
     * PHP version 4 and 5
     *
     * LICENSE:
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     * 
     * @author    David Uhlig <david.uhlig@googlemail.com>
     * @copyright 2007 David Uhlig <david.uhlig@googlemail.com>
     * @license   http://www.gnu.org/licenses/gpl.txt GNU GPL
     * @version   1.0  
     */
     
    // {{{ settings

    /**
     * home
     */
    define('HOME'$_ENV['HOME']);

    /**
     * directories with wallpapers, or wallpaper files
     * use absolute path, seperate by comma
     * !!! no closing slash for directorys
     * !!! directories will _not_ be walked through recursive 
     */
    define('BACKGROUND_DIR'HOME '/.wallpaper');

    /**
     * absolute path to your background list as choosen via 
     * Applications / Settings / Background -> Picture -> File 
     */
    define('BACKGROUND_LIST'HOME '/.config/xfce4/desktop/hintergrundbilder.list');

    // }}}

    // {{{ functions

    /**
     * rewriteBackgroundList
     */
    function rewriteBackgroundList()
    {
        
    $res fopen(BACKGROUND_LIST"w");
        
    fwrite($res"# xfce backdrop list\n");
        
        if (
    $res === false)
        {
            return;
        }
        
        
    $aryBackgroundDir split(","BACKGROUND_DIR);    
        
        foreach (
    $aryBackgroundDir as $strBackgroundDir)
        {
            if (
    is_dir($strBackgroundDir))
            {
                
    $aryDir scandir($strBackgroundDir);
                            
                foreach (
    $aryDir as $strFile)
                {
                    if (
    is_dir($strFile))
                    {
                        continue;
                    }
                    if (
    $strFile == "." || $strFile == "..")
                    {
                        continue;
                    }
                    if (!
    file_exists($strBackgroundDir "/" $strFile))
                    {    
                        continue;
                    }
                                    
                    
    fwrite($res$strBackgroundDir "/" $strFile "\n");
                }    
            }
            elseif (
    file_exists($strBackgroundDir))
            {
                
    fwrite($res$strBackgroundDir);
            }
        }
        
        
    fclose($res);
    }

    /**
     * php4 compat for scandir
     * taken from php.net/scandir user comments
     */
    if(!function_exists('scandir')) {
        function 
    scandir($strDir$intSortorder 0) {
            if (
    is_dir($strDir)) {
                
    $strDirlist opendir($strDir);
                while ((
    $strFile readdir($strDirlist)) !== false) {
                    if(!
    is_dir($strFile)) {
                        
    $aryFiles[] = $strFile;
                    }
                }
            (
    $intSortorder == 0) ? asort($aryFiles) : rsort($aryFiles);
            return 
    $aryFiles;
            } else {
                return 
    false;
            }
        }
    }

    // }}}

    // {{{ main

    rewriteBackgroundList();
    exec("killall -USR1 xfdesktop");

    // }}}
    ?>
    Last edited by eteran; January 14th, 2007 at 10:40 PM.

  5. #5
    Join Date
    Jun 2006
    Beans
    9

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    Try gaze.sourceforge.net it's a nice wallpaper switcher that fetches images from flickr. Just works with gnome, though

  6. #6
    Join Date
    Jul 2006
    Beans
    9

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    Thank you, this is somewhat sweet. I say "somewhat" because if I'm not logged in cron sends the following message (25 of them last night alone <g>):

    Cron <cmo@codybeau> killall -USR1 xfdesktop
    xfdesktop: no process killed

    Know of a way around this and yet allow switching images? i *REALLY* like the changing wallpaper.

  7. #7
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    could the output maybe piped to /dev/null?

    e.g.

    Code:
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * killall -USR1 xfdesktop | /dev/null
    I've never tried that above so I have no clue whether this works... just a suggestion that you may want to try.

  8. #8
    Join Date
    Jul 2006
    Beans
    9

    Thumbs down Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    Quote Originally Posted by hyper_ch View Post
    could the output maybe piped to /dev/null?

    e.g.

    Code:
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * killall -USR1 xfdesktop | /dev/null
    I've never tried that above so I have no clue whether this works... just a suggestion that you may want to try.
    Thanks for writing ! Yes, you're right that you might be wrong <g>. I've thought it over and this works:

    # Reload Background Image
    */30 * * * * killall -USR1 xfdesktop > /dev/null 2>&1

  9. #9
    Join Date
    Jul 2006
    Beans
    39

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    how can i get this to work on gnome?

  10. #10
    Join Date
    Jul 2006
    Beans
    9

    Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)

    You can't. Use this instead: http://ubuntuforums.org/showthread.php?t=18163

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

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