1
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2
* vim: ts=4 sw=4 noet ai cindent syntax=c
4
* Conky, a system monitor, based on torsmo
6
* Any original torsmo code is licensed under the BSD license
8
* All code written since the fork of torsmo is licensed under the GPL
10
* Please see COPYING for details
12
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
13
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
15
* All rights reserved.
17
* This program is free software: you can redistribute it and/or modify
18
* it under the terms of the GNU General Public License as published by
19
* the Free Software Foundation, either version 3 of the License, or
20
* (at your option) any later version.
22
* This program is distributed in the hope that it will be useful,
23
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
* GNU General Public License for more details.
26
* You should have received a copy of the GNU General Public License
27
* along with this program. If not, see <http://www.gnu.org/licenses/>.
33
#include "text_object.h"
35
/* check for OS and include appropriate headers */
36
#if defined(__linux__)
38
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
40
#elif defined(__OpenBSD__)
46
unsigned int poolsize;
52
void update_entropy(void)
54
get_entropy_avail(&entropy.avail);
55
get_entropy_poolsize(&entropy.poolsize);
58
void print_entropy_avail(struct text_object *obj, char *p, int p_max_size)
61
snprintf(p, p_max_size, "%u", entropy.avail);
64
void print_entropy_perc(struct text_object *obj, char *p, int p_max_size)
67
percent_print(p, p_max_size, entropy.avail *
68
100 / entropy.poolsize);
71
void print_entropy_poolsize(struct text_object *obj, char *p, int p_max_size)
74
snprintf(p, p_max_size, "%u", entropy.poolsize);
77
void print_entropy_bar(struct text_object *obj, char *p, int p_max_size)
83
ratio = (double) entropy.avail /
84
(double) entropy.poolsize;
85
new_bar(obj, p, p_max_size, (int) (ratio * 255.0f));