More sysinfo stuff

This commit is contained in:
Kevin Lange 2015-06-11 21:09:25 -07:00
parent c6a2d2ebe7
commit 4501419126
2 changed files with 84 additions and 13 deletions

View File

@ -12,7 +12,6 @@
#include <sys/utsname.h>
#include "lib/graphics.h"
#include "lib/yutani.h"
#include "gui/terminal/lib/termemu.h"
#include "toaru_logo.h"
@ -20,33 +19,48 @@
#define NUM_DATA_LINES 30
char data_lines[NUM_DATA_LINES][100];
const char * prog_lines[NUM_DATA_LINES] = {NULL};
#define C_A "\033[34;1m"
#define C_O "\033[0m"
void print_thing(int j) {
printf("\033[0m %s", data_lines[j]);
fflush(stdout);
if (prog_lines[j]) {
system(prog_lines[j]);
} else {
printf("\n");
}
}
int main(int argc, char * argv[]) {
/* Prepare data */
char * user = getenv("USER");
char * wm_theme = getenv("WM_THEME");
struct utsname buf;
uname(&buf);
yutani_t * yctx = yutani_init();
int i = 0;
sprintf(data_lines[i++], C_A "%s" C_O "@" C_A "%s", user, buf.nodename);
prog_lines[i] = "hostname";
sprintf(data_lines[i++], C_A "%s" C_O "@" C_A, user);
sprintf(data_lines[i++], C_A "OS: " C_O "ToaruOS");
sprintf(data_lines[i++], C_A "Kernel: " C_O "%s %s", buf.sysname, buf.release);
sprintf(data_lines[i++], C_A "Uptime: " C_O "(query /proc/uptime)");
prog_lines[i] = "uname -sr";
sprintf(data_lines[i++], C_A "Kernel: " C_O);
prog_lines[i] = "uptime -p";
sprintf(data_lines[i++], C_A "Uptime: " C_O);
//sprintf(data_lines[i++], C_A "Packages: " C_O "(hell if I know!)");
sprintf(data_lines[i++], C_A "Shell: " C_O "esh %s", buf.release);
sprintf(data_lines[i++], C_A "Resolution: " C_O "%dx%d", yctx->display_width, yctx->display_height);
prog_lines[i] = "sh -v";
sprintf(data_lines[i++], C_A "Shell: " C_O);
prog_lines[i] = "yutani-query -r";
sprintf(data_lines[i++], C_A "Resolution: " C_O);
sprintf(data_lines[i++], C_A "WM: " C_O "Yutani");
sprintf(data_lines[i++], C_A "WM Theme: " C_O "%s", wm_theme);
sprintf(data_lines[i++], C_A "Font: " C_O "DejaVu Sans Mono");
prog_lines[i] = "yutani-query -m";
sprintf(data_lines[i++], C_A "Font: " C_O);
//sprintf(data_lines[i++], C_A "CPU: " C_O "(query cpudet)");
//sprintf(data_lines[i++], C_A "GPU: " C_O "(hell if I know!)");
sprintf(data_lines[i++], C_A "RAM: " C_O "(query /proc/meminfo)");
prog_lines[i] = "free -ut";
sprintf(data_lines[i++], C_A "RAM: " C_O);
int j = 0;
for (unsigned int y = 0; y < gimp_image.height; y += 2) {
@ -81,7 +95,7 @@ int main(int argc, char * argv[]) {
}
if (j < i) {
printf("\033[0m %s\n", data_lines[j]);
print_thing(j);
j++;
} else {
printf("\033[0m\n");
@ -92,7 +106,7 @@ int main(int argc, char * argv[]) {
for (int x = 0; x < gimp_image.width; x++) {
printf(" ");
}
printf("\033[0m %s\n", data_lines[j]);
print_thing(j);
j++;
}
}

View File

@ -0,0 +1,57 @@
#include <stdio.h>
#include <getopt.h>
#include "lib/yutani.h"
#include "lib/shmemfonts.h"
yutani_t * yctx;
void show_usage(int argc, char * argv[]) {
printf(
"yutani-query - show misc. information about the display system\n"
"\n"
"usage: %s [-rfm?]\n"
"\n"
" -r \033[3mprint display resoluton\033[0m\n"
" -f \033[3mprint the name of the default font\033[0m\n"
" -m \033[3mprint the name of the monospace font\033[0m\n"
" -? \033[3mshow this help text\033[0m\n"
"\n", argv[0]);
}
int show_resolution(void) {
if (!yctx) {
printf("(not connected)\n");
return 1;
}
printf("%dx%d\n", yctx->display_width, yctx->display_height);
return 0;
}
int show_fontname(int font) {
init_shmemfonts();
printf("%s\n", shmem_font_name(font));
return 0;
}
int main(int argc, char * argv[]) {
yctx = yutani_init();
if (argc > 1) {
int index, c;
while ((c = getopt(argc, argv, "rfm?")) != -1) {
switch (c) {
case 'r':
return show_resolution();
case 'f':
return show_fontname(FONT_SANS_SERIF);
case 'm':
return show_fontname(FONT_MONOSPACE);
case '?':
show_usage(argc, argv);
return 0;
}
}
}
return 0;
}