Sunday, April 3, 2022

[SOLVED] How can I query the number of the virtual desktop on which the bash script is running in Linux Mint via bash?

Issue

Environment:

Linux Mint, Cinnamon desktop manager, with multiple workspaces=virtual desktops, e.g. 4.
Bash script

What is known:

How to determine the number of workspaces:

wmctrl -d | wc -l

What I need:

Get the number of virtual desktops the bash script is running on with a pure bash as var (like with grep, not awk or similar) and echo the var.

Solution

Based on answer of KamilCuk, its possible to output on follow way the line which is including the number of the active desktop:

nr_of_active_desktop=activedesktop=$(wmctrl -d | grep "*" | rev | cut -d ' ' -f1)
echo $nr_of_active_desktop


Answered By - Eddy763
Answer Checked By - Gilberto Lyons (WPSolving Admin)