LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2011, 10:14 AM   #1
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Rep: Reputation: 3
Command to display current terminal window's settings?


Hell All,

I was wondering if there is a command line command that will display the current terminal's settings?

For example I would like to run the command and it will display the current window's settings, in order to view for instance the window's geometry size?


Thanks in Advance,
Matt
 
Old 09-07-2011, 10:19 AM   #2
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,384

Rep: Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764
Try 'xrandr'
 
Old 09-07-2011, 10:29 AM   #3
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Hey Allen, thanks for the reply.

I tried the command and this was the output:
Code:
# xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 175, current 1680 x 1050, maximum 1680 x 1050
default connected 1680x1050+0+0 0mm x 0mm
   1680x1050      50.0* 
   1440x900       51.0     52.0  
   1400x1050      53.0     54.0  
   1360x765       55.0  
   1280x1024      56.0     57.0     58.0  
   1280x960       59.0     60.0  
   1280x720       61.0  
   1152x864       62.0  
   1024x768       63.0     64.0     65.0     66.0     67.0     68.0  
   960x720        69.0     70.0  
   928x696        71.0     72.0  
   896x672        73.0     74.0  
   832x624        75.0  
   800x600        76.0     77.0     78.0     79.0     80.0     81.0     82.0     83.0     84.0     85.0  
   720x400        86.0  
   700x525        87.0     88.0  
   640x512        89.0     90.0     91.0  
   640x480        92.0     93.0     94.0     95.0     96.0     97.0     98.0     99.0  
   640x400       100.0  
   640x350       101.0  
   576x432       102.0  
   512x384       103.0    104.0    105.0    106.0    107.0  
   416x312       108.0  
   400x300       109.0    110.0    111.0    112.0    113.0  
   360x200       114.0  
   320x240       115.0    116.0    117.0    118.0  
   320x200       119.0  
   320x175       120.0
Not sure what all that is?

I came across this command below which does display the correct stuff, but I have to click the window that I want to display the data for.
Code:
# xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1e04618 "mmartin@mmartin.paoli.jwpepper.local:/"

  Absolute upper-left X:  359
  Absolute upper-left Y:  161
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1081
  Height: 705
  Depth: 32
  Visual: 0x74
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1e00003 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +359+161  -240+161  -240-184  +359-184
  -geometry 133x40+357+132
By default, when you run the command the mouse then turns into a "plus" looking sign, and it tells you to select the window that you want to display.

There are 2 options that are to use a "name" or "id" instead of using the mouse. Do you know if there is a default "name" or "id" for the current window I am in? Or is there a way to get either of those? I ask because my goal is to do this programmatically, without any human interaction (so no one will be able to use the mouse to select the window).


Thanks,
Matt
 
Old 09-07-2011, 10:52 AM   #4
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Ok so I think I found a way to do this.

If I do the following I can get the "Active" window's id.

Code:
 # xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x1e04618
So that current window's id is "0x1e04618".

Thanks,
Matt
 
Old 09-07-2011, 11:17 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,384

Rep: Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764
Nice catch:
Code:
xwininfo -id $(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d " " -f5) | grep "geometry" | cut -d " " -f4
seems to isolate what you want.
 
Old 09-07-2011, 11:26 AM   #6
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 165

Original Poster
Rep: Reputation: 3
Hey Allen, thanks for your help.

This is my solution below. The result is to isolate the windows geometry so I can check and make sure it is a certain size.
Below shows how I get the "Active Window's Geometry" so I can use it later in a script.

Here's what I got:
Code:
#!/bin/bash

#Finds and Sets the "Active" Window's ID to variable "WINDOW_ID"
WINDOW_ID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5)

#Uses the $WINDOW_ID variable to get the window's full geometry setting.
FULL_GEOMETRY=$(xwininfo -id "$WINDOW_ID" | grep "geometry" | cut -d ' ' -f 4)

#Separate the geometry to have only the "rows x cols"
ACTUAL_GEOMETRY=$(echo $FULL_GEOMETRY | cut -d '+' -f 1)

echo $ACTUAL_GEOMETRY



________OUTPUT________

167x35


.
 
  


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
How do I resize the terminal window from the command line in the gnome terminal QuIcKSpArK Linux - Newbie 5 04-21-2012 02:04 PM
Command from the Terminal Window rxd3950 Linux - Newbie 2 04-11-2011 01:12 PM
terminal command to print current network? daweefolk Linux - Networking 1 01-24-2011 12:45 PM
How to change display settings Fedora 8 using terminal bowbalitic Linux - Newbie 1 03-05-2008 07:38 PM
ping command in terminal window devindude Linux - Newbie 6 03-09-2004 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:37 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