#ifndef C8_STATUS_H
#define C8_STATUS_H
#include <stdbool.h>
#include <stdint.h>
#include <cairo.h>
/* What the network and battery icons show, from NetworkManager and
* UPower on the system bus. Shared by the shell and the lock screen. */
enum status_net {
STATUS_NET_UNKNOWN, // no NetworkManager: no icon
STATUS_NET_NONE, // not connected
STATUS_NET_WIRED,
STATUS_NET_WIFI,
STATUS_NET_MOBILE,
STATUS_NET_OTHER,
};
struct status {
enum status_net net;
bool limited; // connected, but no internet
bool airplane; // the radios are off
bool wifi_available; // there is a Wi-Fi device to turn on
int signal; // Wi-Fi, 0..100
char *net_name; // the connection's, or NULL
char *ap_path; // status.c's own: the access point read, while reading
bool battery; // there is one
int percent;
bool charging, on_battery;
};
extern struct status status;
/* Per cent at which a draining battery is critical: the icon turns red
* with a "!" (the first low-battery toast shows then too) */
#define STATUS_BATTERY_CRITICAL 15
typedef void (*status_fn)(void *data);
/* Starts watching; fn runs whenever something shown changed */
void status_init(void);
void status_listen(status_fn fn, void *data);
/* "Aethernet", "Not connected", "Airplane mode"… */
const char *status_net_label(void);
/* "73% remaining", "Charging", "Fully charged" (static buffer) */
/* The icons, drawn in the current source colour in a size × size box;
* bg is what they're drawn on (for the cut-outs) */
void status_draw_network(cairo_t *cr, double x, double y, double size);
void status_draw_plane(cairo_t *cr, double x, double y, double size);
void status_draw_battery(cairo_t *cr, double x, double y, double size,
uint32_t bg);
/* Wi-Fi bars at a given strength, for lists of networks */
void status_draw_bars(cairo_t *cr, double x, double y, double size,
int signal, bool dim);
#endif