(Solved) How to get the Number of the current desktop?
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
(Solved) How to get the Number of the current desktop?
Hi.
I need to find out the number of the current/active desktop.
Any chance, to get it without to use xdotool or wmctrl?
Want to do this from within a bash script.
Thanks.
I need to find out the number of the current/active desktop.
Any chance, to get it without to use xdotool or wmctrl?
Want to do this from within a bash script.
Thanks.
Last edited by LazY Puppy on Fri 18 Dec 2015, 07:54, edited 1 time in total.
RSH
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
Re: How to get the Number of the current desktop?
Hi, Lazy.LazY Puppy wrote:Hi.
I need to find out the number of the current/active desktop.
Any chance, to get it without to use xdotool or wmctrl?
Want to do this from within a bash script.
Thanks.
You'll find a possible answer here.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
No, this wasn't successful.
A search at the page did not return any useful hints.
Tried to post a question as a guest, but the button didn't work for me.
However: thanks for the Link.
A search at the page did not return any useful hints.
Tried to post a question as a guest, but the button didn't work for me.
However: thanks for the Link.
RSH
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:
No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:
Code: Select all
xprop -root | awk '$1 ~ /CURRENT_DESK/ { print $NF }'
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
- LazY Puppy
- Posts: 1934
- Joined: Fri 21 Nov 2014, 18:14
- Location: Germany
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Hello all.
I can't imagine why one would need more than 9 workspaces or desktops,
but these three bash lines will pad the first 9 desktop numbers with a "0".I'm sure someone can make that more concise, too. But essentially, that's
how padding is done before the number.
BFN.
I can't imagine why one would need more than 9 workspaces or desktops,
but these three bash lines will pad the first 9 desktop numbers with a "0".
Code: Select all
DESK="`xprop -root | awk '$1 ~ /CURRENT_DESK/ { print $NF }'`"
[ ${#DESK} -lt 10 ] && DESK="0$DESK"
echo $DESK
how padding is done before the number.
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
I have a different puppypin for each desktop, so the icons/icon arrangements and wallpaper can all be different on each desktop. If you set the wallpaper to be a month calendar then you can position icons over particular dates - notes, to-do's... whatever. Or copies of work done (zip files etc) on particular days. 12 desktops.musher0 wrote:I can't imagine why one would need more than 9 workspaces or desktops
For a busier individual perhaps 52 desktops (weekly calendar backgrounds).
Or you might have a desktop to reflect each of the main menu's 12 to 15 'sections'.
Or you might have 10+ remote PC's that you RemoteDesktop/VNC into, each running on their own desktop.
The limiting factor in other pup's is the same set of icons on each desktop. With that restriction lifted there's a wider range of possibilities.
This is good rufwoof:
Probably the fastest to suck the output into a variable:
The above,and the next two wont have number-issues.
The 3 above have same runtime
This feeds all the xprop-stuff to awk - and is naturally the slowest.
Edit: Typo '$0==$NF' corrected to '$0=$NF'
I guess USER wants the desktop-number as 1-based so:
Demonstrates that xprop has an inbuilt query-faclityxprop -root _NET_CURRENT_DESKTOP|tail -c 3
provides the desktop number (starting from zero = desktop 1)
You might have to adjust that for desktops > 10 ???
Probably the fastest to suck the output into a variable:
Code: Select all
NUM=$(xprop -root _NET_CURRENT_DESKTOP);NUM=${NUM##*' '}
echo $NUM
Code: Select all
time xprop -root _NET_CURRENT_DESKTOP|awk '$0=$NF'
Code: Select all
time xprop -root _NET_CURRENT_DESKTOP|cut -d ' ' -f3
Code: Select all
time xprop -root _NET_CURRENT_DESKTOP|tail -c 3
This feeds all the xprop-stuff to awk - and is naturally the slowest.
Code: Select all
time xprop -root | awk '$1 ~ /CURRENT_DESK/ { print $NF }'
Edit: Typo '$0==$NF' corrected to '$0=$NF'
I guess USER wants the desktop-number as 1-based so:
Code: Select all
xprop -root _NET_CURRENT_DESKTOP|awk '$0=($NF+1)'
Code: Select all
NUM=$(xprop -root _NET_CURRENT_DESKTOP);NUM=$((${NUM##*' '}+1))
echo $NUM
To each his own, man, to each his own!rufwoof wrote:I have a different puppypin for each desktop, so the icons/icon arrangements and wallpaper can all be different on each desktop. If you set the wallpaper to be a month calendar then you can position icons over particular dates - notes, to-do's... whatever. Or copies of work done (zip files etc) on particular days. 12 desktops.musher0 wrote:I can't imagine why one would need more than 9 workspaces or desktops
For a busier individual perhaps 52 desktops (weekly calendar backgrounds).
Or you might have a desktop to reflect each of the main menu's 12 to 15 'sections'.
Or you might have 10+ remote PC's that you RemoteDesktop/VNC into, each running on their own desktop.
The limiting factor in other pup's is the same set of icons on each desktop. With that restriction lifted there's a wider range of possibilities.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
@some1:
Thanks for your "variations".
I like padding, though, in a case like this, andpads the number.
BFN.
Thanks for your "variations".
I like padding, though, in a case like this, and
Code: Select all
xprop -root _NET_CURRENT_DESKTOP|awk '{ print "0"($0=($NF+1)) }'
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Musher0: RTMs as amigo suggests
Various printfs in the universe:
1.The shell printf -inbuilt or not.
2. awks printf - for formatting output
3 awks sprintf - for internal "printing" for usage inside awk - i.e.conversion,formatting.etc
Padded output:
---
RSH: step has a thing to show you,might help you handling the topless
Various printfs in the universe:
1.The shell printf -inbuilt or not.
2. awks printf - for formatting output
3 awks sprintf - for internal "printing" for usage inside awk - i.e.conversion,formatting.etc
Padded output:
Code: Select all
xprop -root _NET_CURRENT_DESKTOP|awk '{ printf "%02d",($NF+1);}'
RSH: step has a thing to show you,might help you handling the topless