I have a bash script for hiding X11 windows. I want to be able to find what window the mouse is positioned over and unmap that window.
Using xdotool
I've gotten a way to find the window ID:
$ xdotool getmouselocation
x:392 y:344 screen:0 window:54799020
I want to trim this line to just 54799020
.
(I want to remove everything up to and including window:
.)
Is there a way to do this? I have very little experience with tr
and sed
. I've used sed
to remove text before, but I need to also remove the mouse coordinates, which are not always the same.
Try this,
sed 's/.*window:\(.*\)/\1/g' file
In your case,
xdotool getmouselocation | sed 's/.*window:\(.*\)/\1/g'
Example:
$ echo "x:392 y:344 screen:0 window:54799020" | sed 's/.*window:\(.*\)/\1/g'
54799020