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
  • What could be done rather easily is have a small background script check the current wallpaper every x seconds, reset it if it is not the wallpaper you set. – Jacob Vlijm Sep 23 '14 at 18:28
  • Could U tell me how do I do that? – Andrè Paul Benoit Sep 23 '14 at 18:32
  • sure, I will try a few things, will get back to you. – Jacob Vlijm Sep 23 '14 at 18:33
  • 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
  • Andre, Does the solution for this question work for you? The comments under my answer have nothing to do with this question (/answer). Let me know. – Jacob Vlijm Sep 26 '14 at 19:56
  • @JacobVlijm Your "trick" Works fine for me. Thanks a lot for your patience!!!. The scripts Works if I run it manually. I can't make it work adding it to the startup applications. – Andrè Paul Benoit Sep 29 '14 at 15:24
  • Also: about startup applications: you could try adding time.sleep(60) right above set_wallpaper. There is a chance the system isn't ready yet for the gsettings-check. waiting a minute will possibly fix that. – Jacob Vlijm Sep 29 '14 at 15:56

1 Answers1

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"

Jacob Vlijm
  • 83,767
  • 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
  • @AndrèPaulBenoit I see, is it a "normal user" or a restricted user? And (silly question) you do keep the text file with the script? What happens if you run the "get" and "set" both on your own account? – Jacob Vlijm Sep 25 '14 at 15:48
  • @AndrèPaulBenoit Huuhh, I just realize, are we talking about this question???? It seems you are talking about this one: http://askubuntu.com/questions/527168/copy-the-unity-launcher-from-one-user-to-all-users/527882#comment720681_527882. You shouldn't use sudo on the gsettings set command. – Jacob Vlijm Sep 25 '14 at 16:58
  • @JacobVlijm if I do it under an Administrative session it Works fine. If I do it under a standard session it gives me the error. So... can you figure it out a way to solve this? :) :) – Andrè Paul Benoit Sep 25 '14 at 18:17
  • @EliahKagan It's essentially an implementation of Jacob's idea. Jacob did most of the work, found out which commands to use and so I felt that the script was better as a comment (not enough to be an answer on its own). I'd considered this idea from a comment on the question a better option, but couldn't figure out how to limit it only to backgrounds, so I gave up and forgot about it. – muru Oct 07 '14 at 22:10