Last active
October 15, 2022 17:22
-
-
Save funasoul/2b5d4e47d702943d006f6413613ca644 to your computer and use it in GitHub Desktop.
macOS, Linux, OpenBSD等で画面の解像度を取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
_has () { | |
return $( whence $1 &>/dev/null ) | |
} | |
getresolution () { | |
# returns current resolution | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
system_profiler SPDisplaysDataType | awk '/Resolution:/{print $2 "x" $4}' | |
elif _has xrandr; then | |
xrandr | awk '/\*/{print $1}' | |
elif _has xdpyinfo; then | |
xdpyinfo | awk '/dimensions/{print $2}' | |
fi | |
} | |
getresolution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment