]> code.delx.au - spectrwm/commitdiff
Add clock format from merdely
authorMarco Peereboom <marco@conformal.com>
Wed, 18 Feb 2009 20:34:26 +0000 (20:34 +0000)
committerMarco Peereboom <marco@conformal.com>
Wed, 18 Feb 2009 20:34:26 +0000 (20:34 +0000)
baraction.sh
scrotwm.1
scrotwm.c
scrotwm.conf

index 061fab6013a94ce4b8d530fcba91132627b779e8..240b1fcb16499eab7bde685270155aa09bf4295e 100644 (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 ""
index 97f68ef64364df127aa1626b1b4924358fee3a4e..183861491833c7a05031e25080877dd87bce8257 100644 (file)
--- 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
index 28f71b2c913f35a650c380b9fcc7703a0587445d..29029359553aa69b1f02a2ea70a3a90807626df5 100644 (file)
--- 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);
                }
        }
index 7c0014ffd4ddcbb1786a3cc3f991dc56d3d1ac27..6459ed2b1f66bfb6ea1fd68ee20b5ad5c2ad1366 100644 (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