Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Created November 17, 2011 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voyeg3r/1372927 to your computer and use it in GitHub Desktop.
Save voyeg3r/1372927 to your computer and use it in GitHub Desktop.
set mandatory background to gnome3
#!/bin/bash
# set mandatory wallpaper gnome3
# script to change kd3 3.5 wallpaper https://gist.github.com/1621547
# http://www.marcusmoeller.ch/misc/using-dconf-magic-to-change-background-image.html
# http://askubuntu.com/questions/52120/how-to-change-wallpapers-of-all-clients
# http://blog.sriunplugged.com/shell-scripting/automatic-desktop-wallpaper-changer/
# download
# wget -c https://raw.github.com/gist/1372927/ -O ~/mandatory-wallpaper.sh && chmod +x $_
# In Ubuntu 11.10 (or any GNOME 3 system), you should be able to do this with:
#
# Create a file /etc/dconf/profile/user with the contents:
#
# user
# site
#
# Make a default setting by creating a file /etc/dconf/db/site.d/background with
# the contents:
#
# [org/gnome/desktop/background]
# picture-uri='file:///usr/share/backgrounds/default.jpg'
#
# And finally make the default mandatory by creating
# /etc/dconf/db/site.d/locks/background with the contents:
#
# /org/gnome/desktop/background/picture-uri
#
# dconf settings need to be compiled to work so run sudo dconf update The first
# time you run this, you'll need to reboot to see the effect. Currently, there's
# a bug where users will still see the normal Background chooser; it just won't
# actually change the background.
# pega somente a extensão do arquivo arq
# echo ${arq##*.}
#wget -c http://ns223506.ovh.net/rozne/1ea221a3af6573ed5b35806d5823d3e0/wallpaper-740152.jpg -O /usr/share/backgrounds/default.jpg
# put this in your crontab -- crontab -e
# */15 * * * * /root/mandatory-wallpaper.sh
# get random file
FILE=`find /usr/share/backgrounds/ -type f -iregex ".*\.png\|.*\.jpg" | shuf -n1`
ON_USER=aluno #your username here
export DBUS_SESSION=$(grep -v "^#" /home/$ON_USER/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0)
# Change lines containing filename default.jpg
if [ `lsb_release -sc` == "oneiric" ] ; then
which dconf-editor &>/dev/null || apt-get install -y dconf-tools
[ -d /etc/dconf/profile ] || mkdir -p /etc/dconf/profile/
echo "user" > /etc/dconf/profile/user
echo "site" >> /etc/dconf/profile/user
[ -d /etc/dconf/db/site.d ] || mkdir -p /etc/dconf/db/site.d
echo "[org/gnome/desktop/background]" > /etc/dconf/db/site.d/background
echo "picture-uri='file://$FILE'" >> /etc/dconf/db/site.d/background
[ -d /etc/dconf/db/site.d/locks ] || mkdir -p /etc/dconf/db/site.d/locks/
echo "/org/gnome/desktop/background/picture-uri" > /etc/dconf/db/site.d/locks/background
dconf update
else
#gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set /desktop/gnome/background/picture_filename --type string "$file"
# Setting wallpaper default to all users
gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
-t str -s /desktop/gnome/background/picture_filename "$FILE"
# setting wallpaper to current user
sudo -u $ON_USER $DBUS_SESSION /usr/bin/gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$FILE"
sudo -u $ON_USER $DBUS_SESSION /usr/bin/gconftool-2 -t string -s /desktop/gnome/background/picture_options stretched
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment