Added ram info for freebsd

This commit is contained in:
TheDarkBug 2021-07-24 12:44:54 +02:00
parent f698a01020
commit d12f45aaa4
2 changed files with 7 additions and 1 deletions

View file

@ -20,6 +20,8 @@ KDE NeOwOn, nixOwOs; Plus FweeBSD, OwOpenBSD and macOwOS; Plus WinyandOwOws.
- [lshw](https://github.com/lyonel/lshw) to get GPU info.
- [freecolor](http://www.rkeene.org/oss/freecolor/) to get ram usage on FreeBSD.
### Via package manager
Right now, the package is only available on the AUR:

View file

@ -297,7 +297,7 @@ int uptime_mac()
#ifdef __FREEBSD__
int uptime_freebsd()
{
{ // this code is from coreutils uptime: https://github.com/coreutils/coreutils/blob/master/src/uptime.c
int boot_time = 0;
static int request[2] = { CTL_KERN, KERN_BOOTTIME };
struct timeval result;
@ -516,7 +516,11 @@ void get_info()
#ifndef __CYGWIN__
FILE *meminfo;
#ifdef __FREEBSD__
meminfo = popen("LANG=EN_us freecolor -om 2> /dev/null", "r");
#else
meminfo = popen("LANG=EN_us free -m 2> /dev/null", "r");
#endif
while (fgets(line, sizeof(line), meminfo))
// free command prints like this: "Mem:" total used free shared buff/cache available
sscanf(line, "Mem: %d %d", &ram_total, &ram_used);