On Lubuntu 16.02, this command shows information about all desktops:
$ wmctrl -d
0 - DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 1
1 - DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 2
2 * DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 3
3 - DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 4
4 - DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 5
Need to store and process the information about the active desktop, what shows up by:
$ wmctrl -d | grep "*"
2 * DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 3
For some strange reason, this solution won't store the information needed:
$ activedesktop=$(wmctrl -d | grep "*")
$ echo $activedesktop
2 Desktop Documents Downloads Mail Music Pictures Public Videos DG: 3926x1600 VP: 0,0 WA: 0,24 2560x1576 desktop 3
As the variable inserts the home directories names where the "*" was supposed to be.
Why is this happening, and how to solve it?