tadly / hideIt.sh

Automagically hide/show a window by its name when the cursor is within a defined region or you mouse over it.
GNU General Public License v3.0
248 stars 11 forks source link

xwininfo prints options and seq: invalid floating point argument #1

Closed tadly closed 7 years ago

tadly commented 7 years ago

For me to get started please provide the output of the following command:

xwininfo -root

I suspect the output to differ from mine making my regex fail creating a bunch of follow-up errors

phisko commented 7 years ago
xwininfo: Window id: 0xd6 (the root window) "i3"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

This is what I'm getting.

I've also been toying around on my own trying to figure this out. It shouldn't affect anything, but I'm running zsh as my default shell. The shebang seems to be ignored, as if I start bash before I run the script I get a different (but still not correct) behavior:

Searching window...
Found window with id: 46137345
Fetching window dimensions...
Fetching screen dimensions...
Initially hiding window...
Defined region:
  X:
  Y:

Waiting for trigger...

And then it freezes, and polybar stays visible

tadly commented 7 years ago

Hm. Your output seems to be pretty much the same and my regex seems to be working.

Regarding the shebang. I should not use the old method but it writes itself so much easier (muscle-memory) and I seem to have forgotten to change it. Try this one instead. #!/usr/bin/env bash (I'll change over to that one)

At this point you at least don't get strange errors I assume?

If it stays at this output, that's alright. I don't do any more logging afterwards (Will add more later one). For polybar to work you HAVE TO HAVE override-redirect = true set for your bar. Otherwise the wm (I assume, or something else) doesn't allow the window to be moved. Like at all!

phisko commented 7 years ago

I already tried switching to the new shebang (I get the muscle memory problem, I do the same thing every time ~), but it doesn't change anything. This is really weird:

I added override-redirect = true to my polybar config and it now hides correctly, however moving the mouse over it doesn't make it pop back down :(

Sorry to bother you with this, I can't seem to wrap my head around what's going on

phisko commented 7 years ago

Oh my bad! I forgot the --hover option, polybar now pops back down as expected!

The only "issue" left is the strange shebang behavior, I'll keep toying around and let you know if I find anything

tadly commented 7 years ago

I was just writing an essay about the missing --hover option and you interrupted me by finding it out yourself :'(

Happy to see it working now.

The shebang is really strange and yes, please let me know if you have any useful information regarding this. I suspect others will get the same problem.

Will do some testing myself once I finished the improvements/features I'm working on right now :)

bigodel commented 7 years ago

The output of my xwininfo --root is:

xwininfo: Window id: 0xd5 (the root window) "i3"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1366
  Height: 768
  Depth: 24
  Visual: 0x20
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x22 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1366x768+0+0
Searching window...
Found window with id: 16777222
18874375
Fetching window dimensions...
usage:  xwininfo [-options ...]

and a bunch of usage options. That also happens to "Initially hiding windows", but after that I start to get a seq: invalid floating point argument: ‘--3’ Try 'seq --help' for more information. error. I'm posting the full output on pastebin: https://pastebin.com/mCimSJUr

bigodel commented 7 years ago

And just to make it clear, I'm using the --hover option too

tadly commented 7 years ago

@phiste did your output look just like what @heartb1t is getting?

Also, @heartb1t: What shell are you using by default? Bash, zsh, something else?

phisko commented 7 years ago

Yes, those are the same messages I'm getting, except for the "Permission denied".

@heartb1t, in order for "./whatever" to work, you must first give it execution rights. Try running "chmod +x hideIt.sh", that should remove the "Permission denied" error

tadly commented 7 years ago

@heartb1t Aaaaah... I see what the issue is in your case now. That's something I wanted to improve upon. Your output:

Found window with id: 16777222
18874375

Note the second line. While searching a window I get two results (even though I require only one). That messes with further execution.

I'll work on than right away!

phisko commented 7 years ago

Awesome! I had two IDs in my output too but thought nothing of it

tadly commented 7 years ago

@phiste actually was able to reproduce that error that way and zsh might work just fine than too. I installed zsh before working on this fix and had no issues so all might be well at the end :)

I'm almost done with the fix

tadly commented 7 years ago

Alright.. basic fix is out. You guys can test the latest master.

I know that you might hit an issue where you can't uniquely identify a window solely by its name and me reverting the the first match in this case might very well pick the wrong window.

This is a separate issue I'll work on soon'ish. Wanted that to be included in the initial release but xdotool search is lacking a bit in that department

phisko commented 7 years ago

I just tried it, and unfortunately I think the first window to match the id wasn't the right one. The script froze on "Initially hiding window" and I had to kill my terminal to stop it

Changing win_id=${windows[-1]} to win_id=${windows[-2]} worked like a charm though! I don't know if the first id will always be the wrong one, perhaps it would be good to have a way to detect the right one, but I have no idea how you'd go about doing that.

Thanks for the quick fix, and the awesome script :)

tadly commented 7 years ago

As said, I want to improve upon finding the correct window but rather than guessing I'd like to utilize all the properties a window has.

Currently, only WM_NAME is used. I'd like to include at least WM_CLASS (which provides a class-name and an instance) for additional filtering.

I'll see what I can whip up :)

@heartb1t if the new version works (or at least doesn't throw weird errors like before) for you, I'd like to close this issue. I'll open another one regarding better windows searching

bigodel commented 7 years ago

I'm froze on Waiting for hover rn. Tried changing win_id to different values but it doesn't work.

bigodel commented 7 years ago

And when I try to cancel the script with it doesn't return me to my shell, it keeps me frozen there till I close the terminal.

bigodel commented 7 years ago

When I run xdotool search --name "Polybar tray window" I get two different ID's.

tadly commented 7 years ago

hm. dammit.. this issue again :/ Though, reading my source I goofed a little. I don't actually pick the first window id but the last one from the list.

Can you try again?

@phiste you could test the latest commit as well.

bigodel commented 7 years ago

It is working correctly now, thanks! I'll add it to i3's startup. I hope you can improve it and make it universal, because the script is really nice. Good luck!

tadly commented 7 years ago

Awesome. I'll knock this issue on it's head than.