Replace fetchy.c
This commit is contained in:
parent
6b6c3bf0d2
commit
dbcc7275ea
12
fetchy.c
12
fetchy.c
|
@ -129,6 +129,8 @@ void read_line(char x){
|
|||
}
|
||||
|
||||
|
||||
|
||||
// taken from https://github.com/ss7m/paleofetch
|
||||
void truncate_spaces_leading(char *str){
|
||||
int src = 0, dst = 0;
|
||||
while(*(str + dst) == ' ') dst++;
|
||||
|
@ -148,7 +150,7 @@ void truncate_spaces_leading(char *str){
|
|||
void truncate_spaces_trailing(char *str){
|
||||
int index, i = -1;
|
||||
|
||||
/* Find last index of non-white space character */
|
||||
|
||||
i = 0;
|
||||
while(str[i] != '\0'){
|
||||
if(str[i] != ' ' && str[i] != '\t' && str[i] != '\n'){
|
||||
|
@ -157,7 +159,7 @@ void truncate_spaces_trailing(char *str){
|
|||
i++;
|
||||
}
|
||||
|
||||
/* Mark next character to last non-white space character as NULL */
|
||||
|
||||
str[index + 1] = '\0';
|
||||
}
|
||||
|
||||
|
@ -173,7 +175,7 @@ static char *get_sys(char *sys, char *os_name){
|
|||
|
||||
snprintf(os_name, BUF_SIZE, "%s Linux", name);
|
||||
|
||||
if ( !strcmp( name, "Arch") || !strcmp( name, "Artix") ) *sys = 'a';
|
||||
if ( !strcmp( name, "Arch")) *sys = 'a';
|
||||
if ( !strcmp( name, "Ubuntu")) *sys = 'u';
|
||||
|
||||
free(name);
|
||||
|
@ -300,9 +302,11 @@ static char *get_RAM(char *ram_info){
|
|||
truncate_spaces_leading(line);
|
||||
sscanf(line, " MemTotal: %f", &total);
|
||||
|
||||
fgets(line, BUF_SIZE * 3, RAM);
|
||||
|
||||
fgets(line, BUF_SIZE * 3, RAM);
|
||||
truncate_spaces_leading(line);
|
||||
sscanf(line, " MemFree: %f", &free_mem);
|
||||
sscanf(line, " MemAvailable: %f", &free_mem);
|
||||
|
||||
fclose(RAM);
|
||||
|
||||
|
|
Loading…
Reference in a new issue