Tech
Setting a webcampak capture as a dynamic wallpaper on Linux
The script available below has been created for Gnome desktop environement, this is the environment available by default with Ubuntu.
All necessary actions will be performed using a console, you could also do the same with any graphical interface.
First open a console, with Gnome go to “Applications” > “Accessories” > “Console”, then type in the following commands :
#> mkdir Pictures
#> cd Pictures
#> mkdir wallpaper
#> cd wallpaper
Then check the full path of the directory you are currently into pwd :
#> pwd
/home/maison/Images/wallpaper
Write down the result of the above command, you will need it for the script :
#> gedit script.sh
Copy/paste the following code into the text editor :
#!/bin/bash
wget http://mon_url/live/webcam-1280x1024.jpg -O /home/maison/Images/wallpaper/Wallpaper_$(date +%Y%m%d%s).jpg
gconftool-2 -t str --set /desktop/gnome/background/picture_filename /home/maison/Images/wallpaper/Wallpaper_$(date +%Y%m%d%s).jpg
gconftool-2 -t str --set /desktop/gnome/background/picture_options scaled
Replace the url with your own picture url (mon_url/live/webcam-1280x1024.jpg), the change the path by replacing /home/maison/Images/wallpaper with the result of “pwd” command.
Save your file and quit gedit.
You can test your script with the following command :
bash script.sh
Your wallpaper should be replaced with a picture from your webcampak.
We then need to add a task within GNU/Linux crontab. Cron will take care of executing the script regularly (i.e. every 10 minutes).
crontab -e
Add the following line at the end of the script (replace directory to match your environement)
*/10 * * * * bash /home/Utilisateur/Images/wallpaper/script.sh > /home/Utilisateur/Images/wallpaper/wallpaper.log
Save and quit, your system will now automatically refresh your wallpaper.
Cet article a été automatique importé de notre ancien blog, merci de nous excuser pour tout problème d’affichage ou image manquante.
TECH