Advertisement
metalx1000

BASH get screen resolution width and height Linux

Dec 8th, 2017
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #!/bin/bash
  2. #get screen resolution
  3. res="$(xrandr|grep '*'|head -n 1|awk '{print $1}')"
  4.  
  5. #get width and height
  6. width="$(xrandr|grep '*'|head -n 1|awk '{print $1}'|cut -d\x -f1)"
  7. height="$(xrandr|grep '*'|head -n 1|awk '{print $1}'|cut -d\x -f2)"
  8.  
  9. #output
  10. echo "Your screen Resolution is $res"
  11.  
  12. echo "The width is $width and the height is $height"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement