gchar * hi_get_field(gchar * field) { gchar *tmp; if (!strcmp(field, "Memory")) { MemoryInfo *mi; mi = computer_get_memory(); tmp = g_strdup_printf("%dMB (%dMB used)", mi->total, mi->used); g_free(mi); } else if (!strcmp(field, "Random")) { return g_strdup_printf("%d", rand() % 200); } else if (!strcmp(field, "Uptime")) { tmp = computer_get_formatted_uptime(); } else if (!strcmp(field, "Date/Time")) { time_t t = time(NULL); tmp = g_new0(gchar, 32); strftime(tmp, 32, "%D / %R", localtime(&t)); } else if (!strcmp(field, "Load Average")) { tmp = computer_get_formatted_loadavg(); } else { tmp = g_strdup(""); } return tmp; }
gchar *hi_get_field(gchar * field) { gchar *tmp; if (g_str_equal(field, "Memory")) { MemoryInfo *mi = computer_get_memory(); tmp = g_strdup_printf("%dMB (%dMB used)", mi->total, mi->used); g_free(mi); } else if (g_str_equal(field, "Uptime")) { tmp = computer_get_formatted_uptime(); } else if (g_str_equal(field, "Date/Time")) { time_t t = time(NULL); tmp = g_new0(gchar, 64); strftime(tmp, 64, "%c", localtime(&t)); } else if (g_str_equal(field, "Load Average")) { tmp = computer_get_formatted_loadavg(); } else { tmp = g_strdup(""); } return tmp; }
gchar * hi_info(gint entry) { static Computer *computer = NULL; static gchar *tmp = NULL; /*if (tmp != NULL) { g_free(tmp); tmp = NULL; } */ if (!computer) { computer = computer_get_info(); } switch (entry) { case COMPUTER_NETWORK: return g_strdup_printf("[$ShellParam$]\n" "ReloadInterval=3000\n" "ViewType=1\n" "%s", network_interfaces); case COMPUTER_SENSORS: return g_strdup_printf("[$ShellParam$]\n" "ReloadInterval=3000\n" "%s", sensors); case COMPUTER_SHARES: return g_strdup_printf("[SAMBA]\n" "%s", shares_list); case COMPUTER_FILESYSTEMS: return g_strdup_printf("[$ShellParam$]\n" "ViewType=1\n" "ReloadInterval=5000\n" "[Mounted File Systems]\n%s\n", fs_list); case COMPUTER_SUMMARY: tmp = computer_get_alsacards(computer); return g_strdup_printf("[$ShellParam$]\n" "UpdateInterval$Memory=1000\n" "UpdateInterval$Date/Time=1000\n" "[Computer]\n" "Processor=%s\n" "Memory=...\n" "Operating System=%s\n" "User Name=%s\n" "Date/Time=%s\n" "[Display]\n" "Resolution=%dx%d pixels\n" "OpenGL Renderer=%s\n" "X11 Vendor=%s\n" "[Multimedia]\n" "%s\n" "#[Storage]\n" "#IDE Controller=\n" "#SCSI Controller=\n" "#Floppy Drive=\n" "#Disk Drive=\n", computer->processor->model_name, computer->os->distro, computer->os->username, computer->date_time, computer->display->width, computer->display->height, computer->display->ogl_renderer, computer->display->vendor, tmp); case COMPUTER_DISPLAY: return g_strdup_printf("[Display]\n" "Resolution=%dx%d pixels\n" "Vendor=%s\n" "Version=%s\n" "[Monitors]\n" "%s" "[Extensions]\n" "%s" "[OpenGL]\n" "Vendor=%s\n" "Renderer=%s\n" "Version=%s\n", computer->display->width, computer->display->height, computer->display->vendor, computer->display->version, computer->display->monitors, computer->display->extensions, computer->display->ogl_vendor, computer->display->ogl_renderer, computer->display->ogl_version); case COMPUTER_OPERATING_SYSTEM: tmp = computer_get_formatted_uptime(); return g_strdup_printf("[$ShellParam$]\n" "UpdateInterval$Uptime=10000\n" "UpdateInterval$Load Average=1000\n" "[Version]\n" "Kernel=%s\n" "Compiled=%s\n" "C Library=%s\n" "Distribution=%s\n" "[Current Session]\n" "Computer Name=%s\n" "User Name=%s\n" "#Language=%s\n" "Home Directory=%s\n" "Desktop Environment=%s\n" "[Misc]\n" "Uptime=%s\n" "Load Average=...", computer->os->kernel, computer->os->compiled_date, computer->os->libc, computer->os->distro, computer->os->hostname, computer->os->username, computer->os->language, computer->os->homedir, computer->os->desktop, tmp); case COMPUTER_LANGUAGE: return g_strdup_printf("[$ShellParam$]\n" "ViewType=1\n" "[Available Languages]\n" "%s", computer->os->languages); case COMPUTER_PROCESSORS: return processor_get_info(computer->processor); default: return g_strdup("[Empty]\nNo info available="); } }