Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sound notification wrapper for KDE
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
sven
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 274

PostPosted: Tue Feb 01, 2005 6:20 pm    Post subject: Sound notification wrapper for KDE Reply with quote

This is a simple wrapper for the KDE notification system. If you don't use arts - like me - because your soundcard supports hardware mixing then you can tell KDE to use an external player for its system sounds. I've written this wrapper because aplay can only play WAVE files (at least it cannot play Ogg) - KDE uses a mixture of Ogg and WAVE files though. Enter this script as external player in the configuration dialog and it will choose the appropriate player for you. It supports WAVE, Ogg and MP3 and relies on aplay, ogg123 (vorbis-tools) and mpg123.

Just copy the below source code and paste it into an empty file, name it knwrapper and save it in /usr/bin for example. Be sure to set the executable flag! I'm sure someone else has written something similar but a quick search didn't come up with anything like it.

Code:
#!/bin/bash
#
# knwrapper - KDE notification wrapper
# v1.0.1
# 2005/02/02
#
# This is a simple wrapper for the KDE notification system.
# If you don't use arts - like me - because your soundcard
# supports hardware mixing then you can tell KDE to use an
# external player for its system sounds. I've written this
# wrapper because aplay can only play WAVE files - KDE
# uses a mixture of Ogg and WAVE files though. Enter this
# script as external player in the configuration dialog
# and it will choose the appropriate player for you. It
# supports WAVE, Ogg and MP3 and relies on aplay, ogg123
# (vorbis-tools) and mpg123.
#
# Sven Jacobs <sven.jacobs@web.de>
# www.sven-jacobs.de

WAVE=aplay
OGG=ogg123
MP3=mpg123

if [ $# == 1 ]; then
  FILETYPE=`file -b "${1}"`

  if expr "${FILETYPE}" : ".*WAVE.*" >/dev/null 2>&1
  then
    ${WAVE} "${1}" >/dev/null 2>&1
  elif expr "${FILETYPE}" : ".*Ogg.*" >/dev/null 2>&1
  then
    ${OGG} "${1}" >/dev/null 2>&1
  elif expr "${FILETYPE}" : ".*MP3.*" >/dev/null 2>&1
  then
    ${MP3} "${1}" >/dev/null 2>&1
  fi
fi


Have fun! And btw: I'm not responsible for any damage this script may cause and blablabla ... you know what I mean ;-)


Last edited by sven on Wed Feb 02, 2005 7:05 am; edited 1 time in total
Back to top
View user's profile Send private message
sven
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 274

PostPosted: Wed Feb 02, 2005 7:04 am    Post subject: Reply with quote

I've modified the above script a bit so that it can play files with spaces in their filenames.
Back to top
View user's profile Send private message
Gvalandor
n00b
n00b


Joined: 14 Apr 2003
Posts: 12
Location: Finland

PostPosted: Sat Jul 30, 2005 12:13 pm    Post subject: Reply with quote

I simply use play from the sox package.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum