blob: 2671a021299719c571491e775c75ed8f78d4fa55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "resolution.h"
#include "common.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const char *display_resolution() {
const char *display = run_command_s("echo $DISPLAY");
if (display == NULL || strlen(display) == 0) return NULL;
else free((void *)display);
const char *isexist = run_command_s("which xrandr");
if (
isexist == NULL ||
strlen(isexist) == 0 ||
strncmp(isexist, "xrandr not found", strlen("xrandr not found")) == 0
) {
if (isexist) free((void *)isexist);
return NULL;
}
free((void *)isexist);
return run_command_s("xrandr --nograb --current | "
"awk -F 'connected |\\\\+|\\\\(' '/ "
"connected.*[0-9]+x[0-9]+\\+/ && $2 {printf $2 "
"\", \"}' | sed 's/primary //' | "
"sed 's/,\\([^,]*\\)$/\\1/'");
}
|