Silly sysinfo tool
This commit is contained in:
parent
8fae365760
commit
e05c9b78a0
98
userspace/extra/sysinfo.c
Normal file
98
userspace/extra/sysinfo.c
Normal file
@ -0,0 +1,98 @@
|
||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
* This file is part of ToaruOS and is released under the terms
|
||||
* of the NCSA / University of Illinois License - see LICENSE.md
|
||||
* Copyright (C) 2015 Kevin Lange
|
||||
*
|
||||
* sysinfo - visually based on screenfetch
|
||||
*
|
||||
* Displays system information in a visually-pleasing format.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "lib/graphics.h"
|
||||
#include "lib/yutani.h"
|
||||
|
||||
#include "gui/terminal/lib/termemu.h"
|
||||
#include "toaru_logo.h"
|
||||
|
||||
#define NUM_DATA_LINES 30
|
||||
|
||||
char data_lines[NUM_DATA_LINES][100];
|
||||
|
||||
#define C_A "\033[34;1m"
|
||||
#define C_O "\033[0m"
|
||||
|
||||
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);
|
||||
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)");
|
||||
//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);
|
||||
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");
|
||||
//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)");
|
||||
|
||||
int j = 0;
|
||||
for (unsigned int y = 0; y < gimp_image.height; y += 2) {
|
||||
for (unsigned int x = 0; x < gimp_image.width; x += 1) {
|
||||
unsigned char r_t = gimp_image.pixel_data[(x + y * gimp_image.width) * 4];
|
||||
unsigned char g_t = gimp_image.pixel_data[(x + y * gimp_image.width) * 4 + 1];
|
||||
unsigned char b_t = gimp_image.pixel_data[(x + y * gimp_image.width) * 4 + 2];
|
||||
unsigned char a_t = gimp_image.pixel_data[(x + y * gimp_image.width) * 4 + 3];
|
||||
unsigned char r_b = 0;
|
||||
unsigned char g_b = 0;
|
||||
unsigned char b_b = 0;
|
||||
unsigned char a_b = 0;
|
||||
if (y != gimp_image.height - 1) {
|
||||
r_b = gimp_image.pixel_data[(x + (y + 1) * gimp_image.width) * 4];
|
||||
g_b = gimp_image.pixel_data[(x + (y + 1) * gimp_image.width) * 4 + 1];
|
||||
b_b = gimp_image.pixel_data[(x + (y + 1) * gimp_image.width) * 4 + 2];
|
||||
a_b = gimp_image.pixel_data[(x + (y + 1) * gimp_image.width) * 4 + 3];
|
||||
}
|
||||
|
||||
uint32_t out = alpha_blend_rgba(
|
||||
rgba(0,0,0,TERM_DEFAULT_OPAC),
|
||||
premultiply(rgba(r_t, g_t, b_t, a_t)));
|
||||
|
||||
uint32_t back = alpha_blend_rgba(
|
||||
rgba(0,0,0,TERM_DEFAULT_OPAC),
|
||||
premultiply(rgba(r_b, g_b, b_b, a_b)));
|
||||
|
||||
/* Print half block */
|
||||
printf("\033[38;6;%d;%d;%d;%dm\033[48;6;%d;%d;%d;%dm▄",
|
||||
_RED(back), _GRE(back), _BLU(back), _ALP(back),
|
||||
_RED(out), _GRE(out), _BLU(out), _ALP(out));
|
||||
|
||||
}
|
||||
if (j < i) {
|
||||
printf("\033[0m %s\n", data_lines[j]);
|
||||
j++;
|
||||
} else {
|
||||
printf("\033[0m\n");
|
||||
}
|
||||
}
|
||||
|
||||
while (j < i) {
|
||||
for (int x = 0; x < gimp_image.width; x++) {
|
||||
printf(" ");
|
||||
}
|
||||
printf("\033[0m %s\n", data_lines[j]);
|
||||
j++;
|
||||
}
|
||||
}
|
101
userspace/extra/toaru_logo.h
Normal file
101
userspace/extra/toaru_logo.h
Normal file
@ -0,0 +1,101 @@
|
||||
/* GIMP RGBA C-Source image dump (toaru_logo.c) */
|
||||
|
||||
static const struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
unsigned char pixel_data[36 * 19 * 4 + 1];
|
||||
} gimp_image = {
|
||||
36, 19, 4,
|
||||
"\0x\306\1\2u\306C\5r\307\357\6p\310\370\4s\307\261\0w\306\37\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0~\312\2\0\211\321\0\0"
|
||||
"\0\0\0\0w\306\0\0y\305\1\2u\307D\7p\310\353\16g\311\377\14h\310\377\5p\307"
|
||||
"v\0\177\305\5\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\7f\273\0\0y\310\10\0~\312\12\0\206\316\7\0}\311\17"
|
||||
"\4h\276\33\3l\300W\1r\303\37\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0y\306$\11m"
|
||||
"\310\345\16f\311\377\6p\307\213\0}\305\12\0\0\0\0\0w\306\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\206\315\4\2p\303d\4"
|
||||
"j\300\223\5e\275|\4i\276\262\5e\274\370\12R\261\377\4i\276\320\0\0\0\0\0"
|
||||
"\0\0\0\0w\306\0\0\0\0\0\0|\305\40\10n\310\301\15g\311\377\6p\307\203\0}\305"
|
||||
"\10\0\0\0\0\0\0\0\0\0\203\310\1\3r\305!\2s\305O\0{\307\27\0\0\0\0\0\0\0\0"
|
||||
"\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\234\331\5\5g\276|\7]\271\377\11W\266\376\10\\\267\375"
|
||||
"\11Y\265\377\12Q\261\377\6b\272\266\0\224\326\15\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0~\305\22\10n\310\243\14h\310\377\6o\307\216\0|\305\12\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\3r\305Z\6l\304\377\6l\303\254\1u\305\"\0\0\0\0\0\0\0\0\0z\307\1\2"
|
||||
"s\305#\3p\304i\0{\310)\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0"
|
||||
"\0\0\0\0{\307\32\3i\276g\0t\305\225\4g\275\352\10X\265\376\4g\275\222\0\214"
|
||||
"\322\34\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\224\300\3\7o\310\205\14i\310\377"
|
||||
"\6p\307\237\0|\305\16\0\0\0\0\0\0\0\0\0~\307%\4p\305\252\14a\301\377\14_"
|
||||
"\300\377\4n\304\211\0~\310\12\0\0\0\0\0\0\0\0\2s\304E\6i\301\377\10d\277"
|
||||
"\255\0\207\314\25\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\2p\303\0\0\0\0"
|
||||
"\0\0\220\324\35\7`\271\265\7^\270\371\1p\302\220\0\234\333\27\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\5r\307f\14i\310\377\7o\307\275\0|\305"
|
||||
"\11\0\221\310\10\1v\306~\11i\304\326\15`\302\375\16\\\301\377\11e\302\377"
|
||||
"\3p\304~\0\217\315\2\1u\305L\0z\306I\0\213\315\14\6h\300\327\11a\275\342"
|
||||
"\0z\310\217\7d\276\267\4m\302\252\3q\303\6\0w\306\0\12Z\270\0\0\0\0\0\0\202"
|
||||
"\315$\6d\274\276\7`\272\377\5c\273\377\6`\271\333\10[\266\320\5a\272\265"
|
||||
"\0}\312O\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0y\306C\13i\307\347\10m\307\351"
|
||||
"\0y\306v\6n\305\323\15b\304\366\16`\303\377\12f\303\377\4n\305\314\2r\305"
|
||||
"T\1s\305\16\0\0\0\0\2t\305\232\10e\300\365\6h\301\326\11b\276\364\14X\272"
|
||||
"\375\11]\274\370\7d\276\377\2q\303\246\1u\305\5\5g\276\0\0\0\0\0\0~\312!"
|
||||
"\6d\274\303\13S\263\377\6a\272\377\3n\301\300\2o\302\217\2n\301\250\5`\271"
|
||||
"\376\11R\261\352\1s\303i\0\0\0\0\0w\306\0\0\0\0\0\0\177\305\32\11l\310\274"
|
||||
"\13i\307\377\14f\306\370\17b\305\377\11i\305\377\3q\306\277\1t\305E\1s\306"
|
||||
"\10\0\203\310\2\0\0\0\0\0\0\0\0\1u\305\16\2s\305\221\4m\302\332\7f\277\377"
|
||||
"\6j\301\346\3q\303\357\2r\304\234\0\204\314\13\0\0\0\0\0\0\0\0\0w\306\25"
|
||||
"\5f\276\304\13R\263\377\6e\275\312\0w\3063\0\227\323\2\0\177\312\4\0{\310"
|
||||
"\11\4i\275?\7Z\265\377\7Z\265\335\0\0\0\0\0\0\0\0\0\177\306\2\0w\306Z\10"
|
||||
"m\307\351\17d\307\377\11i\306\377\2t\306\257\0w\3061\0\0\0\0\0\0\0\0\0w\306"
|
||||
"\0\0w\306\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\4n\302&\6i\300\375\6g\300\370"
|
||||
"\11`\275\366\13[\272\377\6g\277\360\0t\305\222\0y\307\12\5g\275&\7`\272\377"
|
||||
"\7c\273\341\2p\302\317\6c\273\373\4k\300\322\0v\3058\0\0\0\0\2o\302\32\6"
|
||||
"\\\267\336\10W\264\376\0\0\0\0\0x\306\13\3s\307~\11l\310\377\15h\310\377"
|
||||
"\4r\306\312\0y\306:\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306"
|
||||
"\0\0\0\0\0\0}\310\4\2s\305c\5j\301\372\13\\\274\377\5j\301\346\6g\277\352"
|
||||
"\7d\276\367\5k\301\322\12Z\270\377\4k\300\334\0{\311\35\0w\307r\3n\301\237"
|
||||
"\6c\274\370\3k\300\311\12U\264\364\7`\272\377\0y\3073\4h\276F\7Y\264\377"
|
||||
"\6\\\266\316\0w\306\6\4s\307\200\12l\311\377\12k\311\357\2u\306\201\0\222"
|
||||
"\304\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\2r\305\200\10d\300\377\7f\277\343\5j\301\372\4n\302\320\11_\274\352"
|
||||
"\5i\300\247\0\0\0\0\1u\305\240\14R\264\377\1v\306\210\0\0\0\0\4i\277R\6c"
|
||||
"\274\376\6e\275\221\1t\304\265\15F\253\377\4i\276\341\5_\271\365\12Q\261"
|
||||
"\355\1v\304^\2v\307K\11n\311\377\12l\312\347\0w\306Z\0\0\0\0\0\0\0\0\0w\306"
|
||||
"\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0x\306K\11c"
|
||||
"\300\377\6j\302\321\0w\3065\6h\300\377\10c\276\377\6g\277\347\1r\3043\0\0"
|
||||
"\0\0\0|\311>\12X\267\377\5k\300\272\0\0\0\0\0\212\322\22\5f\274\216\10Z\267"
|
||||
"\357\7_\272\376\12S\262\374\12Q\261\364\10U\263\321\1v\306i\0\0\0\0\4t\310"
|
||||
"\311\15j\313\373\1v\305|\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4o\303\276\12a\277\377\0\177\311"
|
||||
">\3q\303>\10c\276\377\11`\275\354\3o\303\\\0\0\0\0\0\0\0\0\0y\307o\14S\265"
|
||||
"\377\2p\303\242\0\0\0\0\0\0\0\0\0\307\364\4\0|\310F\3k\300w\3j\277~\0u\305"
|
||||
"f\0\212\321&\0\0\0\0\0\0\0\0\6r\311\370\13l\313\350\0~\303-\0\0\0\0\0w\306"
|
||||
"\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\5j\302\337\11c\300\377\4l\302\211\7f\300\330\11a\275\377\10c\276\264"
|
||||
"\0\271\340\10\0\0\0\0\0}\310A\7a\274\337\11]\272\375\0}\311?\0\0\0\0\0w\306"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0w\306\0\0w\306\0\5s\310"
|
||||
"\333\16j\314\371\1v\306\206\0\361\245\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\240\316\7\0\177\3103\0\214\314\27\2q\304\215\7f"
|
||||
"\301\377\5k\302\377\5l\303\300\5j\301\360\5i\301\305\0x\306c\6g\277\240\7"
|
||||
"c\275\355\6d\275\377\2p\303m\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2u\307a\12m\312\377\15i\312"
|
||||
"\365\7o\310\311\2s\307\236\1v\306\202\0y\306r\0z\306n\0w\306|\2t\305\216"
|
||||
"\5o\305\266\7j\304\322\12d\301\337\10e\301\341\2s\305|\5l\303>\5l\3024\0"
|
||||
"z\310\35\1s\304:\3q\304\223\4m\302\370\4l\301\343\4l\301\225\3o\3027\0\214"
|
||||
"\320\5\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0w\306\10\3t\307t\7o\310\377\15i\311\377\17e\310\377"
|
||||
"\16d\307\372\16c\306\366\16b\305\365\16a\304\367\16`\303\372\16^\302\377"
|
||||
"\16\\\301\377\16Z\277\377\14_\277\377\3p\304\267\0~\310\4\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\2t\305\21\4l\302\40\4o\302\26\0|\310\12\0\0\0\0\0\0\0\0\0w\306\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0v\306\2\1u\306\33\1v\306o\3s\307\261\5p\307\331\6n\306"
|
||||
"\362\6n\305\375\6m\305\374\6m\305\360\6n\304\343\5o\305\311\2t\305\244\1"
|
||||
"v\306u\1v\306\31\0v\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0w\306\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user