Get current workspace #?

The Workspaces applet lets you specify the number of a workspace to jump to:

Workspaces 2

But for that to work in a script, you’d have to know how many workspaces the user has and which one you are currently in.

There is a utility (“workspace”) for that on Beshare, but it doesn’t compile in 64-bit Haiku.

Is there another way to get this information?

EDIT: attaching link to file

1 Like

Is the sourcecode for the workspace utility online somewhere?

Besides that, you could try if the Workspaces applet can be asked for the currently active workspace with hey. I would have tried myself but I’m not on a Haiku machine right now.

It’s in the hpkg, in the data directory

1 Like

You can get how many workspace there are from the settings
message ${XDG_CONFIG_HOME}/system/app_server/workspaces
with a pinch of gawk you can do rows*columns to get it
message ${XDG_CONFIG_HOME}/system/app_server/workspaces | awk 'BEGIN{i=1} /columns/,/rows/ {i=i*$(NF-1)} END{print i}' FS='[^0-9]'

I don’t know how to get the current workspace, perhaps with a trick, opening a new tracker window and getting its workspace with hey
hey Tracker get Workspaces of Window $(hey Tracker count of Window | awk '/result/ {print $4-1}') | awk '/result/ {print 1+log($4)/log(2)}'

1 Like

Thanks, zuMi, that actually gives parseable output, But it would be a maintenance nightmare for me :unamused:.

For the record, I found out that there are undocumented features in yab that give me exactly what I wanted :smile:. I’ve reported it here.

1 Like