Commands to run when Connecting HDMI
Solution 1
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.
Solution 2
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.
Related videos on Youtube
yurividal
Updated on September 18, 2022Comments
-
yurividal over 1 year
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?
-
user.dz almost 10 yearsFor Sound switch, See Switching to HDMI Audio when HDMI is plugged into a laptop (14.04)
-
-
yurividal almost 10 yearsOk, this helped me. Check my answer bellow. It is ALMOST done. Still need help with audio.
-
Korkel almost 10 yearsI have editted my answer with some steps for the audio problem you have. I hope it helps you.
-
yurividal almost 10 yearsI dont think you understand. I already have HDMI audio out. It works. But everytime i connect the cable, i have to MANUALLY go to system settings, audio, and change the output to HDMI. I would like to do it thru command line, to be able to automate it.
-
Korkel almost 10 yearsIsn't that possible with that program?