Linux.com

Event sounds in Fluxbox

 

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 the sounds.tar.gz file from this post in the sidux forum: http://www.sidux.com/PNphpBB2-viewtopic-t-13645-start-45.html if you are a sidux member, and/or don't want to mess with /usr/share/sounds, or don't have any sound files available.

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

For this guide, place the folder 'sounds', unpacked from the tar.gz, into: ~/.fluxbox.

Inside of 'sounds' are 7 .wav files that I either copied/changed/made, that have different uses based on what you want to hear for what event.
I made the sounds to my taste, but they 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. either grab the sounds.tar.gz file below, or find the paths to some good sound event .wav 's. From here on out I assume you grabbed the tar file. If not, you will need to change the paths in the menu code. (See below)

3. Unpack your sounds.tar.gz into ~/.fluxbox. This keeps everything together for backup purposes. You should now have a folder named 'sounds' in /home/user/.fluxbox.

4. 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:
[separator]
[submenu](Quit)
##### 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}
[end]
[separator]
[separator]


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!

 

Please comment if you are using this  'how -to'.  All suggestions and comments welcome. 

 

Comments

Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD211 Introduction to Linux for Developers
    08 Dec » 09 Dec - Virtual
    Details
  2. LFS220 Linux System Administration
    08 Dec » 11 Dec - Virtual
    Details
  3. LFD331 Developing Linux Device Drivers
    15 Dec » 19 Dec - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board