解像度の追加
このコミットが含まれているのは:
コミット
b2155d447c
22
main.c
22
main.c
|
@ -12,6 +12,7 @@
|
|||
#include "src/recording.h"
|
||||
#endif
|
||||
#include "src/packages.h"
|
||||
#include "src/resolution.h"
|
||||
#include "src/cpu.h"
|
||||
#include "src/gpu.h"
|
||||
#include "src/memory.h"
|
||||
|
@ -105,10 +106,12 @@ size_t logosize = 11;
|
|||
lc++;
|
||||
|
||||
#if defined(__linux__)
|
||||
printf("%s ", LOGO[lc]);
|
||||
printf("%s%s%s"RESET, color, "Distro", ": ");
|
||||
printf("%s\n", display_distro());
|
||||
lc++;
|
||||
if (display_distro() != NULL) {
|
||||
printf("%s ", LOGO[lc]);
|
||||
printf("%s%s%s"RESET, color, "Distro", ": ");
|
||||
printf("%s\n", display_distro());
|
||||
lc++;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("%s ", LOGO[lc]);
|
||||
|
@ -142,6 +145,13 @@ size_t logosize = 11;
|
|||
printf("\n");
|
||||
lc++;
|
||||
|
||||
if (display_resolution()) {
|
||||
printf("%s ", LOGO[lc]);
|
||||
printf("%s%s%s"RESET, color, "Resolution", ": ");
|
||||
printf("%s\n", display_resolution());
|
||||
lc++;
|
||||
}
|
||||
|
||||
printf("%s ", LOGO[lc]);
|
||||
printf("%s%s%s"RESET, color, "CPU", ": ");
|
||||
display_cpu();
|
||||
|
@ -166,13 +176,9 @@ size_t logosize = 11;
|
|||
}
|
||||
|
||||
// TODO:
|
||||
// * ロゴ
|
||||
// * パッケージ
|
||||
// * libc
|
||||
// * シェル
|
||||
// * 解像度
|
||||
// * 端末
|
||||
// * GPU
|
||||
// * ストレージ
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#define LOGO_COLORS_H
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__linux__)
|
||||
#define MIN_SIZE 11
|
||||
#define MIN_SIZE 12
|
||||
#else
|
||||
#define MIN_SIZE 10
|
||||
#define MIN_SIZE 11
|
||||
#endif
|
||||
|
||||
#define LOGO_SIZE 24
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#include "gpu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char *run_res_command(const char *command) {
|
||||
char buf[128];
|
||||
char *out = NULL;
|
||||
size_t outsize = 0;
|
||||
|
||||
FILE *p = popen(command, "r");
|
||||
if (!p) {
|
||||
fprintf(stderr, "解像度コマンドを実効に失敗: %s", command);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf), p) != NULL) {
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
|
||||
size_t len = strlen(buf);
|
||||
char *nout = realloc(out, outsize + len + 1);
|
||||
if (nout == NULL) {
|
||||
perror("メモリの役割に失敗");
|
||||
free(out);
|
||||
pclose(p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
out = nout;
|
||||
|
||||
memccpy(out + outsize, buf, sizeof(buf), len);
|
||||
outsize += len;
|
||||
out[outsize] = '\0';
|
||||
}
|
||||
|
||||
pclose(p);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
const char *display_resolution() {
|
||||
return run_res_command("xrandr --nograb --current | "
|
||||
"awk -F 'connected |\\\\+|\\\\(' '/ "
|
||||
"connected.*[0-9]+x[0-9]+\\+/ && $2 {printf $2 "
|
||||
"\", \"}' | sed 's/primary //' | sed 's/,//'");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef RESOLUTION_H
|
||||
#define RESOLUTION_H
|
||||
|
||||
const char *display_resolution();
|
||||
|
||||
#endif
|
読み込み中…
新しいイシューから参照