rulururu

post Rock yourself to sleep

February 25th, 2008

Filed under: Linux, Music — Kai @ 7:00 am

When going to bed I usually listen to some good melotic rock rhythms until falling asleep. Most times my computer is supposed to play music for half an hour and then switch off.
I simply shutdown after thirty minutes:

shutdown -h 30

But what can you do if you just wanna stop the music after half an hour but the pc should keep on working all night. That’s what I asked myself yesterday night. I sorted out the problem by using DCOP which stands for Desktop COmmunication Protocol.

Essentially, DCOP is a “remote control” system, which allows an application or a script to be controlled from outside. I use this software for years for my remote control with LIRC (Linux Infrared Remote Control) to gives impulses to Amarok player.

The model is simple. Each application using DCOP is a client. They communicate to each other through a DCOP server, which functions like a traffic director, dispatching messages/calls to the proper destinations. All clients are peers of each other.

For example you can tell xmms to pause playing music:

dcop xmms player pause

To wait for thirty minutes and then stop Amarok is as simple as the previous example:

sleep 30m; dcop amarok player stop

If you have further interest in DCOP here’s a simple guide howto implement a DCOP interface yourself:
Creating a DCOP Interface

It’s interesting to know that in modern KDE systems, every KDE application supports a basic set of DCOP interfaces, even if the programmer of the application did not explicitly code in such support.

KDE API Reference:
The DCOP Desktop COmmunication Protocol library

post Making a audio-cd the easy way

February 2nd, 2008

Filed under: Linux, Music — Kai @ 4:35 pm

Almost everybody know that situation only too well - you quickly have to burn an audio cd (e.g. for a party) and need all the tracks on cover.

I used to burn the cd with K3b or Brasero and then made a screenshot which I quickly edited to a fitting size with gimp and finally printed it.

Yesterday I found a better way when coming accross cdlabelgen, a great console-tool for making printable cd covers.

Usage can for example be:

cdlabelgen -c "Led Zeppelin" -s "Mothership" -o cover.ps

with parameter -f you can point to a file containing the tracknames.

cdlabelgen -c "Led Zeppelin" -s "Mothership" -f tracklist.txt -o cover.ps

I generate this file with a really short python script which I do pipe and writing the stream into a textfile:

ls -l | ./tracklist.py > tracklist.txt

#!/usr/bin/env python
from fileinput import input
import re
for line in input():
        s = line.find("- ")
        if s >= 0:
                line = line[s+2:line.find(".")]
                print line

Combination of all this to a small bash script gives you a great solution that saves a lot of time:

  • Generate tracklist
  • Get cd-title
  • Generate printable cover (postscript file)
  • Convert mp3 files to wav
  • Burn tracks using e.g. cdrecord

The script might look similar to this:

#!/bin/sh

#get title folder name
title=`${1} | awk 'BEGIN {FS="/"} {print $NF}'`
#generate list
ls -l ${1} | ./listfiles.py > tmp.txt
#generate label
cdlabelgen -c "`echo $title`"  -f ./tmp.txt -o ~/Desktop/label.ps
#delete list
rm tmp.txt
#convert mp3 to wav and burn
for i in *.mp3; do mpg123 -v -w "${i%mp3}wav" "$i"; done
cdrecord -dev=ATA:1,0,0 -eject speed=4 -pad -audio *.wav

If your printer is able to print postcript you can print directly like this:

cdlabelgen <args> | lpr -P<printername> -o Resolution=None -o PageSize=A4

You can add much more to your cover like images, date, etc. just have a look at the manpage.

ruldrurd
Powered by WordPress, Content and Design by Kai Bellmann
Entries (RSS) and Comments (RSS)