mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
add tiny clock program (C) i'm using in the status bar
This commit is contained in:
parent
da620b0cee
commit
1c6b90997b
64
scripts/clock.c
Normal file
64
scripts/clock.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
dwm status bar provider. use as ~/.xinitrc or call it in your xinitrc
|
||||||
|
or xsession in place of dwm.
|
||||||
|
|
||||||
|
to compile: gcc -Os -s -o dwm-status dwm-status.c
|
||||||
|
|
||||||
|
Copyright (c) 2007, Tom Menari <tom dot menari at googlemail dot com>
|
||||||
|
Copyright (c) 2007, Don Stewart
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
/* configuration */
|
||||||
|
#define REFRESH_RATE 60
|
||||||
|
#define TIME_FORMAT "%H.%M %a %b %d"
|
||||||
|
#define TIME_FORMAT2 "PDT %H.%M"
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
char b[34];
|
||||||
|
char c[34];
|
||||||
|
time_t epochtime;
|
||||||
|
struct tm *realtime;
|
||||||
|
|
||||||
|
time_t pdttime;
|
||||||
|
struct tm *pdtrealtime;
|
||||||
|
|
||||||
|
double load;
|
||||||
|
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
getloadavg(&load, 1);
|
||||||
|
|
||||||
|
epochtime = time(NULL);
|
||||||
|
realtime = localtime(&epochtime);
|
||||||
|
strftime(b, sizeof(b), TIME_FORMAT, realtime);
|
||||||
|
|
||||||
|
setenv("TZ","America/Los_Angeles", 1);
|
||||||
|
pdttime = time(NULL);
|
||||||
|
pdtrealtime = localtime(&pdttime);
|
||||||
|
strftime(c, sizeof(c), TIME_FORMAT2, pdtrealtime);
|
||||||
|
|
||||||
|
fprintf(stdout, "%s | %s | %.2f | xmonad 0.3 \n", b, c, load);
|
||||||
|
fflush(stdout);
|
||||||
|
sleep(REFRESH_RATE);
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user