Skip to content

Instantly share code, notes, and snippets.

@Jacob-Vlijm
Last active August 29, 2015 14:07
Show Gist options
  • Save Jacob-Vlijm/816b64a056ac30d0bafc to your computer and use it in GitHub Desktop.
Save Jacob-Vlijm/816b64a056ac30d0bafc to your computer and use it in GitHub Desktop.
background script to password protect wallpaper changing in Ubuntu 14.04
#!/usr/bin/env python3
"""
Copyright (C) 2014 Jacob Vlijm
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 3 of the License, or 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, see <http://www.gnu.org/licenses/>.
"""
import time
import subprocess
set_password = "monkey"
key = "org.gnome.desktop.background picture-uri "
read = "gsettings get "+key; change = "gsettings set "+key
set_wallpaper = subprocess.check_output(["/bin/bash", "-c", read]).decode("utf-8").strip()
pass_window ='zenity --entry --entry-text="Enter password" --text="Enter password" --title="password" --hide-text'
def check_wall():
global set_wallpaper
curr_wallpaper = subprocess.check_output(["/bin/bash", "-c", read]).decode("utf-8").strip()
if curr_wallpaper != set_wallpaper:
subprocess.Popen(["/bin/bash", "-c", change+set_wallpaper])
try:
entered_password = subprocess.check_output(
["/bin/bash", "-c", pass_window]).decode("utf-8").strip()
except Exception:
entered_password = None
if entered_password == set_password:
subprocess.Popen(["/bin/bash", "-c", change+curr_wallpaper])
set_wallpaper = curr_wallpaper
else:
pass
while True:
check_wall()
time.sleep(3)
@Jacob-Vlijm
Copy link
Author

Mild password protection, meant for home use.
explantion: http://askubuntu.com/a/533537/72216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment