How to determine active monitor of the current pseudo-terminal in Linux shell?
-
20-06-2021 - |
Question
All is in the title, I would like to know the current monitor to rename the KDE Konsole
title accordingly to his position (left or right).
This way I will put in ~/.bashrc
or such by example :
qdbus org.kde.konsole $KONSOLE_DBUS_SESSION org.kde.konsole.Session.setTitle \
1 "LEFT"
to change the title of the Konsole
.
I took a look to the man pages of :
- xdotool
- xprop
And I play around qdbus
, but I'm just able to find the current desktop with
qdbus org.kde.kwin /KWin org.kde.KWin.currentDesktop
Any clue ?
Solution
Learn libXrandr and/or the xrandr
command.
http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
You'll discover that your window can be fully inside both monitors at the same time, or even outside the view of both monitors.
You need to discover which CRTC is being used by each output and then the area of the framebuffer covered by the CRTC. Then you need to discover where in the framebuffer your application is.
I'm not sure if there's any easier or even kde-specific way of doing this.