Skip to content

Turn off laptop display when plugged to an external monitor

I want to automatically turn off the laptop display when the laptop is plugged to an external monitor (i.e. use the external monitor as the only display). Often, I "dock" my work laptop onto my home setup and work on it using my main desktop monitor. How to best achieve this? I'm on Arch Linux.

Several related questions:

  • Setting the brightness to 0 is not the same as turning off the display completely, right? There might be implications in terms of disabling the display so that it uses no power at all vs. brightness "off" resulting in very little power usage but still using power nonetheless, for example.

  • It doesn't seem like DPMS is appropriate in this situation. So I scripted something with xrandr. Is there a better solution? Could it be added to a hook, e.g. a udev hook?

  • How do monitor names referred to by xrandr work, e.g. HDMI1, DP2, VIRTUAL1, etc.? I scripted something basic in the past involving the names and on rare occasions I needed to change the names used by the script as xrandr gave them different names after some time. Not sure if it has to do with unplugging and plugging back an HDMI cable to the monitor or switching out a graphics card, for example.

  • Is there a better way to pragmatically tell if a screen is on/off so you can toggle it? Currently I'm following this solution but is pretty ghetto.

Much appreciated.

Edited 17 Feb 2019. We only hold this version.

1 points1 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
1 · 100% up
Kind
Text
ID
argwps

Author

46
posts
45
comments
0
media
View profile

1 comment

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.