New Stimulus for Connecting external displays

Bug #1040649 reported by Felipe 'chronos' Prenholato
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Cuttlefish
Incomplete
Wishlist
Unassigned

Bug Description

Hello, this is a really nice app, however I missed some stymulus.

Monitor is Plugged / Unplugged:
What to do: It should watch when a new monitor (via VGA or HDMI) is plugged or not and we run a command for each action.
Why: Today, KDE offer window to configure monitors, but not save a default for each monitor I plug in. At my work a have one HP running at 1366x720, at home a Dell running at 1440x900. KDE don't regonized it, but when I run a command called disper (disper -e -t left when plugged, disper -s when unplugged) I have what I need.

[...]

Thx!

Edited by Alex: You requested several things in one bug report. Thus in order to keep the reports tidy and to prevent total chaos I splitted them into several bug reports ;-)

Tags: wishlist
Alex (noneed4anick)
description: updated
Changed in cuttlefish:
importance: Undecided → Wishlist
status: New → Incomplete
Revision history for this message
Alex (noneed4anick) wrote :

Hey Felipe,

thanks for your feedback. The idea of this stimulus is reasonable, but I have to do some research in order to check, if realizing this is possible at all. I'm pretty sure this wont be easily to achieve, because depending on the driver of the graphic card the data structures for the connected displays differ.

For now I have checked this on two machines, one with intel and one with nvidia graphics and there doesn't seem to be a interface that is valid for both. In fact I only found an interface for the intel card.

Revision history for this message
Felipe 'chronos' Prenholato (chronossc) wrote :

Hello Alex.

Yes, we have these problems with proprietary GPUs.

With last nvidia beta drivers (304.37) and last KDE (4.9.00) on Ubuntu 12.04 KDE show me a dialog when a monitor is plugged/unplugged, and when click on configure show 'display' window (that is attached).

I don't know what code do it, cuz I don't know about KDE code, but I believe KDE sends a Signal for that event (if not is a good idea open a ticket).

Revision history for this message
Alex (noneed4anick) wrote :

Sound's interessting and promissing. I'm wondering if this works the same with ATI cards...

I just found this: http://stackoverflow.com/questions/10400236/how-to-observe-changes-in-connected-monitors-via-xlib
This is also interessting. I'm going to try to write a test file for testing this xlib event. If it works with a set of intel, nvidia and ati cards, I would make a stimulus out of it.

But I need at least one tester with an ati card... So if anyone else is reading this, any help is appreciated ;-)

Alex (noneed4anick)
summary: - New Stymulus for Audio and Suspend/Hibernate/Power on
+ New Stimulus for Connecting external displays
Revision history for this message
nikitakit (nikitakit) wrote :

Another good source might be https://github.com/wertarbyte/autorandr/

Revision history for this message
Alex (noneed4anick) wrote :

Thanks, I'll have a look

Revision history for this message
Georg Peters (georgpeters) wrote :

Did you find something? I'm excited for this feature since I have a laptop with a connected display once in a while..

The way I managed to live with (for now) is:

i have two "profiles" - one for the laptop without, one with display attached.
So I manually switch between these two..cuttlefish only needs to recognize the display (ideal: with name or something else unique) and execute a command that suites to the display attached, ex. display 1 is a beamer, so execute beamer.conf..display 2 is my hd tv..so tv.conf

Any ideas so far? =)

Revision history for this message
Georg Peters (georgpeters) wrote :

Hi again ;)
I tried to write a plugin yesterday..what should I say..I failed ;) (thx for the good youtube video anyway)

So I came along with another solution (for now):

udev rules!
I have two simple udev rules, that monitors if a hdmi monitor is connected or disconnected and execute a script.

First find your env variables to identify the device:
georg@ideapad:~$ udevadm monitor --environment --udev

I got something like "ID_MODEL == "TS2GJF110"" which is unique on my system.

so here are our rules(/etc/udev/rules.d/70-hdmi.rules):
ACTION=="add", ENV{ID_MODEL}=="TS2GJF110", RUN+="/usr/local/bin/hdmi.sh"
ACTION=="remove", ENV{ID_MODEL}=="TS2GJF110", RUN+="/usr/local/bin/hdmi.sh"

Another good thing (for me) is that we can identify the device..so the rule only applies to my hdmi monitor, not the beamer at work ;-)

my simple script:
#!/bin/sh

status="$(cat /sys/class/drm/card0-HDMI-A-1/status)"

export XAUTHORITY=/home/georg/.Xauthority
export DISPLAY=:0.0

if [ "${status}" = disconnected ]
then
 xrandr --output LVDS1 --auto --output HDMI-0 --off

elif [ "${status}" = connected ]
then
 xrandr --output LVDS1 --off --output HDMI-0 --mode 1920x1080
fi

