You are not logged in.
I'm trying to use only one key in my i3-wm config to rotate the currently focused monitor - basically the on that the focused window is on.
But if I want to do
$ Xrandr --rotate left then it requires me to specify a '--output' device (for me either DP-3 or DP-5) - which I do not know how to get.
One more thing to note, is that I have each Workspace assigned to a specific output, if it helps:
workspace $Ws1 output DP-5
workspace $Ws2 output DP-3
workspace $Ws3 output DP-5
workspace $Ws4 output DP-3
workspace $Ws5 output DP-5
workspace $Ws6 output DP-3
workspace $Ws7 output DP-5
workspace $Ws8 output DP-3
workspace $Ws9 output DP-5Thanks in advance!
Last edited by areuz (2016-12-31 14:41:18)
If I'm not a bush, I'm not no one.
Dotfiles Git
Offline
The only way to go from a focused window to the output it's on is by coordinates. You can get the coordinates of the window with something like wmctrl - and xrandr will give you the coordinates and size of each output.
The following would do this in C - with no parameters, this will just return the name of the output the currently focused window is on. With any parameters it will instead give the output that the mouse is currently in:
/*
WHICHOUT.C
Released to public domain
gcc -o whichout whichout.c -lX11 -lXrandr
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
int main(int argc, const char *const *argv) {
int i, tx = 0, ty = 0;
Display *dpy = XOpenDisplay(0x0);
Window root = DefaultRootWindow(dpy);
Window wig, win;
XGetInputFocus(dpy, &win, &i);
if (argc == 1) XGetGeometry(dpy, win, &wig, &tx, &ty, &i, &i, &i, &i);
else XQueryPointer(dpy, win, &wig, &wig, &tx, &ty, &i, &i, &i);
if (!dpy) return 1;
XRRScreenResources *res = XRRGetScreenResources(dpy, root);
if (!res) return 2;
for (i = 0; i < res->noutput; ++i) {
XRROutputInfo *info = XRRGetOutputInfo(dpy, res, res->outputs[i]);
if (!info || !info->crtc) continue;
XRRCrtcInfo *crtc = XRRGetCrtcInfo(dpy,res,info->crtc);
if (!crtc) { XRRFreeOutputInfo(info); continue; }
if (!(tx < crtc->x || tx > crtc->x + crtc->width || ty < crtc->y || ty > crtc->y + crtc->height)) {
printf(info->name);
break;
}
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(info);
}
XRRFreeScreenResources(res);
XCloseDisplay(dpy);
return 0;
}"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks Trilby! I hoped that there was another easier way by now, I saw a similar post from like 2 years ago. But I guess there is no way around that.
If I'm not a bush, I'm not no one.
Dotfiles Git
Offline
Also, this another reason is why I don't like the 'add [Solved] in the title' approach combined with the title length restrictions. I have to shorten my title now...
If I'm not a bush, I'm not no one.
Dotfiles Git
Offline
Hm.. It works very strangely with multiple workspaces, I will have to figure out how it works first.
Actually (sorry for 3 posts in a row xD) I just found a tool called 'xdotool' - which when used like
xdotool get_dekstopreturns an int of 0 - n_screens, which in my case will work perfectly for a simple bash 'case' statement!
I'll post the code in few, and I'll try to make it inline ![]()
Last edited by areuz (2016-12-31 14:52:44)
If I'm not a bush, I'm not no one.
Dotfiles Git
Offline