Commands to run when Connecting HDMI
Everytime I connect my pc to my tv using my HDMI cable (to watch my movies), I have to manually go to:
1- Monitors, to select "mirror" screen to HDMI 2- Sound, to select the HDMI as default sound output 3- Screen Off an Lock, to avoid screen locking while watching a video.
Is there a way I can automate this? Or at least write a script with commands that will do this. (I could manually run a script every time I connect my HDMI, and then run annother one to undo the changes later)
How can I do these actions from a Command Line?
Solution 1:
xrandr can handle the display, but I'm not sure what would handle the audio portion.
Something like
#!/bin/bash
xrandr --output HDMI2 --primary --auto
should switch to HDMI2 as primary screen. You'll need to read some man-pages though and make sure the script works right for your configuration.
Solution 2:
Try the program Disper:
This can be installed in a Terminal (CTRL+ALT+T).
sudo add-apt-repository ppa:disper-dev/ppa
sudo apt-get update
sudo apt-get install disper
Then do the following:
disper -l
Open Nvidia X Server Setting, you should see the external display is added. Configure TwinView should get you a dual monitor set up for your laptop. That's it.
Edit:
For the audio problem, do the following:
Open a Terminal (CTRL+ALT+T) and enter the following.
sudo apt-get install pavucontrol
Install the alsa mixer daily builds, what you can get here.
Open Pulse audio, go to the configuration tab in the drop down menu there is an option for HDMI audio out.