hope it helps someone until cuttlefish get a plugin for that action...since you can customize it a way better.

Revision history for this message
Felipe 'chronos' Prenholato (chronossc) wrote : Re: [Bug 1040649] Re: New Stimulus for Connecting external displays
Download full text (3.2 KiB)

Actually it depends of GPU and driver.

My Nvidia GTS 360M with nvidia-current 304.51 on Ubuntu 12.04 not works,
and, even don't have a entry in /sys/class.

I think that cuttlefish can support GPUs with udev rules if we can have a
generic rule that apply to any monitor... with something documented saying:

"Isn't my fault that your card does not support udev events, sorry..."

I think that because many people don't have a powerfull card like my one
was some years ago, and, people who don't want gaming and want linux today,
will buy machines with lasted intel GPUs.

Felipe 'chronos' Prenholato.
Linux User nº 405489
Home page: http://devwithpassion.com | http://chronosbox.org/blog
GitHub: http://github.com/chronossc/ | Twitter: http://twitter.com/chronossc

2012/9/25 Georg Peters <email address hidden>

> Hi again ;)
> I tried to write a plugin yesterday..what should I say..I failed ;) (thx
> for the good youtube video anyway)
>
> So I came along with another solution (for now):
>
> udev rules!
> I have two simple udev rules, that monitors if a hdmi monitor is connected
> or disconnected and execute a script.
>
> First find your env variables to identify the device:
> georg@ideapad:~$ udevadm monitor --environment --udev
>
> I got something like "ID_MODEL == "TS2GJF110"" which is unique on my
> system.
>
> so here are our rules(/etc/udev/rules.d/70-hdmi.rules):
> ACTION=="add", ENV{ID_MODEL}=="TS2GJF110", RUN+="/usr/local/bin/hdmi.sh"
> ACTION=="remove", ENV{ID_MODEL}=="TS2GJF110", RUN+="/usr/local/bin/hdmi.sh"
>
> Another good thing (for me) is that we can identify the device..so the
> rule only applies to my hdmi monitor, not the beamer at work ;-)
>
> my simple script:
> #!/bin/sh
>
> status="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
>
> export XAUTHORITY=/home/georg/.Xauthority
> export DISPLAY=:0.0
>
> if [ "${status}" = disconnected ]
> then
> xrandr --output LVDS1 --auto --output HDMI-0 --off
>
> elif [ "${status}" = connected ]
> then
> xrandr --output LVDS1 --off --output HDMI-0 --mode 1920x1080
> fi
>
> hope it helps someone until cuttlefish get a plugin for that
> action...since you can customize it a way better.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1040649
>
> Title:
> New Stimulus for Connecting external displays
>
> Status in Cuttlefish:
> Incomplete
>
> Bug description:
> Hello, this is a really nice app, however I missed some stymulus.
>
> Monitor is Plugged / Unplugged:
> What to do: It should watch when a new monitor (via VGA or HDMI) is
> plugged or not and we run a command for each action.
> Why: Today, KDE offer window to configure monitors, but not save a
> default for each monitor I plug in. At my work a have one HP running at
> 1366x720, at home a Dell running at 1440x900. KDE don't regonized it, but
> when I run a command called disper (disper -e -t left when plugged, disper
> -s when unplugged) I have what I need.
>
> [...]
>
> Thx!
>
>
> Edited by Alex: You requested several things in one bug report. Thus in
> order to keep the reports tidy and to prevent total chaos I splitted them
> into several bug report...

Read more...

Revision history for this message
Georg Peters (georgpeters) wrote :

u can use the xrandr command to check if hdmi is connected or not..dont need to cat /sys/class/.. if this is the only problem?!

Also your right, I do have an intel GPU..so it's working fine, but I think it might be a step in the right direction on finding a solution for cuttlefish, meanwhile I use this workaround.

Revision history for this message
Alex (noneed4anick) wrote :

I also have seen the /sys/class/... method, but as far as I know this "file" is created by the intel driver. So it's no global solution.

Revision history for this message
Georg Peters (georgpeters) wrote :

Alex, I guee you can just run the "xrandr" command, use grep to filter if there is "hdmi connected" and there you are..

My python skills are too low to implant this in the structure of cuttlefish..but I think you only have to check "xrandr | grep "HDMI1 connected"" continuously..if it changed to connected/disconnected --> run script.

Isn't it that simple? :(

Revision history for this message
Alex (noneed4anick) wrote :

Hey Georg,

the main problem here is that this would be a polling mechanism. The implementation would be something like running every X seconds xrandr and parse its output to check if something changed. While this would be a working solution, polling is somewhat dirty, because you are creating unnecessary load on the system, even though the call of xrandr would be minimal.

The better solution would be to register a callback, by which cuttlefish will be notified on the change of the displaystatus.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.