You are not logged in.
What I'd like to do is use xwininfo and wmctrl to maximize an application in X without a window manager. Here is what I've worked out:
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
# exec gnome-session
# exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
MAXIMIZE_ID=$(xwininfo -root -child | grep "st-256color" | grep -o "^[[:space:]]*0x[[:alnum:]]*" | grep -o "0x[[:alnum:]]*")
MAXIMIZE_WIDTH=$(xwininfo -root | grep "Width" | grep -o "[[:digit:]]*")
MAXIMIZE_HEIGHT=$(xwininfo -root | grep "Height" | grep -o "[[:digit:]]*")
while [ "$MAXIMIZE_ID" = "" ]
do
MAXIMIZE_ID=$(xwininfo -root -child | grep "st-256color" | grep -o "^[[:space:]]*0x[[:alnum:]]*" | grep -o "0x[[:alnum:]]*")
if [ "$MAXIMIZE_ID" != "" ]
then
wmctrl -i -r $MAXIMIZE_ID -e 0,0,0,$MAXIMIZE_WIDTH,$MAXIMIZE_HEIGHT
fi
done &
exec stAs intended it maximizes the st terminal. However, the terminal simply hangs there, I can provide it with no input, any clues as to what I'm missing and/or doing incorrectly? I realize st uses the geometry parameter, I'm only using it here as an example application as not all applications support that parameter.
Last edited by grimpirate (2014-08-12 19:20:00)
Offline
Have you tried adding a tiny manual tiling or stacking WM to your ~/.xinitrc?
Offline
What I'd like to do is use xwininfo and wmctrl to maximize an application in X without a window manager.
Wmctrl controls a *EWMH/NetWM compatible X* windows manager, without one it should not be capable to work. I get exit code 1, when trying to list windows on a window-managerless screen:
$ env DISPLAY=:0.1 wmctrl -l
Cannot get client list properties.
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)Should you be really unwilling to use a wm, look at source code of a tiny wm. Maybe you can get whatever you want with a few lines.
Edit: corrected that.
wmctrl - interact with a EWMH/NetWM compatible X Window Manager.
Last edited by emeres (2014-08-13 12:32:21)
Offline
It's much more complex than that. Wmctrl requires a EWMH compliant window manager. Many of the lightest weight WMs are not EWMH compliant.
Is this just for st, or do you want all windows maximized? Does st have a 'geometry' flag?
You could write a WM that does nothing but fullscreen every window that is mapped in about a dozen lines of code. Note, however, that without a WM, windows will generally not properly be assigned the input focus - one result is that cursors on most terminals will remain 'hollow'. For the cost of one or two more lines of code, this new WM could also set input focus appropriately.
EDIT: st does have a geometry flag, just use that.
Also, your 'grep | grep' pipe could just be "awk '/Width/ { print $2;}'", or two get both width and height in one go:
xwininfo -root | awk '/Width/ { printf "%s", $2;} /Height/ {printf "x%s", $2;}'Though this wouldn't be quite right for a st geometry string as that takes rows and columns, not pixels.
EDIT2: your solution will also fail miserably for two other reasons. There is not point in initializing the MAXIMIZEID variable before the loop starts - because if there actually are any windows there, the while loop will never run. Also, without a sleep command, or something, all that while loop will be very good for will be to turn your cpu into a frying pan (100% cpu use -> heat).
Here's a very plain WM that will do the same thing without melting your CPU:
#include <X11/Xlib.h>
int main(void) {
Display *dpy;
if(!(dpy = XOpenDisplay(0x0))) return 1;
XEvent ev;
int scr = DefaultScreen(dpy);
int sw = DisplayWidth(dpy, scr);
int sh = DisplayHeight(dpy, scr);
Window w, root = RootWindow(dpy, scr);
XSelectInput(dpy, root, SubstructureRedirectMask);
while (!XNextEvent(dpy, &ev)) {
if (ev.type == MapRequest && (w=ev.xmaprequest.window)) {
XMoveResizeWindow(dpy, w, 0, 0, sw, sh);
XMapWindow(dpy, w);
XSetInputFocus(dpy, w, RevertToPointerRoot, CurrentTime);
XFlush(dpy);
}
}
return 0;
}Last edited by Trilby (2014-08-13 13:03:59)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
@karol: I use dwm normally, which would do this quite readily, I was moreso curious as to if I could eliminate the resource usage of the window manager AND enable only a singular application to run (a heavily restricted kiosk of sorts).
@emeres: Yes I read the man page and realize wmctrl's purpose. Seeing as X can display an application without the need for a window manager, it likely respects the default sizes of applications, which presumably can be altered. I realize those may be unfounded assumptions. However, my poorly composed xinitrc does indeed have the intended effect of maximizing the st window,
@Trilby: Thanks very much for the code, I compiled it as follows (and chmodded to 0755):
gcc -I /usr/include/ -c maxwm.c -o maxwmHowever, running st & followed by exec maxwm stops the server with a "Server terminated successfully" message. I don't want ALL windows maximized for the record, I want a single application maximized, and only that application. I added an echo "count" >> xinitout line to the while loop to see if it was in fact executing ridiculous amounts of times, but it stops at 6, so it does appear to terminate as expected once it obtains the id of the st window.
Offline
If you only want to fullscreen that one window, just use st's geometry flag.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Sorry, I should've been more specific Trilby, I'm using st as an example, it's not the actual application I want to maximize. The actual application is abiword, whose geometry parameter I atttempted to use to no avail.
EDIT -> Trilby: Read my original post where I stipulated "I realize st uses the GEOMETRY PARAMETER, I'm only using it here as an EXAMPLE APPLICATION as not all applications support that parameter."
Last edited by grimpirate (2014-08-14 16:21:17)
Offline
Sorry, I should've been more specific
Yes, you should have as I was looking into the st man page and even the code to check various points. Abiword is a different program, and depending on which version of abiword you use, I would not expect it to work without a window manager. The abiword in the repos uses gtk3, and most gtk3 programs never set or adjust their own size - instead they send messages to the window manager to request the WM change their size.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline