0

Is there some command (or trick) to detect what DISPLAY is active?
I mean active in a sense that it will "eat" all key strokes, and mouse clicks and moves; so it has the input focus.
I mean also for the simple hardware installation where the user has only one physical keyboard and only one mouse (usb or ps2).

The default X session loads at ctrl+alt+f7 (:0) here.
I have another X at ctrl+alt+f8/f9 (:1).
I want to code a script that, when I go to :1, it automatically lock :0, or :1 accordingly.

When the mouse is stopped and no key is being pressed, we are just staring at the screen; but, I think the "current active? (or both are?)" X must be watching the input for changes, while the other X is unable to watch such changes, that channel must be uniquely accessed in some way... any tips?

  • 1
    I don't know about that Ctrl-Alt-* stuff but there is no general definition of a DISPLAY being "active" or "inactive". Would a Xvnc display be considered active only when there is at least one client connected to it? I also guess that under any reasonable definition, many different displays could all be considered "active" at the same time... – Celada Jul 28 '14 at 1:08
  • I updated the question, I actually mean it having the hardware keyboard and mouse input focus. – Aquarius Power Jul 28 '14 at 1:23
  • 2
    I don't think such solutions exist, because there is no such thing as "input focus". Quite the contrary is the case. Multiseat setups seem very common for e.g. kiosk systems. Such decisions would always be heuristical approaches with a bunch of sources for errors. For instance, in your comment you talk about "the hardware keyboard", implying there is only one and it is read from by an X-Server. Both are assumptions that needn't be true. Then there are things like Xephyr and Xnest, which stack X-Servers into one another. – Bananguin Jul 28 '14 at 6:04
  • @Bananguin wow :D, so you mean to provide a generic large scale solution that will work to everyone it would be very complicated right? but I mean just the simple usual hardware installation found on "most?" desktop or notebook systems; I will increase the restriction on the question :) – Aquarius Power Jul 28 '14 at 18:49
  • 1
    I think fgconsole (if run as root) should do what you want. Ctrl-Alt-Fx switches to the Linux console #x, and fgconsole tells you the number of the currently active console. – celtschk Jul 28 '14 at 20:03
2

fgconsole (if run as root) should do what you want. Ctrl-Alt-Fx switches to the Linux console #x, and fgconsole tells you the number of the currently active console.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.