From 6ddc03b50d51439672e8db2a30ba1c3f404ac443 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Wed, 18 Feb 2009 20:34:26 +0000 Subject: [PATCH] Add clock format from merdely --- baraction.sh | 10 ++++++++++ scrotwm.1 | 5 ++++- scrotwm.c | 19 +++++++++++++------ scrotwm.conf | 1 + 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/baraction.sh b/baraction.sh index 061fab6..240b1fc 100644 --- a/baraction.sh +++ b/baraction.sh @@ -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 "" diff --git a/scrotwm.1 b/scrotwm.1 index 97f68ef..1838614 100644 --- a/scrotwm.1 +++ b/scrotwm.1 @@ -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 diff --git a/scrotwm.c b/scrotwm.c index 28f71b2..2902935 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -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); } } diff --git a/scrotwm.conf b/scrotwm.conf index 7c0014f..6459ed2 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -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 -- 1.7.10.4