From 7afbff08b60632e68c4c26faf35f1d1f808c3549 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 2 Nov 2022 21:00:23 +0100 Subject: [PATCH] apps: Add a little screen utility It tells you the resolution of your screen :) --- apps/Makefile | 2 +- apps/src/screen.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 apps/src/screen.c diff --git a/apps/Makefile b/apps/Makefile index 4e704baa..4f110df2 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -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 diff --git a/apps/src/screen.c b/apps/src/screen.c new file mode 100644 index 00000000..60dceed0 --- /dev/null +++ b/apps/src/screen.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +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); +} \ No newline at end of file