If making the screen sleep works, then almost certainly the toggle- script below will work:
#!/bin/bash
# --- set your monitor below
monitor=VGA-0
# ---
if [ -z "$(xrandr | grep $monitor | grep +)" ]; then
xrandr --output $monitor --auto
else
xrandr --output $monitor --off
fi
The script toggles on/off a monitor, to be set in the head of the script:
# --- set your monitor below
monitor=VGA-0
# ---
How to use
- Copy the script into an empty file, save it as
screentoggle.sh
- In the head of the script, set the monitor, like in the example. Use
xrandr
to find the name of your monitor
Add the script to a shortut key: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
sh /path/to/screentoggle.sh
Now if you toggle the screen off on one computer, it will be available on the other.
Note
You probably need to add (and run) the shortcut on both computers, since the screen will only switch if the screen is set to --auto
on at least one computer.