From a7fa8e216b14b93670369d1867a5c37f42407e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 20 Jun 2024 01:50:04 +0900 Subject: =?UTF-8?q?xrandr=E3=81=8C=E3=81=AA=E3=81=91=E3=82=8C=E3=81=B0?= =?UTF-8?q?=E3=83=BB=E3=83=BB=E3=83=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resolution.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include +#include 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 |\\\\+|\\\\(' '/ " -- cgit v1.2.3