Retrieve the current desk number from a shell or perl script

I’d like to find out what desk number is currently active from a shell script or perl script. I naively thought I could use:

FvwmCommand 'Echo $[desk.n]'

But that doesn’t work… It seems that the Echo output goes to the standard error of the Fvwm process; It does not come back to show up on the output of the FvwmCommand.

In the end, what I want is a perl script that will allow me to type:

deskname blah

And it will figure out what desk I’m on, set the title of that desk to “blah”, and update a config file where I’ve saved the titles of all my desktops so that I can restore them if needed.

I can see how to set the name of the current desk, with:

FvwmCommand 'DesktopName $[desk.n] blah'

But then I don’t know what desk number it is… so I can’t associate the name with the desk number in the originating script.

Any suggestions?

Not being an expert, I had the same problem. If you have xdotool installed, then you can obtain the desktop number with…

$ xdotool get_desktop

Thank you! That was exactly what I needed, and now I have another tool to learn about!

Thanks for sharing this small line of code :slight_smile: