Function - play # uses mplayer random directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function - play # uses mplayer random directories
# 1  
Old 05-18-2013
Function - play # uses mplayer random directories

I have this in my .bashrc and use it to play my music. It is organized by directories and this will play them in random order:

Code:
play(){ ## play directories with mplayer (random)
if [ $# -eq 0 ]
then
    # if no option show music types
    echo -n "
play {directory|style}

Styles:
-------"
    find  ~/music/ -maxdepth 1 -type d -print | cut -d'/' -f5|sort
else
    # create tmp list
    xtitle "mplayer tunes!"
    clear
    [ ! -e $1 ] && cd ~/music
    find -L $1 -type f -name \*.\* >play.$$
    if [ "$1" == "vids" ]
    then
        \mplayer -fs -msgcolor -shuffle -playlist play.$$ 2>/dev/null
    else
        \mplayer -msgcolor -shuffle -playlist play.$$ 2>/dev/null
    fi

    \rm play.* 2>/dev/null
    cd -
fi
}

I have many other tools and such, if folks find them of use I will post them.

bd - Put your hand on a hot stove for a minute and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. That's Relativity. - A.E.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Mplayer fifo.

Hi all, First of all, sorry for the pastebin link. The code tags aren't working for me. #!/bin/bash # while-menu-dialog: a menu driven - Pastebin.com This is a channel "changer" shell script i'm working on. It uses dialog to display the menus. It... (3 Replies)
Discussion started by: ignatius
3 Replies

2. Shell Programming and Scripting

Recurse directories and return random file

I have a nice program to change the background but I want it to operate on subdirectories as well. # Script to randomly set Background from files in a directory while true;do # Directory Containing Pictures DIR="/home/pc/Pictures" # Internal Field Separator set to newline, so file names... (4 Replies)
Discussion started by: triplemaya
4 Replies

3. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

4. Shell Programming and Scripting

Function to remove the directories from PATH variable

Hello, From the URL https://www.unix.com/shell-programming-scripting/121303-remove-path-path-environment-variable-2.html I got a function to remove the directories from a path. but looks like this isnt quite working.. i am also not able to post the comments in the thread as it is closed. ... (6 Replies)
Discussion started by: satishkumar432
6 Replies

5. Shell Programming and Scripting

Extract function names and directories from php files

I need a script that extracts function names from php files together with their location (path and file in which they are defined). The php files are located in several directories under a base directory. Ideally the output should be something like: "Path/FileName/FunctionName" for a... (2 Replies)
Discussion started by: bamse
2 Replies

6. Shell Programming and Scripting

mplayer problem

I have this problem using a script that uses mplayer. This is the error messages. INFO: Mplayer Log LOG: MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team LOG: mplayer: could not connect to socket LOG: mplayer: No such file or directory LOG: Failed to open LIRC support. You... (1 Reply)
Discussion started by: locoroco
1 Replies

7. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

8. Solaris

mplayer on soalris

Hi all ... I would like to know how to install mplayer on solaris 10 i have been trying to understand it through the docs on their website but didnt get it that well.. So if anyone can give me step by step instructions to install it ..i would much appreciate it!!! Thanks (3 Replies)
Discussion started by: wrapster
3 Replies

9. Shell Programming and Scripting

random function script

hi, I need a command which picks the records randomly from the file. For example. i am having some 10000 entries in a file and need to extract the lines randomly without repeating the numbers. Do anybody have any idea on how to get this out. (4 Replies)
Discussion started by: prash_b
4 Replies

10. UNIX for Dummies Questions & Answers

Help me: Divx with MPlayer

Hi, I'm a beginner in linux :( I wanna play divx with MPlayer. I have mdk8.1 and I can't install MPlayer because I have gcc 2.96 I need upgrade my gcc to 2.95.2 or 2.95.4 Anyone can say me how do i do to uninstall gcc-2.96 and install gcc-2.95.2. Can you give me the exactly url to... (1 Reply)
Discussion started by: mercutio
1 Replies
Login or Register to Ask a Question
play(1) 						      General Commands Manual							   play(1)

NAME
play - play any sound file to audio device rec - record audio to any sound file format SYNOPSIS
play [fopts] infile [effect] rec [fopts] outfile [effect] DESCRIPTION
This manual page briefly documents the play and rec commands. play and rec are programs that allow you to play and record different types of sound files from the command line. They are front ends to the more general sox(1) package. Normally, the play command will automatically detect the type and other parameters of the soundfile. If it can't do so, the parameters can be changed through options. OPTIONS
A summary of common options are included below. For a complete description of options and their values, see the sox(1) man page. -c [channels], --channels=[channels] Define the number of channels in the file. -d [device], --device=[device] Specify a different device to play the sound file to. -f [format], --format=[format] Specify bit format of the sample. One of s, u, U, A, a, or g. -r [rate], --rate=[rate] Specify the sample rate of the audio data (samples per second). -s [size], --size=[size] Specify the width of each sample. One of b, w, l, f, d, or D. -t [type], --type=[type] Specify audio file format to use. Useful if it can not be automatically determined. -v [volume], --volume=[volume] Change the audio volume -x , --xinu Reverse the byte order of the sample (only works with 16 and 32-bit data). -h, --help Show summary of options. --version Show version of play/rec. Description of effects are described in the sox(1) man page. SEE ALSO
sox(1) soxexam(1) AUTHOR
This manual page was written by Guenter Geiger <geiger@iem.mhsg.ac.at>, for the Debian GNU/Linux system. Updates by Anonymous. December 11, 2001 play(1)