# Get the name of the current desktop/group in cwm.
BEGIN {
num_desktops = -1
cur_desktop = -1
}
#_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 10
/NET_NUMBER/ {
num_desktops = $3
}
#_NET_CURRENT_DESKTOP(CARDINAL) = 5
/NET_CURRENT_DESKTOP/ {
# I am using cwm which inserts a "nogroup" as first group.
# so need to add 1 to make this sync up with the awk array
# index of the group list.
cur_desktop = $3 + 1
}
#_NET_DESKTOP_NAMES(UTF8_STRING) = "nogroup", "one", "two", ...
/NET_DESKTOP_NAMES/ {
split($0, a1, "=")
ds = a1[2]
split(ds, desktops, ",")
}
END {
#printf "num_desktops[%d]\n", num_desktops
#printf "cur_desktop[%d]\n", cur_desktop
#for (i=1; i<=num_desktops; i++)
# print i, ":", desktops[i]
d = desktops[cur_desktop]
printf "%s", d
}