summaryrefslogtreecommitdiff
path: root/src/gpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu.c')
-rw-r--r--src/gpu.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gpu.c b/src/gpu.c
new file mode 100644
index 0000000..168fe23
--- /dev/null
+++ b/src/gpu.c
@@ -0,0 +1,28 @@
+#include "gpu.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+void run_gpu_command(const char *command) {
+ char buf[128];
+
+ FILE *p = popen(command, "r");
+ if (!p) {
+ fprintf(stderr, "GPUコマンドを実効に失敗: %s", command);
+ return;
+ }
+
+ while (fgets(buf, sizeof(buf), p) != NULL) {
+ buf[strcspn(buf, "\n")] = '\0';
+ printf("%s", buf);
+ }
+
+ pclose(p);
+}
+
+void display_gpu() {
+ run_gpu_command("glxinfo -B | grep -F 'OpenGL renderer string' | "
+ "sed 's/OpenGL renderer string: //' | sed 's/Mesa //' | "
+ "sed 's/DRI //' | sed 's/(R)//' | sed 's/(.*$//'");
+}