diff options
| -rwxr-xr-x | examplebar.sh | 9 | ||||
| -rw-r--r-- | src/bardata.c | 16 | ||||
| -rw-r--r-- | src/tsar.c | 10 | ||||
| -rwxr-xr-x | tsarc | 1 |
4 files changed, 27 insertions, 9 deletions
diff --git a/examplebar.sh b/examplebar.sh index 5fef616..c089f7c 100755 --- a/examplebar.sh +++ b/examplebar.sh @@ -1,4 +1,9 @@ #! /bin/sh -./tsarc create test_comp & -./tsarc layout -left test_comp -center test_comp -right test_comp test_comp & +./tsarc create clock +./tsarc layout -left clock + +while true; do + ./tsarc set clock -text "`date +"%a %b %d, %r"`" + sleep 1 +done diff --git a/src/bardata.c b/src/bardata.c index 8888ac3..7cdca78 100644 --- a/src/bardata.c +++ b/src/bardata.c @@ -18,11 +18,6 @@ size_t comps_size = 0; comp_t *comps_left[16], *comps_right[16], *comps_center[16]; size_t left_size = 0, right_size = 0, center_size = 0; -void new_component(char *name) { - strcpy(comps[comps_size].name, name); - comps_size++; -} - comp_t *find_comp(char *name) { for (size_t i = 0; i < comps_size; i++) { if (strcmp(comps[i].name, name) == 0) { @@ -32,6 +27,14 @@ comp_t *find_comp(char *name) { return NULL; } +void new_component(char *name) { + comp_t* existing = find_comp(name); + if (existing) + return; + strcpy(comps[comps_size].name, name); + comps_size++; +} + void add_component(comp_side_t side, char *name) { comp_t *comp = find_comp(name); if (side == SIDE_LEFT) { @@ -65,6 +68,9 @@ void set_component(char argv[MAX_ARGS][MAX_ARG_LEN], int argc) { void set_layout(char argv[MAX_ARGS][MAX_ARG_LEN], int argc) { comp_side_t side = SIDE_LEFT; + left_size = 0; + center_size = 0; + right_size = 0; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-left") == 0) { @@ -7,6 +7,7 @@ #include <X11/Xft/Xft.h> #include <X11/Xlib.h> +#include <X11/Xatom.h> #include "pipe.h" #include "bardata.h" @@ -75,7 +76,13 @@ void init_x(void) { &win_attr ); - XMapRaised(display, win); + XClassHint class_hint; + class_hint.res_name = "tsarbar"; + class_hint.res_class = "Bar"; + + XSetClassHint(display, win, &class_hint); + + XMapWindow(display, win); load_font("monospace:size=10"); @@ -126,7 +133,6 @@ int main(void) { XResizeWindow(display, win, width, bar_height); - int x = 0; for (int i = 0; i < left_size; i++) { comp_t* comp = comps_left[i]; @@ -1,2 +1,3 @@ #! /bin/sh printf "%s\201" "$@" > /tmp/tsarc.pipe +printf "\n" > /tmp/tsarc.pipe |
