-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminui-getres.c
45 lines (35 loc) · 1.08 KB
/
minui-getres.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2023 Bardia Moshiri <[email protected]>
#include <stdio.h>
#include <minui/minui.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
freopen("/dev/null", "w", stderr);
if (gr_init(false) != 0) {
printf("Failed to initialize minui\n");
return -1;
}
int width = gr_fb_width();
int height = gr_fb_height();
printf("Display resolution: %dx%d\n", width, height);
mkdir("/var/lib/droidian", 0755);
mkdir("/var/lib/droidian/phosh-notch", 0755);
FILE *width_file = fopen("/var/lib/droidian/phosh-notch/width", "w");
if (width_file == NULL) {
printf("Failed to open width file\n");
return -1;
}
fprintf(width_file, "%d\n", width);
fclose(width_file);
FILE *height_file = fopen("/var/lib/droidian/phosh-notch/height", "w");
if (height_file == NULL) {
printf("Failed to open height file\n");
return -1;
}
fprintf(height_file, "%d\n", height);
fclose(height_file);
gr_exit();
return 0;
}