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:
Quote:
# 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:
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:
- Enter now again crontab -l and you should have this output:
Quote:
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 :)
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.. :D
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
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");
// }}}
?>
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 :|
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.
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.
Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)
Quote:
Originally Posted by
hyper_ch
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
Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)
how can i get this to work on gnome?
Re: HowTo: Wallpaper Changer for Xubuntu (Xfce)