Vlastimil Burián
Vlastimil Burián

Reputation: 3466

How do I get screen resolution in a shell script on Linux

Environment

System: Linux Mint 18 / 19 Cinnamon 64-bit.

Shell: dash (POSIX).


Question

I need to dynamically account for the screen resolution in a POSIX shell script.

I prefer a function for re-use.

Upvotes: -2

Views: 3004

Answers (1)

Vlastimil Burián
Vlastimil Burián

Reputation: 3466

Function

get_screen_resolution()
{
    xdpyinfo | awk '/dimensions:/ { print $2 }'
}

Usage

resolution=$(get_screen_resolution)

Upvotes: 2

Related Questions