Tag Archives: ubuntu

Cyclic sound MP3 audio recording in ubuntu

I work in a relatively safe environment, yet it may very well happen that I need to prove something that someone said in my office, so I can hold it against them when the time comes.

My laptop is always turned on, so I could use it to record the environmental sounds around it, with a couple of requirements:

  • the recording must be totally unattended, starting when I turn on the pc, and stopping when I turn it off, without any user intervention
  • the recorded files must be somehow purged, starting from the oldest ones, so that my disk doesn’t get filled with audio files

As in the Ubuntu spirit, I tried to search for something that did the job right away, but with no luck.

So, still in the Ubunt spirit, I had to arrange it myself: the idea is to record the audio in chunks of 10 minutes, and each time delete the oldest files, so that there is a chosen number of max files inside the recording folder.

You will need the audio-recorder package for the job, install it as follows:

sudo apt-add-repository ppa:osmoma/audio-recorder
sudo apt-get update
sudo apt-get install audio-recorder

when the program is installed, open it (Alt-F2 and then launch audio-recorder), click on the “additional settings” button, and setup your default recording folder there, in this example it’s the folder “audiofiles” directly under your home folder.
Also I suggest changing the file naming standard to %Y-%m-%d-%H:%M:%S so that each recording can be easily associated with the time of starting.

Then, you need to make a bash script that will deal with starting a new recording, while closing the previous one, this is what I came up with:


/usr/bin/audio-recorder --display=:0.0 -c stop
/usr/bin/audio-recorder --display=:0.0 -c start
cd /home/username/audiofiles
rm `ls -t | awk 'NR>150'`

which does exactly the following: stops a previously open (if existing) instance of the program, and starts a new one, then deletes the oldest recorded audio chunks so that there are maximum 150 files inside the recording folder (if you want a different amount, just replace 150 with the number you prefer); please note that the recording folder written in this bash script must be the same that is set in the additional settings, so if you want to use a different folder make sure to set it up both in audio-recorder and in this bash script.
Also, please note that the username part of the path must be replaced with your ubuntu username.

You can create this bash script as a “recordaudio.sh” file in your home folder, and then be sure to chmod +x recordaudio.sh so you can execute it.

Then, you need something that actually starts the recording, and cron is our friend here.

Run the command

crontab -e

and if it’s the first time you run it,¬† you should be presented with a choice screen asking you which editor you prefer… absolutely choose nano!

Inside the editor screen, paste this:

*/10 * * * * /home/username/recordaudio.sh

where “username” must be replaced with you ubuntu username, then press Ctrl-X to save the file (press Y is prompted to confirm).

What this cron line does, is running the bash script we just created every ten minutes, so the recorded sound files will be 10 minutes long. If you want to change this length, just change the 10 in the command to the number of minutes you prefer.

Restart the pc, and notice how files are being created inside of your folder. After a while, you will also get over the set limit for the files, and you will notice how the number of files will always stay the same, with the oldest files being deleted.

How to drag and drop files between windows in Ubuntu Unity launcher bar

So I like Unity, it looks nifty and the Zeitgeist launcher is so productive.
One huge gripe about unity though, is that you cannot, apparently, drag&drop files between applications open in the Unity launcher bar, namely:

  • a file from nautilus into thunderbird as a mail attachment
  • an image from nautilus into a photo-editing program
  • the same file from nautilus into an archive manager
  • an image into the upload page of imgur.com opened in your browser
  • anything else

I use a Precise Pangolin installation, and this is what works for me:

  1. Start dragging the file until you have it under your mouse pointer, ready to be dropped somewhere
  2. At this point you will notice the launcher bar buttons become gray (almost all of them, Nautilus and Firefox stay bright for me)
  3. Trying to drop onto any of the buttons, be it grayed out or bright, will NOT bring up its window
  4. Keep the mouse button pressed, and on your keyboard use theWinKey+TAB combination, you will see the applications buttons on the unit launcher bar brighten one at a time, cycling though both bright ones and grayed ones
  5. When you have highlighted the button of the program you need (for example, Thunderbird to attach a file into a mail), release the WinKey+TAB combo and the relative application window will open
  6. Finally drop your file in the opened window
  7. After you’ve done your job, flood LaunchPad with bug reports until we get this dumb problem fixed

Ubuntu won’t start Gnome GDM after upgrade to Oneiric Ocelot

