aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/sway/main.c b/sway/main.c
index 0c219fb3..e960c4e2 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -12,6 +12,7 @@
12#include <sys/un.h> 12#include <sys/un.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <wlr/util/log.h> 14#include <wlr/util/log.h>
15#include <wlr/version.h>
15#include "sway/commands.h" 16#include "sway/commands.h"
16#include "sway/config.h" 17#include "sway/config.h"
17#include "sway/server.h" 18#include "sway/server.h"
@@ -46,43 +47,6 @@ void sig_handler(int signal) {
46 sway_terminate(EXIT_SUCCESS); 47 sway_terminate(EXIT_SUCCESS);
47} 48}
48 49
49void detect_raspi(void) {
50 bool raspi = false;
51 FILE *f = fopen("/sys/firmware/devicetree/base/model", "r");
52 if (!f) {
53 return;
54 }
55 char *line = NULL;
56 size_t line_size = 0;
57 while (getline(&line, &line_size, f) != -1) {
58 if (strstr(line, "Raspberry Pi")) {
59 raspi = true;
60 break;
61 }
62 }
63 fclose(f);
64 FILE *g = fopen("/proc/modules", "r");
65 if (!g) {
66 free(line);
67 return;
68 }
69 bool vc4 = false;
70 while (getline(&line, &line_size, g) != -1) {
71 if (strstr(line, "vc4")) {
72 vc4 = true;
73 break;
74 }
75 }
76 free(line);
77 fclose(g);
78 if (!vc4 && raspi) {
79 fprintf(stderr, "\x1B[1;31mWarning: You have a "
80 "Raspberry Pi, but the vc4 Module is "
81 "not loaded! Set 'dtoverlay=vc4-kms-v3d'"
82 "in /boot/config.txt and reboot.\x1B[0m\n");
83 }
84}
85
86void detect_proprietary(int allow_unsupported_gpu) { 50void detect_proprietary(int allow_unsupported_gpu) {
87 FILE *f = fopen("/proc/modules", "r"); 51 FILE *f = fopen("/proc/modules", "r");
88 if (!f) { 52 if (!f) {
@@ -218,6 +182,8 @@ void enable_debug_flag(const char *flag) {
218 debug.txn_timings = true; 182 debug.txn_timings = true;
219 } else if (strncmp(flag, "txn-timeout=", 12) == 0) { 183 } else if (strncmp(flag, "txn-timeout=", 12) == 0) {
220 server.txn_timeout_ms = atoi(&flag[12]); 184 server.txn_timeout_ms = atoi(&flag[12]);
185 } else if (strcmp(flag, "noscanout") == 0) {
186 debug.noscanout = true;
221 } else { 187 } else {
222 sway_log(SWAY_ERROR, "Unknown debug flag: %s", flag); 188 sway_log(SWAY_ERROR, "Unknown debug flag: %s", flag);
223 } 189 }
@@ -245,7 +211,7 @@ static void handle_wlr_log(enum wlr_log_importance importance,
245int main(int argc, char **argv) { 211int main(int argc, char **argv) {
246 static int verbose = 0, debug = 0, validate = 0, allow_unsupported_gpu = 0; 212 static int verbose = 0, debug = 0, validate = 0, allow_unsupported_gpu = 0;
247 213
248 static struct option long_options[] = { 214 static const struct option long_options[] = {
249 {"help", no_argument, NULL, 'h'}, 215 {"help", no_argument, NULL, 'h'},
250 {"config", required_argument, NULL, 'c'}, 216 {"config", required_argument, NULL, 'c'},
251 {"validate", no_argument, NULL, 'C'}, 217 {"validate", no_argument, NULL, 'C'},
@@ -344,11 +310,11 @@ int main(int argc, char **argv) {
344 } 310 }
345 311
346 sway_log(SWAY_INFO, "Sway version " SWAY_VERSION); 312 sway_log(SWAY_INFO, "Sway version " SWAY_VERSION);
313 sway_log(SWAY_INFO, "wlroots version " WLR_VERSION_STR);
347 log_kernel(); 314 log_kernel();
348 log_distro(); 315 log_distro();
349 log_env(); 316 log_env();
350 detect_proprietary(allow_unsupported_gpu); 317 detect_proprietary(allow_unsupported_gpu);
351 detect_raspi();
352 318
353 if (optind < argc) { // Behave as IPC client 319 if (optind < argc) { // Behave as IPC client
354 if (optind != 1) { 320 if (optind != 1) {