apps: Add a little screen utility
It tells you the resolution of your screen :)
This commit is contained in:
parent
249c79f8a3
commit
7afbff08b6
@ -1,4 +1,4 @@
|
||||
APPS := init sh uname uptime hello ps ls args cat stat su session date mkdir
|
||||
APPS := init sh uname uptime hello ps ls args cat stat su session date mkdir screen
|
||||
|
||||
APPS_DIR := $(LUNA_ROOT)/apps
|
||||
APPS_SRC := $(APPS_DIR)/src
|
||||
|
32
apps/src/screen.c
Normal file
32
apps/src/screen.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd = open("/dev/fb0", O_WRONLY | O_CLOEXEC);
|
||||
if(fd < 0)
|
||||
{
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fb_width = ioctl(fd, FB_GET_WIDTH);
|
||||
if(fb_width < 0)
|
||||
{
|
||||
perror("ioctl(FB_GET_WIDTH)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fb_height = ioctl(fd, FB_GET_HEIGHT);
|
||||
if(fb_height < 0)
|
||||
{
|
||||
perror("ioctl(FB_GET_HEIGHT)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Your screen is %dx%d\n", fb_width, fb_height);
|
||||
|
||||
close(fd);
|
||||
}
|
Loading…
Reference in New Issue
Block a user