LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2021, 07:29 PM   #1
Lennard37
LQ Newbie
 
Registered: Dec 2020
Posts: 28

Rep: Reputation: Disabled
How to get the x and the y size of Cinnamon desktop, without the task bar ?


How to get the x and the y size of Linux Mint Ubuntu Edition Cinnamon desktop, without the task bar (can be its called without gratification) ?

I have found 3 partly solutions.

Partly solution 1:

Code:
wmctrl -lG
0x04000003 -1 0    0    1366 728  pc_name desktop
# ...
# ...
# ...
0x04e00003  0 0    48   1366 703  computer LinuxQuestions.org - Post New Thread - Mozilla Firefox
How to get the value 1366 and 728 for output on follow way ?
Code:
echo $x
echo $y
Partly solution 2:

Code:
xdotool getwindowgeometry [FensterID z.B. 0x012345678]
# Output
Code:
Window 012345678
  Position: 0,0 (screen: 0)
  Geometry: 1366x728
# little bit filtered
Code:
xdotool getwindowgeometry 0x04000003 | grep Geometry
# Output
Code:
Geometry: 1366x728
# Kommandosobstitution
Code:
var="$( xdotool getwindowgeometry 0x04000003 | grep Geometry )"
echo $var
How to get ?
Code:
echo $x
echo $y
Partly solution 3:

Code:
wmctrl -d
# Output
Code:
0  * DG: 1366x768  VP: 0,0  WA: 0,0 1366x728  Workspace 1
1  - DG: 1366x768  VP: N/A  WA: 0,0 1366x728  Workspace 2
2  - DG: 1366x768  VP: N/A  WA: 0,0 1366x728  Workspace 3
3  - DG: 1366x768  VP: N/A  WA: 0,0 1366x728  Workspace 4
Code:
wmctrl -d | grep "Workspace 1"
# Output
Code:
0  * DG: 1366x768  VP: 0,0  WA: 0,0 1366x728  Workspace 1
Wanted output:
Code:
echo $x
1366

echo $y
728
I am looking for a solution which don't need AWK.

Last edited by Lennard37; 09-17-2021 at 06:43 AM.
 
Old 09-16-2021, 08:28 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
A couple of examples for your first question using cut.
Code:
x=$(xdotool getdisplaygeometry | cut -d ' ' -f1 )
y=$(xdotool getdisplaygeometry | cut -d ' ' -f2 )
echo "x=$x"
echo "y=$y"

x=$(wmctrl -lG | grep Desktop | tr -s ' ' | cut -d ' ' -f5 )
y=$(wmctrl -lG | grep Desktop | tr -s ' ' | cut -d ' ' -f6 )

echo "x=$x"
echo "y=$y"

Last edited by michaelk; 09-16-2021 at 08:29 PM.
 
Old 09-17-2021, 06:15 AM   #3
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,597

Rep: Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545

I would assume there is an X/Wayland way to do this that isn't specific to Mint or Cinnamon.

Yep, a quick search reveals xprop and _NET_WORKAREA which is calculated "by taking the current page minus space occupied by dock and panel windows"

Code:
$ xprop -root _NET_WORKAREA _NET_DESKTOP_GEOMETRY
_NET_WORKAREA(CARDINAL) = 0, 0, 1280, 764
_NET_DESKTOP_GEOMETRY(CARDINAL) = 0, 0, 1280, 800
Easy enough to then use cut/awk/whatever to extract the numbers.


Last edited by boughtonp; 09-17-2021 at 06:28 AM.
 
1 members found this post helpful.
Old 09-17-2021, 06:19 AM   #4
Lennard37
LQ Newbie
 
Registered: Dec 2020
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thanks, thats looking its on right way.

By the follow I get 1366 x 768 as output, but I need the range of the display ( in this case 1366 x 728 ) which dont have menus from Cinnamon and is available to show other windows. It can be I have to add the "wid" behind the "xdotool getdisplaygeometry" for this.

Quote:
Originally Posted by michaelk View Post
A couple of examples for your first question using cut.
Code:
x=$(xdotool getdisplaygeometry | cut -d ' ' -f1 )
y=$(xdotool getdisplaygeometry | cut -d ' ' -f2 )
echo "x=$x"
echo "y=$y"

By follow one I dont get a output on this time:
Quote:
Originally Posted by michaelk View Post
A couple of examples for your first question using cut.
Code:
x=$(wmctrl -lG | grep Desktop | tr -s ' ' | cut -d ' ' -f5 )
y=$(wmctrl -lG | grep Desktop | tr -s ' ' | cut -d ' ' -f6 )

