Turn the desktop black of all (possibly additionally) connected screens
Not sure if the solution below is sufficient to you, but as an (additional?) measure, it should help to make it at least more difficult to access the system.
As usual, it is mostly the combination of measures that makes incidental access more difficult. It could e.g be made more difficult by:
- adding a password to "un-" blacken the screen
- a log file to keep track of changes in screen brightness
- change the default shortcut key to open the terminal, so "blindly" typing commands is unlikely.
At the same time, I am pretty sure however that someone with real knowledge will always find a way, if the time is sufficient, unless you completely block all connecting options by (e.g.) building the system inside some kind of a box. Only think of restarting from an external medium.
The bottom line is that you'll have to decide if it is useful to you
Exists of a background script that once per second:
- checks all connected screens (also newly connected ones)
- checks if all screens are set to brightness
1.0, see further below)
- sets all screens to brightness
- the script reads the desired brightness value from a hidden file in your home directory
- the solution includes two shortcut key combinations to set that value in the file to
1.0 (normal use) or
0.0 (black screen).
As mentioned, the scortcut keys can be made to use a password (in plain text). Please mention it if you find it usesfull.
screen_brightness = os.environ["HOME"]+"/.screenset.txt"
if not os.path.exists(screen_brightness):
return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8")
return [l.split() for l in screendata.splitlines() if " connected" in l]
curr_set = read_set()
screendata = get("xrandr --verbose")
n_screens = screendata.count(" connected")
n_dimmed = screendata.count("Brightness: "+curr_set)
if n_dimmed != n_screens:
screens = find_screens(screendata)
for scr in screens:
subprocess.Popen(["xrandr", "--output", scr, "--brightness", curr_set])
How to set up
- Copy the script into a empty file, save it as
Create two shortcut keys (commands):
echo 1.0 > ~/.screenset.txt
echo 0.0 > ~/.screenset.txt
Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the commands to two different shortcut keys.
Test run the script with the command:
If all works fine, add it to your startup applications: Dash > Startup Applications > Add the command:
As mentioned, the script / setup can be made more secure with a (plain text) password and/or a log file. Please look if this is a useful direction.