From dbe4291409f06607bc22b6b0dba280754c5b26bc Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 7 Mar 2008 18:04:13 +0000 Subject: [PATCH] Select cow size from command line git-svn-id: http://svn.nickg.me.uk/work/xcowsay@282 a97b1542-0b21-0410-a459-e47997c36f34 --- display_cow.c | 3 ++- xcowat | 6 ++---- xcowfortune | 6 ++---- xcowsay.c | 11 ++++++++++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/display_cow.c b/display_cow.c index e2b024b..cb2dfff 100644 --- a/display_cow.c +++ b/display_cow.c @@ -62,7 +62,8 @@ static cowstate_t next_state(cowstate_t state) static GdkPixbuf *load_cow() { char cow_path[MAX_COW_PATH]; - snprintf(cow_path, MAX_COW_PATH, "%s/cow_med.png", DATADIR); + snprintf(cow_path, MAX_COW_PATH, "%s/%s_%s.png", DATADIR, + get_string_option("image_base"), get_string_option("cow_size")); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(cow_path, NULL); if (NULL == pixbuf) { diff --git a/xcowat b/xcowat index fb0fe0f..4f8fae6 100755 --- a/xcowat +++ b/xcowat @@ -6,13 +6,11 @@ # Might not have a display if [ "$DISPLAY" = "" ]; then - export DISPLAY=:0.0 + DISPLAY=:0.0 fi # xcowsay may not be on the PATH... # ...but it should be in the same directory as xcowat PATH=$PATH:`dirname $0` -export PATH - -echo "DISPLAY=$DISPLAY env xcowsay \"$2\"" | at $1 +echo "env DISPLAY=$DISPLAY PATH=$PATH xcowsay \"$2\"" | at $1 diff --git a/xcowfortune b/xcowfortune index 06d6378..118be81 100755 --- a/xcowfortune +++ b/xcowfortune @@ -6,7 +6,7 @@ # I run this via a cron job where DISPLAY isn't set if [ "$DISPLAY" = "" ]; then - export DISPLAY=:0.0 + DISPLAY=:0.0 fi # xcowsay may not be on the PATH... @@ -16,6 +16,4 @@ PATH=$PATH:`dirname $0` # fortune is often in /usr/games which may not be on the PATH PATH=$PATH:/usr/games -export PATH - -exec env fortune | env xcowsay +exec env PATH=$PATH fortune | env PATH=$PATH DISPLAY=$DISPLAY xcowsay $@ diff --git a/xcowsay.c b/xcowsay.c index 693d8ee..b8a18a2 100644 --- a/xcowsay.c +++ b/xcowsay.c @@ -14,7 +14,9 @@ #define DEF_MIN_TIME 1000 #define DEF_MAX_TIME 30000 #define DEF_FONT "Bitstream Vera Sans 14" -#define DEF_READING_SPEED 250 // Human average is apparently 200-250 WPM (=4 WPS) +#define DEF_READING_SPEED 200 // Human average is apparently 200-250 WPM (=5 WPS) +#define DEF_COW_SIZE "med" +#define DEF_IMAGE_BASE "cow" #define MAX_STDIN 4096 // Maximum chars to read from stdin @@ -25,6 +27,7 @@ static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"time", required_argument, 0, 't'}, {"font", required_argument, 0, 'f'}, + {"cow-size", required_argument, 0, 'c'}, {"reading-speed", required_argument, 0, 'r'}, {"daemon", no_argument, &daemon_flag, 1}, {"debug", no_argument, &debug, 1}, @@ -56,6 +59,7 @@ static void usage() " -r, --reading-speed=N\tNumber of milliseconds to delay per word.\n" " -f, --font=FONT\tSet message font (Pango format).\n" " -d, --daemon\t\tRun xcowsay in daemon mode.\n" + " --cow-size=SIZE\tSize of the cow (small, med, large).\n" " --debug\t\tKeep daemon attached to terminal.\n\n" "Default values for these options can be specified in the xcowsay config\n" "file. See the manpage for more information [Or not... ;-)]\n\n" @@ -86,6 +90,8 @@ int main(int argc, char **argv) add_int_option("max_display_time", DEF_MAX_TIME); add_int_option("reading_speed", DEF_READING_SPEED); add_string_option("font", DEF_FONT); + add_string_option("cow_size", DEF_COW_SIZE); + add_string_option("image_base", DEF_IMAGE_BASE); int c, index = 0, failure = 0; const char *spec = "hdrt:f:"; @@ -97,6 +103,9 @@ int main(int argc, char **argv) case 'd': daemon_flag = 1; break; + case 'c': + set_string_option("cow_size", optarg); + break; case 'h': usage(); exit(EXIT_SUCCESS); -- 2.39.2