Jump to content

Another bash quicky


Erroneous

Recommended Posts

I use mythtv. I use e17. Neither of which have a very good system for quickly seeing what time it is. Solution: have a voice tell you what time it is by pressing Alt+T, and date by pressing Alt+D. Here's how:

copy this code to a file called time.sh:

case "$1" in

  time)

    date "+ %l %M %p" | sed -e "s/00//g" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g' > .temp

   ;;

  date)

    date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g" > .temp

   ;;

  *)

    date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g" > .temp

    date "+ %l %M %p" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g' >> .temp

    ;;

esac



cat .temp

flite .temp -o .temp.wav

aplay -t wav .temp.wav &>/dev/null

rm .temp

rm .temp.wav

Install the following: alsa-utils, flite.

You want to have aplay or play commands, along with flite.

Then add the appropiate lines to whatever keybinding configs you have for your window manager run "sh ~/time.sh time" and "sh ~/time.sh date" when you press Alt+T and Alt+D, respectively. Here's the lines for fluxbox:

Mod1 t :ExecCommand sh ~/time.sh time

Mod1 d :ExecCommand sh ~/time.sh date

Restart/Reload your window manager and turn up your properly alsa-configured speakers to test it out.

Link to comment
Share on other sites

I never did like the use of files for these types of tasks...

case "$1" in

SPEECH="";

  time)

    SPEECH=$SPEECH `date "+ %l %M %p" | sed -e "s/00//g" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g'`

   ;;

  date)

    SPEECH=$SPEECH `date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g"`

   ;;

  *)

    SPEECH=$SPEECH `date "+ %A, %B %dth" | sed "s/1th/1st/g" | sed "s/2th/2nd/g" | sed "s/3th/3rd/g"`

    SPEECH=$SPEECH `date "+ %l %M %p" | sed -e 's/ 0/ oh /g' | sed -e 's/AM/a-m/g'`

    ;;

esac



echo $(SPEECH)

aoss flite -t $(SPEECH) play

WARNING: Untested script!

flite (which, I might add, is some truly shitty code. Not a comment in sight and fixed strings all over the place) only supports OSS. The aoss wrapping should enable playing in an ALSA environment. Remove if you're still using plain OSS.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...