<commit_before>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <X11/Xlib.h>
#include <unistd.h>

#define MAXSTR  1024

static void XSetRoot(const char *  name)
{
	Display *  display ;
	display = XOpenDisplay(0x0) ;

	if (display == NULL)
	{
		//This should not happen, but, you know...
		fprintf(stderr, "Cannot open display!\n");
		exit(1);
	}

	XStoreName(display, DefaultRootWindow(display), name) ;
	XSync(display, 0) ;

	XCloseDisplay(display) ;
}

static void GetCPUUsage(long double *  result)
{
	long double  a[4] ;
	long double  b[4] ;

	FILE *  fp ;

	fp = fopen("/proc/stat", "r");
	fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
	fclose(fp);
	sleep(1);

	fp = fopen("/proc/stat", "r");
	fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &b[0], &b[1], &b[2], &b[3]);
	fclose(fp);

	*result = ((b[0] + b[1] + b[2]) - (a[0] + a[1] + a[2]))
				/ ((b[0] + b[1] + b[2] + b[3]) - (a[0] + a[1] + a[2] + a[3])) ;
}

static void GetTime(char *  result)
{
	time_t       curtime  ;
    struct tm *  loc_time ;

    //Initialize result to empty string.
    result[0] = '\0' ;

    //Getting current time of system
    curtime = time (NULL) ;

    strcat(result, "d");
}

int main(void)
{
	char         status[MAXSTR] ;
	char         time  [MAXSTR] ;
	long double  cpuUsage = 0   ;

	for (;;)
	{
		//printf("The current CPU utilization is : %Lf\n", loadavg);
		GetCPUUsage(&cpuUsage) ;
		snprintf(status, MAXSTR, "%.2Lf%%", cpuUsage * 100) ;
		//GetTime(time) ;
		strcat(status, time) ;
		XSetRoot(status) ;
	}

	return (0) ;<commit_msg>Add time :-)<commit_after>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <X11/Xlib.h>
#include <unistd.h>

#define MAXSTR  1024

static void XSetRoot(const char *  name)
{
	Display *  display ;
	display = XOpenDisplay(0x0) ;

	if (display == NULL)
	{
		//This should not happen, but, you know...
		fprintf(stderr, "Cannot open display!\n");
		exit(1);
	}

	XStoreName(display, DefaultRootWindow(display), name) ;
	XSync(display, 0) ;

	XCloseDisplay(display) ;
}

static void GetCPUUsage(long double *  result)
{
	long double  a[4] ;
	long double  b[4] ;

	FILE *  fp ;

	fp = fopen("/proc/stat", "r");
	fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
	fclose(fp);
	sleep(1);

	fp = fopen("/proc/stat", "r");
	fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &b[0], &b[1], &b[2], &b[3]);
	fclose(fp);

	*result = ((b[0] + b[1] + b[2]) - (a[0] + a[1] + a[2]))
				/ ((b[0] + b[1] + b[2] + b[3]) - (a[0] + a[1] + a[2] + a[3])) ;
}

static void GetTime(char *  result)
{
	time_t       curtime  ;
    struct tm *  loc_time ;
    char		 temp[99] ;

    //Initialize result to empty string.
    result[0] = '\0' ;

    //Getting current time of system
    curtime = time (NULL) ;

    // Converting current time to local time
    loc_time = localtime (&curtime);

    sprintf(temp, "%02d", loc_time->tm_hour) ;
    strcat(result, temp);
    strcat(result, ":");

    sprintf(temp, "%02d", loc_time->tm_min) ;
    strcat(result, temp);
    strcat(result, ":");

    sprintf(temp, "%02d", loc_time->tm_sec) ;
    strcat(result, temp);
}

int main(void)
{
	char         status[MAXSTR] ;
	char         time  [MAXSTR] ;
	long double  cpuUsage = 0   ;

	for (;;)
	{
		//printf("The current CPU utilization is : %Lf\n", loadavg);
		GetCPUUsage(&cpuUsage) ;
		snprintf(status, MAXSTR, "%.2Lf%%", cpuUsage * 100) ;
		GetTime(time) ;
		strcat(status, "|") ;
		strcat(status, time) ;
		XSetRoot(status) ;
	}

	return (0) ;
{'fraction_non_alphanumeric': 0.20352472996020465, 'fraction_numerical': 0.0267197271176805, 'mean_word_length': 3.1448763250883394, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1800603', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1496, 'n_words': 349}