echo "x=$x"
echo "y=$y"

Last edited by Lennard37; 09-17-2021 at 06:23 AM.
 
Old 09-17-2021, 06:41 AM   #5
Lennard37
LQ Newbie
 
Registered: Dec 2020
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by boughtonp View Post
I would assume there is an X/Wayland way to do this that isn't specific to Mint or Cinnamon.

Code:
$ xprop -root _NET_WORKAREA _NET_DESKTOP_GEOMETRY
_NET_WORKAREA(CARDINAL) = 0, 0, 1280, 764
_NET_DESKTOP_GEOMETRY(CARDINAL) = 0, 0, 1280, 800
Easy enough to then use cut/awk/whatever to extract the numbers.
Thats great. The follow give me a output which is including the wanted x=1366 and y=728 value:
Code:
xprop -root _NET_WORKAREA
# output
_NET_WORKAREA(CARDINAL) = 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728
Now I can try to get this working as follow:
Code:
echo "x=$x"
echo "y=$y"
Thats what I have on this time.:
Code:
x=$(xprop -root _NET_WORKAREA   | tr -s ' ' | cut -d ' ' -f5) 
user@computer:~$ echo "x=$x"
x=1366,
Code:
y=$(xprop -root _NET_WORKAREA   | tr -s ' ' | cut -d ' ' -f6) 
user@computer:~$ echo "x=$x"
y=1366,
How to remove the "," from Output "1366," and "728," ?

Last edited by Lennard37; 09-17-2021 at 06:55 AM.
 
Old 09-17-2021, 06:48 AM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,597

Rep: Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545Reputation: 2545

There's plenty of ways to get just the relevant values, using cut/awk/grep/etc.

Possibly the simplest way to get them into separate variables is to use Bash "[[" and "=~" which performs a regex match and puts the captured groups into an array, for example:

Code:
coords=$(xprop -root _NET_WORKAREA)
[[ "$coords" =~ ([0-9]+),\ ([0-9]+)$ ]]
echo "x=${BASH_REMATCH[1]}"
echo "y=${BASH_REMATCH[2]}"
But since you're getting four sets output you'll first want to check the xprop manual I linked above to confirm the options for only getting the screen/desktop you're interested in before doing that.

 
Old 09-17-2021, 07:38 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Code:
_NET_WORKAREA(CARDINAL) = 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728
         f1                 f2   f3   f4
Code:
x=$(xprop -root _NET_WORKAREA   | tr -s ' ' | cut -d ' ' -f5)
Change the cut separator from a space ' ' to a ','

Code:
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f3) 
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f4)
The only caveat is that x and y contain a leading space.
x= 1366
Code:
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f3 | xargs echo -n) 
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f4 | xargs echo -n)
Add xargs to remove extra spaces.
The "tr -s ' ' " command was used to "shrink" the number of white spaces between numbers in the other commands but not necessary with xprop.

Last edited by michaelk; 09-17-2021 at 07:57 AM.
 
Old 09-17-2021, 08:10 AM   #8
Lennard37
LQ Newbie
 
Registered: Dec 2020
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Code:
_NET_WORKAREA(CARDINAL) = 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728, 0, 0, 1366, 728
         f1                 f2   f3   f4
Code:
x=$(xprop -root _NET_WORKAREA   | tr -s ' ' | cut -d ' ' -f5)
Change the cut separator from a space ' ' to a ','

Code:
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f3) 
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f4)
The only caveat is that x and y contain a leading space.
x= 1366
Code:
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f3 | xargs echo -n) 
x=$(xprop -root _NET_WORKAREA  | cut -d ',' -f4 | xargs echo -n)
Add xargs to remove extra spaces.
The "tr -s ' ' " command was used to "shrink" the number of white spaces between numbers in the other commands but not necessary with xprop.
Thats my preferd solution.
Thanks for this and the guide to do this in future possible by self.
Thanks

Thanks for the other solutions from other people too.
THX

Last edited by Lennard37; 09-17-2021 at 08:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] kicker - Relaunch task bar/ tray bar (the bar at the bottom of screen). andrewysk Linux - Newbie 3 03-18-2021 03:19 PM
Unable to launch "cinnamon-session-cinnamon" X session "cinnamon-session-cinnamon" -found; Falling back to default "session." xxxindigo Linux Mint 22 09-01-2019 09:21 AM
Task Bar and Application Bar Font to small louisb Linux - Laptop and Netbook 6 04-27-2017 10:21 AM
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
[SOLVED] lost task bar and status bar how to get them back devmohan786 Linux - Software 2 07-13-2008 04:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration