Archive for the ‘Arch-Linux’ Category

Another Useful Copy Command

Saturday, May 8th, 2010

I last came up with this subject a while ago, whilst working on my own backup. Been needing something slightly different, which allows pulling out files of the same type. This one uses find rather than a straight cp function.

 find /pathtoinputdir/ -name “*.*” -type f -exec cp -urvp {} /pathtooutputdir \;

I’ll break it down again:

 find /pathtoinputdir/ (pretty obvious, you could use just / to search your whole drive)

 -name “*.*”  (what to search for, replace *.* with anything you want to search for, but say you wanted to find all your jpg files, change it to *.jpg)

-type -f   (brings back files as opposed to directories)

-exec   (allows a function to run based upon what is found by find)

cp -urvp {}  (the copy with arguments and some magic (the brackets) which allows files and directories with spaces, newlines etc. See my other post to get descriptions of the cp arguments. You could replace cp with mv if you wanted to move and not copy)

/pathtooutputdir  (straight forward again, I create it first)

\;    (more magic to go with the brackets)

Word of warning, if you have lots of files with the same name but different contents, you will overwrite the older ones with the latest one, regardless of content

Mp3 playlist script - for current directory and sub folders

Thursday, February 18th, 2010

Making mp3 playlists, a “simple” script

#!/bin/bash

touch ${PWD##*/}.m3u
export IFS=$’\n’
for i in $(find $1 -name “*.mp3″ -type f)
do
echo “$i” |sed ’s/..\(.*\)/\1/’ >> ${PWD##*/}.m3u
done

shuf ${PWD##*/}.m3u > ${PWD##*/}2.m3u
shuf ${PWD##*/}2.m3u > ${PWD##*/}.m3u
rm ${PWD##*/}2.m3u

You can leave out the last three lines if you don’t want to shuffle the list.

There is probably improved/easier code than this but it works for me.

To use, simply copy the code into a text file, save with a name of your choice, and make the file script executable. Put the file in your path, and then run in the directory you want to make a playlist from. it will work on all sub directories of that folder.

Mplayer - neat and tidy on the CLI

Wednesday, November 18th, 2009

How long have I been using mplayer? Years. Why has it never bothered me to sort this out before? Don’t know. Ageism, autism, or general grumpiness sent me off in search of a solution, and how easy was it.

Every time I have run mplayer from the cli I got three lines written out before the “action”:

mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

The very simple fix to this is to add an entry to your ~/.mplayer/config file

lirc=no

That’s it, no more extra lines. Remember to comment out “lirc=no” if you want to use a remote control, though :)

Grub Menu not Visible after attaching new widescreen Monitor! Solved!

Wednesday, November 18th, 2009

Was time to treat myself to an early Christmas present, so splashed out on the ridiculously cheap HannsG HH241 24″, 1980×1080 WUXGA monitor @ £140. Comes with a VGA-VGAcable abd a DVI-HDMI cable (monitor has an HDMI port)

Plugged it in, powered up.

Nvidia Geoforce 6200 Graphics card with DVI/VGA output
HannsG HH241 24″ widescreen 1980×1080 WUXGA, HDMI 1.3 compatible
Multibooting @ 5 OS’s

PC booted up fine with post/bios screen viewable, then a blank screen for a few seconds (where grub menu usually is, then usual starting up for Xubuntu 9.04 (the default OS in my grub menu (grub legacy)

Once X was running everything fine.

Tried all sorts, reinstalling grub to mbr, reconfiguring X, checked for settings in bios (none obvious), but nothing changed.

So switched to VGA-VGA cable, and grub menu was back. So I am kind of sorted, but wavy lines and distorted image during post and splash, and was getting a better picture and all round performance using the hdmi connection.

Previous monitor, an Iiyama 17″ LCD worked fine on a DVI-DVI cable.

Also, Xubuntu Progess screen during boot up was not centred, off to the right a bit.

After hours and hours and hours of googling, finally found a post about toshiba laptop owners not getting grub on a cold reboot. The recommendation was to install grub2
To install grub2 on Jaunty or below

sudo apt-get install grub2

Test it by loading grub2 as chainloader (this option is offered on installation)
You’ll need to “e” “e” and change root to uuid to get the chainloader to work

If you are happy run

sudo upgrade-from-grub-legacy

and grub2 will take over, And lo and behold, the grub menu is back! New things to learn in order to customise grub2 menu, and set up a splash image for it.  Xubuntu progress splash also nicely centred.

Best place to go for just about everything grub2 is here

get_iplayer - Command Line Downloader for BBC iplayer

Saturday, November 7th, 2009

get_iplayer

My favourite program of the moment which exceeds the delivery of the iPlayer on Windows in just about every way!

To get the best out of it, download the latest version (and everything else you need) from here, and also make sure you have the following installed to make the most of the features available:

flvstreamer
ffmpeg
mplayer

(If you must install on Windows, there is an installer which takes care of everything for you)

flvstreamer is especially useful for getting higher quality versions of programmes, but you may have to fiddle about with the location of the file and its permissions to get things working correctly.

Ok, here are the commands I use the most:

get_iplayer
(this gathers a full index of programmes available)

get_iplayer keyword
(gathers index but also finds matches for “keyword” of your choice, e.g. Dr Who or Casualty)

Running the two above will show you the index number for the programme. Use this as follows:

get_iplayer –info 123
(will provide detailed info about the programme, including the various versions and qualities available)

get_iplayer -get 123
(will download the default version, usually iPhone - mov quality)

get_iplayer -get 123 modes=flashhigh flvstreamer=’/usr/bin/flvstreamer’
(will download a higher quality version in mp4 format using flvstreamer, my binary is located in /usr/bin/)

Finally

get_iplayer –update
(simply checks for any updates to get_iplayer and installs them)

Further commands, help and information here

Set Firefox mailto links to GMail/Googlemail

Saturday, September 5th, 2009

Nice easy tip this one.

Open Firefox, and open up  GMail/Googlemail.

Paste this command into the address bar with the GMail/Googlemail page on view

javascript:window.navigator.registerProtocolHandler(”mailto”,”https://mail.google.com/mail/?extsrc=mailto&url=%s“,”GMail”)      << all one line

and click on green arrow

Firefox will ask if you want to add the application, to which you say yes.

Now click on a mailto link, and Firefox will ask you which email client you wish to use. Select Googlemail and also tick the box to allow this to persist.

Job done :)

Useful copy command for backing up

Tuesday, August 18th, 2009

Don’t like backup programs, but I do like cp. I save all my work to an external HDD but I like to make a copy of this onto my server, prior to burning. As I don’t do things in sequence, I may need to make several “backups” before commiting to disk, so needed an easy way of only copying over changed or new files:

cp -urvp /pathto/externaldrive/* /pathto/backup/directory/

What does it all do?

cp         the copy command

-u         update only new or changed files with a newer date

-r          recursive to all sub directories

-v          verbose, tell me what is happening

-p          preserve file attributes

In my case, the path to the external HDD is /media/HANDY120/* - (the device is a Fujitsu HandyDrive 120GB) . Don’t forget the / and the * at the end to ensure everything on the drive is copied.

The path to the backup location can be anywhere, but you must use the same route each time

[Solved] - Mencoder Freezing Computer (my computer!) or Segmentation Faulting

Sunday, June 14th, 2009

This has been an annoyance for sometime, when encoding anything with mencoder, but specifically ts files from recorded TV. Mencoder would start off fine and then freeze the PC completely or Seg Fault, not necessarily in the same place. Other PCs I have would encode fine using the same settings.

I found the solution today on the mplayerusers email list. About 18 months ago I had overclocked my machine, up from 1.7 to 1.9 mhz and increased the FSB. Apparently mencoder doesn’t like overclocked PCs, even though the writer with the solution said it wasn’t mencoder’s fault! So I put my settings back to “Optimal” / “Auto”, and everything is now rosy in the garden, just a tad slower than before :) I can live with that!

Fixing USB Remountable Devices in Minimal CLI Installations

Tuesday, May 19th, 2009

 Keep meaning to log this here, as I seem to have to do it every time I do a command line installation. For some reason, USB devices - flash drives, USB hard drives etc, refuse to mount, even with Thunar and volman installed. A repair is required to the PolicyKIt.conf as follows:

sudo nano /etc/PolicyKit/PolicyKit.conf

and add the following lines in between the <config> tags:

<match action=”org.freedesktop.hal.storage.mount-removable”>
<return result=”yes” />
</match>

You will possibly need a reboot to get this working right.

Now your USB devices should automount correctly

How to remux an avi with the right audio language track using MPlayer/Mencoder

Sunday, April 26th, 2009

MPlayer and Mencoder to the rescue again!

I downloaded a movie the other night which was advertised as having both Spanish and English soundtracks. I had found films like this before, but English had always been the first audio track, so had never been a problem. On this occasion, Spanish was the first audio track. I didn’t want to have to fiddle around with Geexbox getting the right language playing, so needed to sort this out, so that English was the audio track that played. I wasn’t too bothered about dropping the Spanish soundtrack.

Four “simple” steps.

  1. Confirm the aid number of the English language track. Running the video with mplayer in verbose mode produced enough information to find this easily, as track 2
    • mplayer -v inputvideo.avi
  2. Extract the english audio track from the avifile
    • mplayer -aid 2 -dumpaudio -dumpfile englishaudio.mp3  inputvideo.avi
  3. Copy the video track out without any sound
    • mencoder -ovc copy -nosound -o soundlessvideo.avi  inputvideo.avi
  4. Stick the soundless video and the English audio track back together
    • mencoder -ovc copy soundlessvideo.avi -oac copy -audiofile englishaudio.mp3  -o newvideo.avi

No encoding or transcoding going on, just demuxing and remuxing of the right parts. Apparently the use of -nosound can cause a/v sync issues, but in this case a/v sync was fine all the way through.

Found another way too, as doing the above with ac3 sound doesn’t sync well at all. Simply re-encode the audio and output to a new file:

mencoder -ovc copy  -oac mp3lame aid 2 inputfile.avi -o outputfile.avi

or to simply grab the second audio stream without encoding

mencoder -ovc copy -oac copy aid 2 inputfile.avi -o outputfile.avi