I was looking for this and found a question and answer for KDE3; I figured more people will be interested in the answer for KDE4 as time passes (posting here just so I can also post the answer...)
views:
22answers:
1
+1
A:
qdbus org.kde.kwin /KWin org.kde.KWin.currentDesktop
prints the number of the current virtual desktop.
Shai Berger
2010-04-21 12:07:10