diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-20 01:50:04 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-20 01:50:04 +0900 |
commit | a7fa8e216b14b93670369d1867a5c37f42407e90 (patch) | |
tree | 04c922546ecf7dafa70a223afe1b5d9cb5802dca /src/resolution.c | |
parent | 9430ec97891f72a69fb66f433fc3e7253981bb90 (diff) |
xrandrがなければ・・・
Diffstat (limited to 'src/resolution.c')
-rw-r--r-- | src/resolution.c | 11 |
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 |\\\\+|\\\\(' '/ " |