You are not logged in.

#1 2019-07-08 02:46:09

abhixec
Member
Registered: 2019-07-08
Posts: 26

[SOLVED]How to detect HDMI cable?

Hi all,

I have a Thinkpad X1Extreme. I set it up using the X1E arch wiki.
Every time I want to hook up a monitor I have to run

 $ intel-virtual-output -f 

and then run xrandr command to setup the monitor.

Is there a command that I can run to detect when HDMI cable is connected/disconnected?

I tried to go the udev route but when I run

 $ udevadm monitor 

and connect and disconnect the HDMI cable I don't see anything.

At this point I am not sure, how to proceed. Any pointers/help would be greatly appreciated smile

Thanks!

EDIT: my post is how I solved this problem.

Last edited by abhixec (2019-09-24 20:37:49)

Offline

#2 2019-07-08 04:18:11

JeanLucJ
Member
Registered: 2019-03-08
Posts: 59

Re: [SOLVED]How to detect HDMI cable?

Hello,

It's not exactly your situation, but it's close : did you look at this topic?

Also, did you run udevadm as root?

Regards,

Last edited by JeanLucJ (2019-07-08 04:20:04)

Offline

#3 2019-07-08 07:01:52

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Offline

#4 2019-07-11 03:57:28

abhixec
Member
Registered: 2019-07-08
Posts: 26

Re: [SOLVED]How to detect HDMI cable?

I have looked at this before but don't know why I didn't give it a try tongue
Thanks a lot this works like a charm.

Offline

#5 2019-07-11 06:13:52

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Re: [SOLVED]How to detect HDMI cable?

Cool.
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#6 2019-09-24 16:58:43

xlith
Member
Registered: 2019-09-24
Posts: 3

Re: [SOLVED]How to detect HDMI cable?

Hello @abhixec,

I have exactly the same problem. Could you tell me how you solved? I tried "x-on-resize --config "intel-virtual-output -f" --start" but looks like something is wrong.

Offline

#7 2019-09-24 18:46:09

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Re: [SOLVED]How to detect HDMI cable?

"something is wrong" is not a useful problem description, please do yourself a favor and read up http://www.catb.org/~esr/faqs/smart-questions.html

a) does "intel-virtual-output -f" do what you want?
b) if you just run "x-on-resize", does it print config/resize events in response to whatever you do hoping to trigger them?
c) are there any adapters or docks involved? If so: how exactly.

Offline

#8 2019-09-24 18:55:25

xlith
Member
Registered: 2019-09-24
Posts: 3

Re: [SOLVED]How to detect HDMI cable?

Hello again,

a) does "intel-virtual-output -f" do what you want?
  No, It doesn't.

b) if you just run "x-on-resize", does it print config/resize events in response to whatever you do hoping to trigger them?
  No, It doesn't. I plugged in and out my HDMI cable but nothing happens.

c) are there any adapters or docks involved? If so: how exactly.
  No there is not.

Sorry if my way of asking the question is inconvenient. But as you see there is not much I can share. That's why I asked abhixec how he/she solved own problem. I am not a very skilled user. So I thought maybe I couldn't figure out "x-on-resize" usage correctly.

Offline

#9 2019-09-24 19:09:40

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Re: [SOLVED]How to detect HDMI cable?

a) then you're *obviously* not facing the same issue at all. Please  don't hijack random threads.

Open a new thread, but I'd guess you're probably on a wayland session? So please start w/ that and provide the output of "loginctl session-status", if it's indeed an X11 session, your xorg log and the output of "xrandr -q" w/ and w/o the attached HDMI device.

Also this is not about being "inconvenient", but informative.
You falsely and probably out of thin air concluded that you're facing the same problem as the OP and then asked him how to please solve your problem which you've actually not provided any information about.
IOW you're asking us to dodge your false claim, guess what your problem actually is and solve it for you.

Offline

#10 2019-09-24 20:02:08

abhixec
Member
Registered: 2019-07-08
Posts: 26

Re: [SOLVED]How to detect HDMI cable?

So this is what I am currently doing :

monitor.sh
#!/bin/bash
intel_pid=$(pidof intel-virtual-output)
if [ ! -z $intel_pid ]; then
kill -9 $intel_pid
fi
intel-virtual-output -f &
sleep 10
is_connected=$(xrandr -q | grep VIRTUAL3 | head -n 1 | cut -d ' ' -f 2)  #tells if VIRTUAL3 (in my case the HDMI) is connected
display_option=$(xrandr -q | grep VIRTUAL3 | head -n 2 | sed -n 2p| awk '{$1=$1};1'| cut -d ' ' -f1) # gets the max resolution
if [ $is_connected == "connected" ]; then
xrandr --output VIRTUAL3 --mode $display_option --right-of eDP1
elif [ $is_connected == "disconnected" ]; then
xrandr --auto
fi

Note the VIRTUAL3 and eDP1 is what I want in my use case it could be something else for you.
and I run x-on-resize like this:

$ x-on-resize --config ~/.monitor.sh --start  

