Fluxbox sounds

Sound events in fluxbox

How to add event sounds to any fluxbox menu item.
This includes the login and logout sounds, as well as sounds for exit to login and restart fluxbox, and any other item you wish to have open with a sound event.

I tried to make this as simple as possible, and at the end of it all I think I have succeeded well in that respect.

You will need to edit three files, all in ~/.fluxbox, and grab some sounds from /usr/share/sounds or similar.

Inside the tar file is just a folder named sounds, that can be renamed, and/or placed wherever you choose.

For this guide,  make a new folder named  ‘sounds’ in: ~/.fluxbox, and sounds from wherever you like. /usr/share/sounds, or maybe imbedded in different applications folders.

Having a few .wav files in ~/.fluxbox/sounds should give you a good starting point to customizing your super cool fluxbox . . .er . . . box.
The sounds can be the .wav files in /usr/share/sounds, or anything else you want really. Maybe a nice guitar piece for the morning login.

Okay, Heres how.

1. You will need ‘sox’ for your sound events. Sox is the ‘Swiss Army Knife’ of sounds.

apt-get update && apt-get install sox

2. find the paths to some good sound event .wav ‘s. From here on out I assume you have some in ~/.fluxbox/sounds.
This also keeps everything together for backup purposes.

3. Login Sound
We are going to use the ‘play’ command in order to play the sound.wav files.
open ~/.fluxbox/startup, and add the below code to your startup file in order to have a sound event upon fluxbox startup.

########## Play startup sound event #########
#### (apt-get install sox first) ####
play ~/.fluxbox/sounds/login.wav > /dev/null 2>&1 &

before the lines that say:

# And last but not least we start fluxbox.
# Because it is the last app you have to run it with exec before it.
exec /usr/bin/fluxbox

Afterwards won’t allow the serenity you are looking for with your new, super cool sounds. Make sure to save your file.

5. You will need to make a change in your ~/.fluxbox/init file in order to use fluxbox-remote. It should read:

session.screen0.allowRemoteActions:   true

Make sure to save your file.
Fluxbox-remote is a utility that comes with fluxbox that allows you to run fluxbox commands from the terminal.
This is needed for the ‘exit’ command and the ‘restart’ command in your fluxbox menu, as you cannot attach to those commands. Yes, you could try adding: kill -SIGHUP $(xprop -root _BLACKBOX_PID | awk ‘{print $3}’) or similar, but fluxbox-remote sure is easier.

6. Here is the relevant part of my ~/.fluxbox menu:

##### The following code uses fluxbox-remote actions. You must
#### change this line in ~./fluxbox/init: session.screen0.allowRemoteActions, to "true" #####
[exec] (Restart Fluxbox) {play ~/.fluxbox/sounds/restart.wav > /dev/null 2>&1 && fluxbox-remote restart}
#[restart] (Restart Fluxbox)
[exec] (Exit to login) {play ~/.fluxbox/sounds/logout.wav > /dev/null 2>&1 && fluxbox-remote exit}
#[exit] (Exit to login)

##### The following two are for use with 'sudoers' change in /etc.(See sidux Fluxbox Wiki/forum.) #####
[exec] (Reboot) {play ~/.fluxbox/sounds/reboot.wav > /dev/null 2>&1 && sudo /sbin/shutdown -r now}
[exec] (Shutdown) {play ~/.fluxbox/sounds/logout.wav > /dev/null 2>&1 && sudo /sbin/shutdown -h now}

##### Following lines are for password use of shutdown and reboot. #####
#[exec] (Reboot) {play ~/.fluxbox/sounds/reboot.wav > /dev/null 2>&1 && su-to-root -X -c /sbin/reboot}
#[exec] (Shutdown) {play ~/.fluxbox/sounds/logout.wav > /dev/null 2>&1 && su-to-root -X -c /sbin/halt}

The above menu code will give you a submenu named ‘quit’ that has four furthur options inside; ‘Restart Fluxbox, Exit to Login, Reboot, and Shutdown. Add all of it, or only what you need, to your ~/.fluxbox/menu, Or whatever your ‘custom’ fluxbox menu has been named . . . ~/.fluxbox/menu1 for example.

7. If you have the sudoers tweak, you are done, and can check out your wicked cool sound events, and see how easy they are to change. If not, or if you choose not to change your sudoers file, you will want to comment out the lines for sudo use, and uncomment the others.

8. enjoy!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s