Q:

How to Detect Current Workgroup in Workgroups2?

I was looking through the code and found wg-current-workgroup-p ("Return t when WORKGROUP is the current workgroup, nil otherwise.") which seemed to be what I want, but if the current workgroup is called "main" and I do
(wg-current-workgroup-p "main")

I get nil. I'm not sure if I'm doing something wrong or misunderstanding the function. I couldn't find a way to get the current workgroup name either. I'd also like to be able to do this with the workgroup index as well.

A:

wg-current-workgroup-p doesn't take a string as the workgroup name, it needs to be passed an actual workgroup object. For example, try doing this:
(wg-current-workgroup-p (wg-current-workgroup))

(wg-current-workgroup) returns the current workgroup as a workgroup object. Obviously, this will return true, because you're checking if the current workgroup is the current workgroup. 
Some examples:
You can get a list of all workgroup objects with (wg-workgroup-list).
To check if the current workgroup is the last one in the list:
(wg-current-workgroup-p (car (last (wg-workgroup-list))))

To get the name (as a string) of the first workgroup, you can do this:
(wg-workgroup-name (car (wg-workgroup-list)))

You can get all the workgroups names as strings with (wg-workgroup-names)
helm-apropos is useful for finding all these functions.

