Add clock format from merdely

This commit is contained in:
Marco Peereboom 2009-02-18 20:34:26 +00:00
parent f1d671a567
commit 6ddc03b50d
4 changed files with 28 additions and 7 deletions

View file

@ -1,5 +1,14 @@
#!/bin/sh
print_date() {
# The date is printed to the status bar by default.
# To print the date through this script, set clock_enabled to 0
# in scrotwm.conf. Uncomment "print_date" below.
FORMAT="%a %b %d %R %Z %Y"
DATE=`date "+${FORMAT}"`
echo -n "${DATE} "
}
_print_cpu() {
typeset -R4 _1=${1} _2=${2} _3=${3} _4=${4} _5=${5}
echo -n "CPU:${_1}% User${_2}% Nice${_3}% Sys${_4}% Int${_5}% Idle "
@ -71,6 +80,7 @@ while :; do
APM_DATA=`/usr/sbin/apm -alb`
fi
if [ $I -gt 2 ]; then
# print_date
print_cpu $REPLY
print_apm $APM_DATA
echo ""

View file

@ -132,7 +132,7 @@ Toggle version in status bar
.It Cm M-t
Toggle focused window between tiled and floating
.It Cm M-S Aq Cm Delete
Lock scren
Lock screen
.It Cm M-S-i
Reinitialize physical screens
.It Cm M1
@ -184,6 +184,9 @@ External script that populates additional information in the status bar,
such as battery life.
.It Cm bar_delay
Update frequency, in seconds, of external script that populates the status bar.
.It Cm clock_enabled
Enable or disable displaying the clock in the status bar. Disable by
setting to 0 so a custom clock could be used in the bar_action script.
.It Cm spawn_term
External application that gets spawned when
.Cm M-S- Ns Aq Cm Return

View file

@ -173,6 +173,7 @@ int bar_extra = 1;
int bar_extra_running = 0;
int bar_verbose = 1;
int bar_height = 0;
int clock_enabled = 1;
pid_t bar_pid;
GC bar_gc;
XGCValues bar_gcv;
@ -552,7 +553,9 @@ conf_load(char *filename)
break;
case 'c':
if (!varmatch(var, "color_focus", &i))
if (!strncmp(var, "clock_enabled", strlen("clock_enabled")))
clock_enabled = atoi(val);
else if (!varmatch(var, "color_focus", &i))
setscreencolor(val, i, SWM_S_COLOR_FOCUS);
else if (!varmatch(var, "color_unfocus", &i))
setscreencolor(val, i, SWM_S_COLOR_UNFOCUS);
@ -695,14 +698,18 @@ bar_update(void)
} else
strlcpy(bar_ext, "", sizeof bar_ext);
time(&tmt);
localtime_r(&tmt, &tm);
strftime(s, sizeof s, "%a %b %d %R %Z %Y", &tm);
if (clock_enabled == 0)
strlcpy(s, "", sizeof s);
else {
time(&tmt);
localtime_r(&tmt, &tm);
strftime(s, sizeof s, "%a %b %d %R %Z %Y ", &tm);
}
for (i = 0; i < ScreenCount(display); i++) {
x = 1;
TAILQ_FOREACH(r, &screens[i].rl, entry) {
snprintf(loc, sizeof loc, "%s %d:%d %s %s",
s, x++, r->ws->idx + 1, bar_ext, bar_vertext);
snprintf(loc, sizeof loc, "%d:%d %s%s %s",
x++, r->ws->idx + 1, s, bar_ext, bar_vertext);
bar_print(r, loc);
}
}

View file

@ -12,6 +12,7 @@ bar_font_color[1] = rgb:a0/a0/a0
bar_font = -*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*
#bar_action = ./baraction.sh
#bar_delay = 1
clock_enabled = 1
# spawn app
spawn_term = xterm