Created
February 28, 2012 14:33
-
-
Save syohex/1932867 to your computer and use it in GitHub Desktop.
Get screen resolution on Mac OSX
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
(with-temp-buffer | |
(shell-command | |
"osascript -e 'tell application \"Finder\" to get bounds of window of desktop'" t) | |
(goto-char (point-min)) | |
(if (re-search-forward "[0-9]+, [0-9]+, \\([0-9]+\\), \\([0-9]+\\)") | |
(let ((width (buffer-substring-no-properties | |
(match-beginning 1) (match-end 1))) | |
(height (buffer-substring-no-properties | |
(match-beginning 2) (match-end 2)))) | |
(mapcar #'string-to-int (list width height))))) |
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
(when (executable-find "xdpyinfo") | |
(with-temp-buffer | |
(shell-command "xdpyinfo" t) | |
(goto-char (point-min)) | |
(when (re-search-forward "dimensions:\s+\\([0-9]+\\)x\\([0-9]+\\)" nil t) | |
(let ((width (buffer-substring-no-properties | |
(match-beginning 1) (match-end 1))) | |
(height (buffer-substring-no-properties | |
(match-beginning 2) (match-end 2)))) | |
(mapcar #'string-to-int (list width height)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment