Linux Tips and Tricks

A collection of tips, tricks and everything linux

Archive for the ‘Bash’ tag

Using linux like a pro with mplayer, find & play mp3 files from command line in Ubuntu Linux 9.04 Jaunty

with 3 comments

Save precious CPU and memory by using mplayer to play mp3s, also keep your playlist file up to date with all your mp3 media files.

First and foremost we need to have mplayer installed, if your on a ubuntu-debian based system use the following command
to install mplayer, if not then you can download the appropriate packages and install them.

apt-get install mplayer

Lets make a home for our script file, and set the appropiate permissions

mkdir ~/scripts; touch ~/scripts/playme.sh; chmod +x ~/scripts/playme.sh; gedit ~/scripts/playme.sh

Paste the following code into your new script file, if you keep your Music files in a different location then change the variable musdir to match your setup.

#/bin/bash
# VARS ##########################################
tmpdir='/tmp'
musdir='/home/osamad/Music'
filename='playlist.m3u'
# CODE ##########################################
find $musdir -name '*.mp3' -o -name '*.ogg' 2>/dev/null >> $tmpdir/$filename
mplayer -playlist $tmpdir/$filename -shuffle -loop 0 -radio volume=80

playme

Using find we build a list of all our mp3s, in this case we have multiple types of media files we want to play so we can specify that by adding the -o -name flags and add them in.

  • -playlist ;flag we set the playlist file we just created
  • -shuffle ; enables shuffle mode
  • -loop 0 ; enables loop 0=forever
  • -radio volume=80 ; set the default volume to 80% (use * or / to adjust when playing)

RunTime

Push ALT+F2 or launch from a terminal

./scripts/playme.sh

playme-terminal

MORE

To find out more information, or to customize your mplayer settings

man mplayer

Create a custom launcher and run your script from the gnome-panel

Written by mnk0

May 1st, 2009 at 1:35 pm

Posted in Linux, Ubuntu, shell

Tagged with , , , ,

keep broken files when trying to unrar a failed crc chek on a rar archive file

without comments

ok just a quick note ,, if you’re tryin to unrar an archive thats been corrupted or been split up into multiple parts, keep the broken parts using unrar.

more description

4 Rar files, part1-4, 3 fails becuase of a crc check issue, so you can recover part of the archive using the keep broken flag for unrar ‘-kb’

mnk0@tree:~/downloads$ unrar x -kb Bleach_Naruto Shippuuden 98 - 720p.rar
UNRAR 3.80 beta 2 freeware Copyright (c) 1993-2008 Alexander Roshal
Extracting from Bleach_Naruto Shippuuden 98 - 720p.rar
Extracting Bleach_Naruto Shippuuden 98 - 720p.rar 99%
Calculating control sums of all volumes.
Cannot find volume Bleach_Naruto Shippuuden 98 - 720p.rar
Bleach_Naruto Shippuuden 98 - 720p.mkv - CRC failed
Total errors: 1
mnk0@tree:~/downloads$ ls Bleach_Naruto Shippuuden 98 - 720p.mkv*
Bleach_Naruto Shippuuden 98 - 720p.mkv
mnk0@tree:~/downloads$

Written by mnk0

March 7th, 2009 at 9:55 pm

Posted in Linux, Ubuntu, shell

Tagged with , , ,

Using find to search files on your system

without comments

Looking for something? Find has all the power you’ll need to locate any file or directory on your system, as long as you know the name of what you’re trying to find. :)

First you’ll need to launch a terminal session, and then we’ll dive into this by typing the following command.

find / -name 'my-file.txt' 2>/dev/null

Breaking down our ‘ find ‘ command

  • ‘ / ‘ - is our search location, since we’re using / it’ll search everything on our root partition
  • ‘ -name ‘ - says we’re gonna search by name, and we can type anything in here (* wildcard)
  • ‘ 2>/dev/null ‘ - will tell the shell to pipe all errors to dev/null meaning they wont be displayed

Written by mnk0

September 19th, 2008 at 11:37 pm

Posted in shell

Tagged with , ,