Created
October 15, 2020 22:25
-
-
Save osnr/da668c3307518161b6f2372fb71b9302 to your computer and use it in GitHub Desktop.
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
local ffi = require 'ffi' | |
ffi.cdef[[ | |
typedef struct _XDisplay Display; | |
typedef struct Screen Screen; | |
extern Display *XOpenDisplay( | |
const char* /* display_name */ | |
); | |
extern int XDefaultScreen( | |
Display* /* display */ | |
); | |
extern int XDisplayWidth( | |
Display* /* display */, | |
int /* screen_number */ | |
); | |
extern int XDisplayHeight( | |
Display* /* display */, | |
int /* screen_number */ | |
); | |
]] | |
local X = ffi.load('X11') | |
local dpy = X.XOpenDisplay(nil) | |
local n = X.XDefaultScreen(dpy) | |
local width = X.XDisplayWidth(dpy, 0) | |
local height = X.XDisplayHeight(dpy, 0) | |
print(string.format("%d x %d", width, height)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment