View Full Version : HDMI toggle for Laptops

28th January 2014, 01:40 AM

As i love minimal DE's or even just WM's, there is usualy no 'support' for automated HDMI activation.
So here is my scripted solution which does that with a single command.

Place the script in either $HOME/bin, $HOME/.local/bin (just you, might need to create the folder bin) or /usr/bin (everyone on the laptop, requires root access to place it there).
Dont forget to enable the execution flag (chmod +x hdmi.sh)
I would rename it back to just hdmi too, note that if you dont rename it, you must type hdmi.sh instead!

The script parses the possible resolutions for HDMI output, and lets you select among them.
Note that after 4 seconds of no user-action, it will continue and let xrandr select your HDMI output.

It will disable the laptopscreen, so it doesnt heat up (on older models) or saves battery if not connected with a power source.

Once you have seen the movie, simply type: hdmi reset
And it will disable hdmi output and go back to your laptop screen.

By "simply type" i mean within the 'run'-dialog (alt+f2 for example works in LXDE).

AFAIK: If you dont have set up your graphic card properly, there will be no sound!
Please see the according threads about how to install your graphic cards properly.
Also, this script is just to redirect the output, not about configuring your system.

If you would open a terminal and try it, it might look like:

✘ ~ $ hdmi
HDMI1 disconnected (normal left inverted right x axis y axis)
Please plug in your HDMI cable first and wait a few seconds (~7s)
+ ~ $ hdmi

Please select your HDMI mode or leave empty for auto
0) 1920x1080i
1) 1920x1080
2) 1280x720
3) 1440x576i
4) 1024x768
5) 1440x480i
6) 832x624
7) 800x600
8) 720x576
9) 720x480
+ ~ $ hdmi reset
xrandr: cannot find mode 1920x1080i
✘ ~ $

Hope this helps

Lets enjoy some HD movies :dance:

If hdmi reset doesnt go back to your prefered screen resolution, feel free to edit the script here:

MODE_LVDS=1024x768 # Change this value and comment out the line below
# if you have problems reseting your laptop screen
MODE_LVDS=$(xrandr|grep LVDS -A10|grep ^[[:space:]]|grep '*'|awk '{print $1}')

13th January 2015, 09:34 PM
To 'install' the script,

1) Change to the directory you downloaded hdmi.sh to.
2) copy paste this::

chmod +x hdmi.sh
mkdir $HOME/bin
mv hdmi.sh $HOME/bin/hdmi

3) Now, simply open a terminal and type:


hdmi reset

Hope this helps