I run that command from my xinitrc in the background.
Hope that helps

xlith wrote:

Hello again,
b) if you just run "x-on-resize", does it print config/resize events in response to whatever you do hoping to trigger them?
  No, It doesn't. I plugged in and out my HDMI cable but nothing happens.

x-on-resize wouldn't detect HDMI changes unless you run intel-virtual-output
Reason it doesn't is because the HDMI is connected to the Nvidia GPU, the command above connect intel's gpu to the HDMI instead of Nvidia's.

Last edited by abhixec (2019-09-24 20:44:40)

Offline

#11 2019-09-24 20:20:22

xlith
Member
Registered: 2019-09-24
Posts: 3

Re: [SOLVED]How to detect HDMI cable?

Hello seth,

I already regret that I asked. But I need to write something for the last time. I don't that I out of thin air concluded anything.

I have MSI GS 65 laptop and both computers have a hybrid graphic.

Also every time I want to hook up a monitor I have to run

$ intel-virtual-output -f

and then run xrandr command to set up the monitor.

I was also looking for a command that I can detect when HSMI cable is connected/disconnected.

I also tried to go the udev route but when I run

$ udevadm monitor

and connect and disconnect the HDMI cable I also don't see anything.

At this point, I was also not sure, how to proceed.

But after this point, my route may be different because I couldn't run x-on-resize. I read man page. I read the developer's blog. And I couldn't find any usage examples. I tried to run it as I shared above but didn't work either. And also if you read my posts there is nothing about you solving my problem. I only asked abhixec how he solved his own problem in more detailed so I can try the same solution on my computer and see if that works.

Anyway as I write at the beginning I already regret asking anything. I would rather use "intel-virtual-output -f "every time I need instead of having this meaningless conversation.
Sorry for my bad English.
Have a nice day.
Thanks...

Offline

#12 2019-09-24 20:21:39

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Re: [SOLVED]How to detect HDMI cable?

Also every time I want to hook up a monitor I have to run

$ intel-virtual-output -f

and then run xrandr command to set up the monitor.

You just said that does NOT do what you want???

Offline

#13 2019-09-24 20:31:14

abhixec
Member
Registered: 2019-07-08
Posts: 26

Re: [SOLVED]How to detect HDMI cable?

xlith wrote:

Hello seth,

I already regret that I asked. But I need to write something for the last time. I don't that I out of thin air concluded anything.

I have MSI GS 65 laptop and both computers have a hybrid graphic.

Also every time I want to hook up a monitor I have to run

$ intel-virtual-output -f

and then run xrandr command to set up the monitor.

I was also looking for a command that I can detect when HSMI cable is connected/disconnected.

I also tried to go the udev route but when I run

$ udevadm monitor

and connect and disconnect the HDMI cable I also don't see anything.

At this point, I was also not sure, how to proceed.

But after this point, my route may be different because I couldn't run x-on-resize. I read man page. I read the developer's blog. And I couldn't find any usage examples. I tried to run it as I shared above but didn't work either. And also if you read my posts there is nothing about you solving my problem. I only asked abhixec how he solved his own problem in more detailed so I can try the same solution on my computer and see if that works.

Anyway as I write at the beginning I already regret asking anything. I would rather use "intel-virtual-output -f "every time I need instead of having this meaningless conversation.
Sorry for my bad English.
Have a nice day.
Thanks...

hey xlith,
refer to my postmy post that should solve your problem.
Also don't take things offensively. seth was only trying to help you because the more details you give us the better we can help with the problem otherwise it would make it really hard to help you out. Since we don't know exactly what is happening!
I know it can be frustrating when you try lots of things, but understand that people may not know what you have done/not done unless you say. It will easier to empathize if you did give as much detail as possible.
Anyways refer to my post and let us know if you have more questions.

seth wrote:

Also every time I want to hook up a monitor I have to run

$ intel-virtual-output -f

and then run xrandr command to set up the monitor.

You just said that does NOT do what you want???

I think he meant in the context of

x-on-resize --config "intel-virtual-output -f" --start

it isn't doing anything.

Last edited by abhixec (2019-09-24 20:36:30)

Offline

#14 2019-09-24 20:55:38

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 68,315

Re: [SOLVED]How to detect HDMI cable?

abhixec wrote:

I think he meant in the context of

x-on-resize --config "intel-virtual-output -f" --start

it isn't doing anything.

I will not speculate as to what he might have meant, but unless he meant something different than he responded to (b), ie.

b) if you just run "x-on-resize", does it print config/resize events in response to whatever you do hoping to trigger them?
  No, It doesn't. I plugged in and out my HDMI cable but nothing happens.

ie. x-on-resize not reacting to un/plugs at all (ie. printing the event) that's gonna be the next bump.
There might be a severe language barrier, but if he fundamentally doesn't understand what anybody here (incl. him) is writing, this is a pointless exercise.
In that case asking in native language (referencing this thread) might  shed some light.

Offline

Board footer

Powered by FluxBB