You are not logged in.

#1 2015-08-12 16:22:49

moesi
Member
Registered: 2014-02-27
Posts: 48

New Monitor connected - Eventlistener

Hi!

I wanted to know if it is possible to run a specific shellscript if a specific monitor is connected?

Actually there is this function in xfce (in Display-settings) whcih recognises a new display and opens some settings...
But i want to check if it is a specific monitor and call a arandr-script for each monitor...

i hope i expressed my problem in a clear way. smile

greetings
Moesi

Offline

#2 2015-08-12 16:48:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: New Monitor connected - Eventlistener

What are the differences in the xrandr scripts you want to call?  Xrandr itself can detect which connector the newly connected monitor is on, and it can also check the default resolution.  Would this be sufficient to identify the monitor?  Or in what way do you want the "specific monitor" identified?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2015-08-13 08:19:13

moesi
Member
Registered: 2014-02-27
Posts: 48

Re: New Monitor connected - Eventlistener

The difference is: At home the monitor is to the left of the notebook, in my lab it is on the right. For identification... they are from different manufacturers, but same resolution.

Trilby wrote:

Xrandr itself can detect which connector the newly connected monitor is on, and it can also check the default resolution.

Should xrandr recognise/trigger an event when the hdmi is plugged in? Or did i get this wrong?

So maybe for me to start with this whole thing, the question should be updated to: How could i catch an "plugged-in event" with bash/python... or even C/C++ (but then, not too complicated).

thx
Moesi

Offline

#4 2015-08-13 11:32:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: New Monitor connected - Eventlistener

The xrandr program will not monitor for events, but it can get all the information about that is currently plugged/unplugged, and then configure the monitors from there.  This seems sufficient as you claimed that xfce is already detecting the plug/unplug events - so just run an xrandr sript from there.

The randr extension to xlib can respond to events and do all of the above (this is how xfce detects the plug/unplug events).  I don't know anything about the python API, but the C one is good if you know C.  There isn't one for bash.

If I were you I'd just write a script that queried the current state and configured everything properly - then have this script triggered by the xfce event.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2015-08-13 17:56:11

moesi
Member
Registered: 2014-02-27
Posts: 48

Re: New Monitor connected - Eventlistener

Ok thank your for the informations!

But thats a little to complicated for me, so i am goign to do it manually with shortcuts.

greetings
Moesi

Offline

#6 2015-08-13 18:40:40

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: New Monitor connected - Eventlistener

You could look into randrctl and autorandr -- two of the results for an AUR search of "randr" that might be useful to you.

Offline

Board footer

Powered by FluxBB