aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
authorLibravatar azarus <azarus@posteo.net>2017-08-14 19:38:43 +0200
committerLibravatar azarus <azarus@posteo.net>2017-08-14 22:29:21 +0200
commit5987f19eb2c48b2f9135775aab3fc8a72b9d735a (patch)
treef05365aeef9de6cdad242f91127f37d460549f31 /sway/main.c
parentUpdate README.ja.md (diff)
downloadsway-5987f19eb2c48b2f9135775aab3fc8a72b9d735a.tar.gz
sway-5987f19eb2c48b2f9135775aab3fc8a72b9d735a.tar.zst
sway-5987f19eb2c48b2f9135775aab3fc8a72b9d735a.zip
Check for Raspberry Pi
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sway/main.c b/sway/main.c
index 82375e0b..6d13955c 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -53,6 +53,46 @@ static void wlc_log_handler(enum wlc_log_type type, const char *str) {
53 } 53 }
54} 54}
55 55
56void detect_raspi() {
57 bool raspi = false;
58 FILE *f = fopen("/sys/firmware/devicetree/base/model", "r");
59 if (!f) {
60 return;
61 }
62 char *line;
63 while(!feof(f)) {
64 if (!(line = read_line(f))) {
65 break;
66 }
67 if (strstr(line, "Raspberry Pi")) {
68 raspi = true;
69 }
70 free(line);
71 }
72 fclose(f);
73 FILE *g = fopen("/proc/modules", "r");
74 if (!g) {
75 return;
76 }
77 bool vc4 = false;
78 while (!feof(g)) {
79 if (!(line = read_line(g))) {
80 break;
81 }
82 if (strstr(line, "vc4")) {
83 vc4 = true;
84 }
85 free(line);
86 }
87 fclose(g);
88 if (!vc4 && raspi) {
89 fprintf(stderr, "\x1B[1;31mWarning: You have a "
90 "Raspberry Pi, but the vc4 Module is "
91 "not loaded! Set 'dtoverlay=vc4-kms-v3d'"
92 "in /boot/config.txt and reboot.\x1B[0m\n");
93 }
94}
95
56void detect_proprietary() { 96void detect_proprietary() {
57 FILE *f = fopen("/proc/modules", "r"); 97 FILE *f = fopen("/proc/modules", "r");
58 if (!f) { 98 if (!f) {
@@ -366,6 +406,7 @@ int main(int argc, char **argv) {
366 log_distro(); 406 log_distro();
367 log_env(); 407 log_env();
368 detect_proprietary(); 408 detect_proprietary();
409 detect_raspi();
369 410
370 input_devices = create_list(); 411 input_devices = create_list();
371 412