MarkDH102
Posts: 384
Joined: Fri Feb 13, 2015 3:18 pm

xdotool and Buster errors

Fri Dec 13, 2019 5:01 pm

Standard Buster. Pi2B. Completely up to date. sudo apt-get install xdotool.
Open a terminal window (don't resize it) and type :

Image

This worked fine under Jessie and Stretch.
I call it from some python code to resize the terminal window on startup of the Pi. I use curses within the terminal window and need it to be a particular size.
Can anyone shed any light please?
Oh I should add that I am headless and running through realVNC...
Attachments
xdotool.jpg
xdotool.jpg (33.71 KiB) Viewed 515 times

User avatar
Botspot
Posts: 629
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: xdotool and Buster errors

Fri Dec 13, 2019 5:10 pm

Next time please paste your command in code tags so others can copy and paste instead of having to manually hand type it from your screenshot. Like this:

Code: Select all

xdotool getactivewindow windowmove 40 35 windowsize --usehints 165 43
I don't know why this command would break on Buster but not on earlier releases, but after removing --usehints it appeared to work fine:

Code: Select all

xdotool getactivewindow windowmove 40 35 windowsize 165 43
Introducing Pi-Power-Tools: The All-In-1 GUI Tool for Raspbian Images & SD Cards.
Boot in a VM, Flash directly from the Internet, Mount, Edit, Shrink, Expand, Repair, and much more.
https://github.com/Botspot/Pi-Power-Tools
PS. Want to download an Img ASAP? PPT's Download mode is 2x as fast as Chromium. :mrgreen:

MarkDH102
Posts: 384
Joined: Fri Feb 13, 2015 3:18 pm

Re: xdotool and Buster errors

Fri Dec 13, 2019 5:14 pm

Sorry about the code tag thing, but I just wanted to show the error...
What led you to remove '--usehints' ???
However, when I remove it, I end up with a tiny window...

User avatar
Botspot
Posts: 629
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: xdotool and Buster errors

Fri Dec 13, 2019 5:41 pm

MarkDH102 wrote:
Fri Dec 13, 2019 5:14 pm
Sorry about the code tag thing, but I just wanted to show the error...
Yes, I usually include both screenshot and code tag. Otherwise I've found a few users on this forum get pretty annoyed...
MarkDH102 wrote:
Fri Dec 13, 2019 5:14 pm
What led you to remove '--usehints' ???
Just removed one word of the command at a time until the error disappeared, then began adding them back with trial and error. Soon I had narrowed down which one caused the problem.
Introducing Pi-Power-Tools: The All-In-1 GUI Tool for Raspbian Images & SD Cards.
Boot in a VM, Flash directly from the Internet, Mount, Edit, Shrink, Expand, Repair, and much more.
https://github.com/Botspot/Pi-Power-Tools
PS. Want to download an Img ASAP? PPT's Download mode is 2x as fast as Chromium. :mrgreen:

User avatar
Paeryn
Posts: 2836
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: xdotool and Buster errors

Fri Dec 13, 2019 8:21 pm

It looks like a bug somewhere, when lxterminal is first opened the window hints aren't fully populated, especially width_inc and height_inc which are supposed to be the character width and height that are used as multipliers to lock the resize dimensions to whole characters. With these set a zero, when xdotool tries to use resize with --usehints it ends up trying to set a size of 0,0 which is invalid.

Window hints when first opened :-

Code: Select all

[email protected]:~ $ DISPLAY=:0 xwininfo -id 20971523 -size

xwininfo: Window id: 0x1400003 "[email protected]: ~"

  Normal window size hints:
      Program supplied minimum size: 203 by 96
      Program supplied base size: 0 by 0
      Program supplied window gravity: NorthWestGravity
  No zoom window size hints defined
Window hints after a resize or zoom has occurred (that's lxterminal's zoom, the zoom hints reported are nothing to do with lxterminal's zoom)

Code: Select all

[email protected]:~ $ DISPLAY=:0 xwininfo -id 20971523 -size

xwininfo: Window id: 0x1400003 "[email protected]: ~"

  Normal window size hints:
      Program supplied minimum size: 203 by 96
      Program supplied base size: 15 by 30
      Program supplied x resize increment: 8
      Program supplied y resize increment: 16
      Program supplied minimum size in resize increments: 25 by 6
      Program supplied base size in resize increments:  1 by 1
      Program supplied window gravity: NorthWestGravity
  No zoom window size hints defined
If you manually resize the window or change the zoom setting then the hints will be correctly set from then on and the resizing will work. I've just tested pressing Ctrl+Shift+) which sets the zoom level to 1 works to populate the hints without altering the window, though trying to send that keypress with xdotool doesn't seem to work.
She who travels light — forgot something.

MarkDH102
Posts: 384
Joined: Fri Feb 13, 2015 3:18 pm

Re: xdotool and Buster errors

Sat Dec 14, 2019 7:01 am

Paeryn

Many thanks for your sterling efforts. I couldn't even begin to decode the "error" message I posted.
I will set to working out how to zoom the window programmatically...

GlowInTheDark
Posts: 390
Joined: Sat Nov 09, 2019 12:14 pm

Re: xdotool and Buster errors

Sat Dec 14, 2019 11:18 am

While I am certainly a big fan of xdotool, wouldn't it be easier here to just open the window at the desired geometry initially? You can do that by using the --geometry command line option. For example, I have a script that contains the line:

Code: Select all

lxterminal --geometry=165x52 --command="tmux ..."
which launches tmux in a very big window.

BTW, regarding the xdotool errors. This just seems to happen from time to time with xdotool. If you are writing scripts based on xdotool, you just have to learn to code around it. Usually, a retry or two will fix the problem. On that topic, were you getting this error all the time, or just sporadically? It would be weird (i.e., outside of my experience) to be getting it consistently, but I can certainly understand it happening sporadically.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

User avatar
Paeryn
Posts: 2836
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: xdotool and Buster errors

Sat Dec 14, 2019 3:53 pm

GlowInTheDark wrote:
Sat Dec 14, 2019 11:18 am
BTW, regarding the xdotool errors. This just seems to happen from time to time with xdotool. If you are writing scripts based on xdotool, you just have to learn to code around it. Usually, a retry or two will fix the problem. On that topic, were you getting this error all the time, or just sporadically? It would be weird (i.e., outside of my experience) to be getting it consistently, but I can certainly understand it happening sporadically.
This is a problem with the hints not being set correctly when lxterminal starts up, once they are set xdotool can resize with hints (xdotool literally just tries setting the size to width * width_inc, height * height_inc, which fails when the *_inc hints are both 0).

I had a quick rummage through the source code and I think lxterminal tries setting them (I didn't have much time to trace it properly) though I found another oddity in that whilst maximising lxterminal does make it fill as much of the screen that it can, subsequently un-maximising immediately resizes the normal state to the max. I'm wondering if the WM is interfering somehow, I'll look in to it probably tomorrow.
She who travels light — forgot something.

MarkDH102
Posts: 384
Joined: Fri Feb 13, 2015 3:18 pm

Re: xdotool and Buster errors

Sun Dec 15, 2019 7:25 am

Thanks all for your input.
Just to let you know.
It had never happened to me before while using Jessie & Stretch.
But it happens EVERY time I open a terminal window and type in the command from above in Buster.
As for the geometry command for lxterminal, I just didn't know about it. But as you say, it achieves what I need in a far simpler way...
I must learn to use man...

MarkDH102
Posts: 384
Joined: Fri Feb 13, 2015 3:18 pm

Re: xdotool and Buster errors

Mon Dec 16, 2019 7:27 am

I had a light bulb moment last night.
I remember why I didn't originally use "--geometry" while launching lxterminal.
Because it didn't centre the terminal window on the screen.
It does appear to now. It was way back in Jessie when I tried it before...

Return to “General discussion”