ref: 40035151954a2a870e07e5e28dc176c0de6eabf5
parent: e2f298b87ed295ed8ec54af3216ede910daef96e
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Feb 9 06:42:02 EST 2021
add -d option to specify date/time format
--- a/bar.c
+++ b/bar.c
@@ -15,7 +15,7 @@
static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw;
static char sep[16], bats[16], *aux;
-static char *pos = "rb", *items[64];
+static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];
static int itemw[64], nitems;
static Image *cback, *ctext;
static Tzone *local;
@@ -130,7 +130,7 @@
r = screen->r;
- tf = tmfmt(tmnow(&tm, local), "YYYY/MM/DD WW hh:mm:ss");
+ tf = tmfmt(tmnow(&tm, local), dfmt);
p.x = r.min.x + Off;
p.y = (pos[0] == 't' || pos[1] == 't') ? r.max.y - (f->height + Off) : r.min.y + Off;
if(pos[0] == 'l' || pos[1] == 'l'){
@@ -200,7 +200,7 @@
static void
usage(void)
{
- fprint(2, "usage: %s [-b] [-p lt|t|rt|lb|b|rb] [-s separator]\n", argv0);
+ fprint(2, "usage: %s [-b] [-d dateformat] [-p lt|t|rt|lb|b|rb] [-s separator]\n", argv0);
threadexitsall("usage");
}
@@ -251,6 +251,9 @@
ARGBEGIN{
case 'b':
bottom = 1;
+ break;
+ case 'd':
+ dfmt = EARGF(usage());
break;
case 'p':
pos = EARGF(usage());
--- a/bar.man
+++ b/bar.man
@@ -4,13 +4,16 @@
.SH SYNOPSIS
.B bar
[
-.I -s separator
+.I -b
]
[
+.I -d dateformat
+]
+[
.I -p position
]
[
-.I -b
+.I -s separator
]
.SH DESCRIPTION
.I bar
@@ -39,13 +42,18 @@
for "bottom". If neither left nor right is chosen, the window will be
placed in either top or bottom center.
.PP
+.I Bar
+keeps itself as a top window. To make it stay at the bottom, use
+.I -b .
+.PP
Separator can be changed with
.I -s
option.
.PP
-.I Bar
-keeps itself as a top window. To make it stay at the bottom, use
-.I -b .
+Date and time format may be set using
+.I -d
+option, see
+.I tmdate(2).
.SH SOURCE
https://git.sr.ht/~ft/bar
.SH BUGS