0

I can't find a way to block users from changing my institutional wallpaper.
I have some PCs running Ubuntu 12.04 using Unity and others running Ubuntu 14.04 using Unity.
I need some kind of tweak/command/solution that blocks the option of changing the wallpaper in any possible way.

Please don't answer me with solutions under GNOME. These two don't work for me:
- How to restrict users on changing their wallpapers?
- Having trouble preventing users from changing wallpaper/settings

  • Would you consider the wallpaper to bounce back to the original to be an option? – Jacob Vlijm Sep 22 '14 at 20:03
  • I really need to use my institutional wallpaper. If a user changes it, and after a reboot my wallpaper comes back... it would be better than the actual situation. But that´s not what I really want/need – Andrè Paul Benoit Sep 23 '14 at 14:44
  • Nono, I actually mean within seconds. – Jacob Vlijm Sep 23 '14 at 18:14
  • mmmm... could be. It would be better than a family/child/pet wallpaper :) What do you suggest? I'm kind of newie on Ubuntu – Andrè Paul Benoit Sep 23 '14 at 18:25
  • 1
    One idea is to change the ownership and read write permission of the folder/file where the personal wallpaper configuration is stored for each user. This will prevent them changing the wallpaper (possibility other settings). However, I don't know where these settings are stored in the user's home. And I don't know if trying to change the wallpaper (when one doesn't have the permission) will crash anything. – user68186 Sep 23 '14 at 20:47
1

Although the suggestion below is far from "waterproof", it offers at least some "first-line" precautions against changing the wallpaper too easily.

You could make a small script to run in the background that checks every x seconds if the current wallpaper is still the wallpaper that you set in the first place.

  • The command to see (get) what is the current wallpaper:

    gsettings get org.gnome.desktop.background picture-uri
    

    If you run this in a terminal, you will get an output looking like:

    'file:///home/jacob/Thema/Bureaublad4/Frog.jpg'
    

We can make the script restore the original wallpaper if it has changed.

  • To set a specific wallpaper, the command is:

    gsettings set org.gnome.desktop.background picture-uri 'file:///home/jacob/Thema/Bureaublad4/Frog.jpg'
    

If we use these two in a python script, we could get the following (python3, 14.04):

#!/usr/bin/env python3

import time
import subprocess

set_wallpaper = "file:///home/jacob/Thema/Bureaublad4/Frog.jpg"

cmd2 = "gsettings set org.gnome.desktop.background picture-uri "+set_wallpaper
cmd1 = "gsettings get org.gnome.desktop.background picture-uri"

def check_wall():
    curr_wallpaper = subprocess.check_output(["/bin/bash", "-c", cmd1]).decode("utf-8").strip()
    if curr_wallpaper == "'"+set_wallpaper+"'":
        pass
    else:
        subprocess.Popen(["/bin/bash", "-c", cmd2])

while True:
    check_wall()
    time.sleep(10)

The only difference for 12.04 is the shebang: 12.04 does not come with python3 by default, so the shebang should be:

#!/usr/bin/env python

How to use

  • copy the script into an empty file. Change the wallpaper line (after set_wallpaper =) into the path to your wallpaper image (starting with file://, like in the example). Save it as something.py.

  • run it by the command:

    python3 /path/to/something.py
    

    or (12.04)

    python /path/to/something.py
    

If all works as you wish, add it to your startup applications: Dash > "Startup Applications" > "Add"

  • This resets the wallpaper every 10s, if I read that correctly? Python seems overkill. – muru Sep 23 '14 at 20:40
  • @muru true (10 seconds) and only if it has changed (of course). Why overkill? It is just a few lines. For me python is a comfortable and fast way to write. It does its job. – Jacob Vlijm Sep 23 '14 at 20:46
  • It does, but bash is considerably more simple and concise (and so, IMHO, easier to understand for an end-user), I'd say. No need to change things for 12.04/14.04, either. – muru Sep 23 '14 at 20:51
  • @muru Actually an interesting discussion. In my experience, python is almost plain English. I do realize however that it is more verbose, which is no problem in more object-orientated programming, but not really "fancy" on AU in general :) – Jacob Vlijm Sep 23 '14 at 20:57
  • Jacob. I'm having problems running the script. It doesn't work. I tried to write U an Inbox but I didn't know how :). I tried also in terminal running the commands in root mode under user session... When I run the "get" sentence in terminal it Works fine. When I run de set it gives me (the same error that the script) "dconf-WARNING **: failed to commit changes to dconf: connection is closed". – Andrè Paul Benoit Sep 25 '14 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.