So sometimes when I connect my laptop to a monitor I like to use both screens at the same time but sometimes I just want to use the monitor. However when I close my laptop screen, my cursor can still go off my monitor screen and to the laptop. I tried messing around with the power management settings such as turning the screen off when lid is closed and connected to an external monitor, but that turns both screens off. Currently, whenever I close my laptop screen I have to go to settings and manually disable it. Is there a way to automate this process? I am currently using Lubuntu 21.04. The other answers I’ve found say to do nothing when the lid closes but I need to disable the screen when the lid’s closed.
2 Answers
A simple way (which I use) is to use Fn
key on your laptop keyboard, that manages external displays and switch to "external monitor only" before you close the lid.
A complex way (which I do not use) is to create a script.
How to run a script when the lid is closed?
Shortcut to switch displays

- 199
Here's how I have solved this problem. I use a keyboard shortcut to turn the laptop screen on and off.
First, run the following command to list your displays:
xrandr
Your laptop screen name should be something like LVDS1. You will need this name later.
Next, set a keyboard shortcut through Settings > Keyboard and click on the plus symbol near the lower right side of the window.
For the name, enter "screen off"
For the command, enter the following command but replace LVDS1 with the name of your laptop screen which may or may not be the same:
xrandr --output LVDS1 --off
Now, click on "Set Shortcut" and press CRTL+ALT+SHIFT+ (the last one is a down arrow if it's hard to see).
Finally, click "Add" to save the shortcut.
Now, set a shortcut to turn the screen back on.
Again, click the plus symbol to add another shortcut.
For the name, enter "screen on".
For the command, enter the following command but replace LVDS1 with the name of your laptop screen which may or may not be the same:
xrandr --output LVDS1 --auto
Now, click on "Set Shortcut" and press CRTL+ALT+SHIFT+ (the last one is an up arrow if it's hard to see).
Finally, click "Add" to save the shortcut.
You will need to log out and log back in to apply these shortcuts.
Also, you can use whatever keys you want. I chose the particular keys because they are unlikely to already be in use. If you set to a combination of keys that are already in use, the shortcut will not work.

- 43,546
- 8
- 97
- 150
F1...12
or double keyFn
+F1...12
shortcut to manage monitors? Scripting for automation, I get that part. Script that gets triggered by the lid and changes the monitor for you. – ordinary Apr 25 '21 at 14:30special keys
with monitor logo, for me, it's the same key asF7
. I should have commented under @shreyv post, sorry about that. But your answer seem to work for them, so it's all good. Have a great week. – ordinary Apr 26 '21 at 02:37