File: bar.h

package info (click to toggle)
i3blocks 1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 548 kB
  • sloc: ansic: 2,439; makefile: 30; javascript: 29; sh: 19
file content (73 lines) | stat: -rw-r--r-- 2,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * bar.h - definition of a status line handling functions
 * Copyright (C) 2014-2019  Vivien Didelot
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef BAR_H
#define BAR_H

#include <stdbool.h>

#include "block.h"
#include "sys.h"

struct bar {
	struct block *blocks;
	sigset_t sigset;
	bool term;
};

#define bar_printf(bar, lvl, fmt, ...) \
	block_printf(bar->blocks, lvl, "%s" fmt, bar->term ? "TTY " : "", ##__VA_ARGS__)

#define bar_fatal(bar, fmt, ...) \
	do { \
		fatal(fmt, ##__VA_ARGS__); \
		bar_printf(bar, LOG_FATAL, "Oops! " fmt ". Increase log level for details.", ##__VA_ARGS__); \
	} while (0)

#define bar_error(bar, fmt, ...) \
	do { \
		error(fmt, ##__VA_ARGS__); \
		bar_printf(bar, LOG_ERROR, "Error: " fmt, ##__VA_ARGS__); \
	} while (0)

#define bar_trace(bar, fmt, ...) \
	do { \
		trace(fmt, ##__VA_ARGS__); \
		bar_printf(bar, LOG_TRACE, "Trace: " fmt, ##__VA_ARGS__); \
	} while (0)

#define bar_debug(bar, fmt, ...) \
	do { \
		debug(fmt, ##__VA_ARGS__); \
		bar_printf(bar, LOG_DEBUG, "Debug: " fmt, ##__VA_ARGS__); \
	} while (0)

int bar_init(bool term, const char *path);

struct map;

/* i3bar.c */
int i3bar_read(int fd, size_t count, struct map *map);
int i3bar_click(struct bar *bar);
int i3bar_print(const struct bar *bar);
int i3bar_printf(struct block *block, int lvl, const char *msg);
int i3bar_setup(struct block *block);
int i3bar_start(struct bar *bar);
void i3bar_stop(struct bar *bar);

#endif /* BAR_H */