Is there a way to get the screen height and width from the shell? I don’t want the terminal size, but the actual size of the display screen.
Hi
xrandr should provide the info you need.
–
Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.24-0.2-default
up 5 days 16:12, 3 users, load average: 0.14, 0.06, 0.01
GPU GeForce 8600 GTS Silent - Driver Version: 260.19.21
Perfect, many thanks!!
sr
For anyone that would like to find the terminal window size, which can also be important can use these commands:
WIDTH=`tput cols`
HEIGHT=`tput lines`
I have been using the following command to center text in some script files:
col_os=$((( $WIDTH - 80) / 2 ))
80 was the width in characters I wanted to center on the screen.
Thank You,
xdpyinfo also works even if there is no randr support.
xdpyinfo | grep dimension
And to find out DPI from xdpyinfo. This one I learnt from @malcolmlewis:
xdpyinfo | grep resol
Thank you James very useful
It was also pointed out to me that you can use the following terminal/bash command format to find the terminal width and height as well:
WIDTH=$(tput cols)
HEIGHT=$(tput lines)
The Terminal Center Command for 80 Characters might best be done this way in the event that the present terminal width is 80 or less characters.
if $(WIDTH) -le 80 ] ; then
col_os=0
else
col_os=$((($WIDTH - 80) / 2 ))
fi
Thank You,