LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command to display current terminal window's settings? (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-display-current-terminal-windows-settings-901603/)

mrm5102 09-07-2011 10:14 AM

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

allend 09-07-2011 10:19 AM

Try 'xrandr'

mrm5102 09-07-2011 10:29 AM

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

mrm5102 09-07-2011 10:52 AM

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

allend 09-07-2011 11:17 AM

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.

mrm5102 09-07-2011 11:26 AM

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


.



All times are GMT -5. The time now is 02:01 AM.