So I was upgrading my home server first from Maverick Meerkat to Natty Narwhal, and then from Natty to Oneric Ocelot.
It is not a plain desktop installation, as back in the time I installed Ubuntu Server and then built upon it adding Gnome without the useless stuff that comes with the ubuntu-desktop package.

Anyway, after upgrading to Oneiric the X interface went away, all I saw was the boot messages text by the kernel up to the Apache2 start, and nothing else. SSH was still accessible so I could go through it, but you could still use recovery console to access the system if you don’t have remote terminal capability installed.

Checking with dmesg I saw these error messages:

[ 24.974182] gdm-simple-slav[1009]: segfault at 0 ip 002945b7 sp bfe9b6c8 error 4 in libnss_compat-2.13.so[291000+6000] [ 38.598946] gdm-simple-slav[1218]: segfault at 0 ip 00a3b5b7 sp bf9c35c8 error 4 in libnss_compat-2.13.so[a38000+6000] [ 39.562834] gdm-simple-slav[1238]: segfault at 0 ip 005eb5b7 sp bff72138 error 4 in libnss_compat-2.13.so[5e8000+6000]

Upgrading again, via SSH, to Precise Pangolin didn’t solve the problem, so I googled aroung and found this bug on launchpad.

Apparently, the autologin feature prevents GDM from going on and just hangs there.

Briefly, what I did and worked in my case (mileage may vary) was:

sudo add-apt-repository ppa:gnome3-team/gnome3
sudo add-apt-repository ppa:ubuntugnometeam/ppa-gen
sudo apt-get update
sudo apt-get dist-upgrade
sudo mv /etc/gdm/custom.conf /etc/gdm/custom.conf.off

The last line is the command that removes the autologin (by renaming the conf file that activates it), after doing this and rebooting I was showed the login screen.

Backup installed packages list in Ubuntu and restore via Synaptic

To backup your Ubuntu install you don’t just need to keep a copy of the /home folder (or partition), since you would still need to re-fetch all the packages you installed, and that can be time consuming, especially if you carefully chose the applications to add to the system.

Synaptic already offers a similar function, which is File > Save Markings As… (be sure to fill the check box “Save full state, not only changes”, otherwise you will be probably getting a 0byte file). You can then use the File > Read Markings function to restore the package list on another system/install.

What’s the deal with this? The function actually saves indiscriminately a list of all the installed packages, including those that were installed just because they were a dependence. For example if you sudo apt-get/aptitude install packagename you will probably install also packagename-data and packagename-core or something along those lines, as they are dependencies of packagename, but the dependencies may be more complex and deeper (for example, packagename-core may also require other packages in turn); dependencies can change over time, so if package A requires package B today, a month from now that may be not true anymore; so if you passively restore the whole packagelist, you would be installing package B even if that’s not needed anymore.

The solution is to save a list of only the “main” packages, which will in turn require the correct dependencies; this can be achieved with:

aptitude search "~i ?not(~M)" -F "%p install" > packagelist.txt

This saves into packagelist.txt the list of the installed packages (~i) that were not installed automatically (not(~M)), mantaining the same format of the list generated by Synaptic, that is “packagename install” in each row, so you can seamlessly import it from Synpatic.

WinKey+Ubuntu, cool! Windows Key keyboard shortcuts in Maverick Meerkat

Maybe I’m posting about nothing new, and if that’s the case, I beg your pardon. Not.

’tis my website and I can write whatever I like.

Anyway I just completed the update of Ubuntu to Maverick Meerkat on my laptop, and well, I was trying to get to the desktop with the good old Ctrl-Ald-D combo, but it didn’t work. Hammered those keys at least 5 times to make sure, but then my lateral thinking suggested me to do WinKey+D instead (the combo I tried the very first time I used Ubuntu), and that worked!

So I went into a Windows Key frenzy, and tried, like, every combo I could test.

Here are my findings:

WinKey+W, WinKey+A
Show all windows in a tiles fashion

As I said, goes to desktop

A very cool version of the Alt-Tab

but here are the cool ones:

Zooms in/out the whole screen, moving the mouse shifts  the view, and
Zooms in all the way

WinKey+M, WinKey+N
Negative colour! Useless for practical uses, anyway the N combo renders negative only the currently active window space, while M makes negative everything onscreen.