aports

Custom Alpine Linux aports

git clone https://git.8pit.net/aports.git

 1/* See LICENSE for license details. */
 2
 3/* Delay (in seconds) used between updates of the status text. */
 4static const int delay = 5;
 5
 6/* Separator to use between different status function outputs. */
 7static const char *statsep = " | ";
 8
 9/* Format to use in the curtime function for the current time. */
10static const char *timefmt = "%a %d %b -- %H:%M:%S";
11
12/* Path to power supply battery file in /sys. */
13static const char *sysbat = "/sys/class/power_supply/BAT0";
14
15/* Path to control file for current charge. */
16static const char *syscur = "charge_now";
17
18/* Path to control file for full charge. */
19static const char *sysfull = "charge_full_design";
20
21/* Sound card to use for alsa output. */
22static const unsigned int sndcrd = 0;
23
24/* Name of the control channel to use for alsa output. */
25static const char* swtchname = "Master Playback Switch";
26static const char* volumname = "Master Playback Volume";
27
28/* Only use batcap function if the device has a battery. */
29static size_t batcapmay(char *dest, size_t n) {
30	size_t ret;
31	static int hasbat = -1;
32
33	if (hasbat == -1) {
34		if (access(sysbat, F_OK)) {
35			hasbat = 0;
36			return 0;
37		}
38		hasbat = 1;
39	} else if (!hasbat) {
40		return 0;
41	}
42
43	ret = batcap(dest, n);
44	if (ret)
45		ret += separator(&dest[ret], n - ret);
46
47	return ret;
48}
49
50/* Array of functions to use in the status bar text. */
51static size_t (* const sfuncs[])(char*, size_t) = {
52	batcapmay,
53	alsavol,
54	separator,
55	loadavg,
56	separator,
57	curtime,
58};