summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resolution.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/resolution.c b/src/resolution.c
index ae2136f..249d6c6 100644
--- a/src/resolution.c
+++ b/src/resolution.c
@@ -1,8 +1,10 @@
#include "resolution.h"
#include "common.h"
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
const char *display_resolution() {
const char *isexist = run_command_s("which xrandr");
@@ -10,7 +12,14 @@ const char *display_resolution() {
isexist == NULL ||
strlen(isexist) == 0 ||
strncmp(isexist, "xrandr not found", strlen("xrandr not found")) == 0
- ) return NULL;
+ ) {
+ if (isexist) free((void *)isexist);
+ return NULL;
+ }
+ free((void *)isexist);
+
+ const char *display = run_command_s("echo $DISPLAY");
+ if (display == NULL || strlen(display) == 0) return NULL;
return run_command_s("xrandr --nograb --current | "
"awk -F 'connected |\\\\+|\\\\(' '/ "