wmcpumon 1.02 (GIT-v1.02-1-g0703c24)
|
multi CPU system monitor dockapp More...
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <poll.h>
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/shape.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_pixel.h>
#include <xcb/screensaver.h>
#include "wmcpumon.xpm"
Data Structures | |
struct | cpu_info |
collected data from /proc/stat More... | |
Defines | |
#define | SCREENSAVER |
config support screensaver | |
#define | MAX_CPUS 4 |
how many cpus are supported | |
#define | _GNU_SOURCE |
we need strchrnul | |
Functions | |
void | Timeout (void) |
called from event loop | |
xcb_image_t * | XcbXpm2Image (xcb_connection_t *connection, xcb_colormap_t colormap, uint8_t depth, uint32_t transparent, const char *const *data, uint8_t **mask) |
Convert XPM graphic to xcb_image. | |
xcb_pixmap_t | CreatePixmap (const char *const *data, xcb_pixmap_t *mask) |
Create pixmap. | |
void | Loop (void) |
Loop. | |
int | Init (int argc, char *const argv[]) |
Init. | |
void | Exit (void) |
Exit. | |
int | GetStat (void) |
Read stat. | |
int | GetMeminfo (void) |
Read meminfo. | |
int | GetMemory (void) |
Get memory used. | |
int | GetSwap (void) |
Get swap used. | |
void | DrawCpuGraphs (int loops) |
Draw CPU graphs. | |
void | DrawCpuBar (void) |
Draw CPU bar. | |
void | DrawMemGraphs (void) |
Draw memory information. | |
void | PrepareData (void) |
Prepare our graphic data. | |
static void | PrintVersion (void) |
Print version. | |
static void | PrintUsage (void) |
Print usage. | |
int | main (int argc, char *const argv[]) |
Main entry point. | |
Variables | |
xcb_connection_t * | Connection |
connection to X11 server | |
xcb_screen_t * | Screen |
our screen | |
xcb_window_t | Window |
our window | |
xcb_gcontext_t | NormalGC |
normal graphic context | |
xcb_pixmap_t | Pixmap |
our background pixmap | |
xcb_pixmap_t | Image |
drawing data | |
int | ScreenSaverEventId |
screen saver event ids | |
static int | StartCpu |
first cpu nr. to use | |
static int | Rate |
update rate in ms | |
static char | WindowMode |
start in window mode | |
static char | Logscale |
show cpu bar in logarithmic scale | |
static char | AllCpus |
use aggregate numbers of all cpus | |
static char | JoinCpus |
aggregate numbers of two cpus | |
static char | UseSleep |
use sleep while screensaver runs | |
static const unsigned char | Log10 [] |
logarithmic log10 table | |
struct cpu_info | CpuInfo [MAX_CPUS] |
cached cpu informations | |
int | Cpus |
number of cpus | |
static uint32_t | MemTotal |
cached memory info total memory | |
static uint32_t | MemFree |
cached memory info free memory | |
static uint32_t | Cached |
cached memory info cached memory | |
static uint32_t | SwapFree |
cached memory info free swap | |
static uint32_t | SwapTotal |
cached memory info total swap |
multi CPU system monitor dockapp
Copyright (c) 2010, 2011 by Lutz Sammer. All Rights Reserved.
Contributor(s): Bitmap and design based on wmc2d.
This file is part of wmcpumon
License: AGPLv3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
#define _GNU_SOURCE |
we need strchrnul
#define MAX_CPUS 4 |
how many cpus are supported
#define SCREENSAVER |
config support screensaver
xcb_pixmap_t CreatePixmap | ( | const char *const * | data, |
xcb_pixmap_t * | mask | ||
) |
Create pixmap.
data | XPM data | |
[out] | mask | Pixmap for data |
void DrawCpuBar | ( | void | ) |
Draw CPU bar.
void DrawCpuGraphs | ( | int | loops | ) |
Draw CPU graphs.
loops | How many loops was collected |
void DrawMemGraphs | ( | void | ) |
Draw memory information.
void Exit | ( | void | ) |
Exit.
int GetMeminfo | ( | void | ) |
Read meminfo.
FIXME: keep fd open!
int GetMemory | ( | void | ) |
Get memory used.
int GetStat | ( | void | ) |
Read stat.
FIXME: keep fd open!
int GetSwap | ( | void | ) |
Get swap used.
int Init | ( | int | argc, |
char *const | argv[] | ||
) |
Init.
argc | number of arguments |
argv | arguments vector |
void Loop | ( | void | ) |
Loop.
int main | ( | int | argc, |
char *const | argv[] | ||
) |
Main entry point.
argc | number of arguments |
argv | arguments vector |
void PrepareData | ( | void | ) |
Prepare our graphic data.
static void PrintUsage | ( | void | ) | [static] |
Print usage.
static void PrintVersion | ( | void | ) | [static] |
Print version.
void Timeout | ( | void | ) |
called from event loop
Timeout call back.
xcb_image_t* XcbXpm2Image | ( | xcb_connection_t * | connection, |
xcb_colormap_t | colormap, | ||
uint8_t | depth, | ||
uint32_t | transparent, | ||
const char *const * | data, | ||
uint8_t ** | mask | ||
) |
Convert XPM graphic to xcb_image.
connection | XCB connection to X11 server | |
colormap | window colormap | |
depth | image depth | |
transparent | pixel for transparent color | |
data | XPM graphic data | |
[out] | mask | bitmap mask for transparent |
char AllCpus [static] |
use aggregate numbers of all cpus
uint32_t Cached [static] |
cached memory info cached memory
xcb_connection_t* Connection |
connection to X11 server
int Cpus |
number of cpus
xcb_pixmap_t Image |
drawing data
char JoinCpus [static] |
aggregate numbers of two cpus
const unsigned char Log10[] [static] |
{ 0, 15, 23, 30, 34, 38, 42, 45, 47, 50, 52, 53, 55, 57, 58, 60, 61, 62, 63, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 73, 74, 75, 75, 76, 77, 77, 78, 78, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 84, 85, 85, 86, 86, 87, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 100, }
logarithmic log10 table
char Logscale [static] |
show cpu bar in logarithmic scale
uint32_t MemFree [static] |
cached memory info free memory
uint32_t MemTotal [static] |
cached memory info total memory
xcb_gcontext_t NormalGC |
normal graphic context
xcb_pixmap_t Pixmap |
our background pixmap
int Rate [static] |
update rate in ms
xcb_screen_t* Screen |
our screen
screen saver event ids
int StartCpu [static] |
first cpu nr. to use
uint32_t SwapFree [static] |
cached memory info free swap
uint32_t SwapTotal [static] |
cached memory info total swap
char UseSleep [static] |
use sleep while screensaver runs
xcb_window_t Window |
our window
char WindowMode [static] |
start in window mode