Archive for February, 2009

Converting mp3 files to iPhone ringtones in Linux

It should go without saying that with “iPhone” and “Linux” in the same sentence you’ll need a jailbroken phone for this. Use the following commands to dump your mp3 file to WAV then convert it to m4a:

1. mplayer -vo null -vc null -ao pcm:fast:file=file.wav file.mp3
2. faac -b 128 -c 44100 -w file.wav

You’ll end up with a file.m4a file. Once you have the OpenSSH package installed and running on your iPhone you can use the scp command to copy the ringtone to the correct location:

scp file.m4a root@iphone:/Library/Ringtones/file.m4r

The root password by default is “alpine”. As you can see the file will need to be renamed to end in “.m4r” instead of “.m4a” to be used as a ringtone. You’ll now be able to see it listed with the other ringtones under Settings -> Sounds -> Ringtone.

Saturday, February 28th, 2009 Technology 6 Comments

Changing GNOME desktop background based on time of day

This has already been done before, but I wanted to try to do it myself. It turned out a bit more complicated than I thought it would be on Ubuntu 8.10 and Fedora 10 because of the way gconftool-2 now interacts with D-BUS.

First, I created a script that could be used to change in between a set of predefined background images:

#!/bin/bash

case $1 in
1)
    gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/home/derrick/wallpaper/Solar_3200x1200_SunRiseTime.png";;
2)
    gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/home/derrick/wallpaper/Solar_3200x1200_DayTime.png";;
3)
    gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/home/derrick/wallpaper/Solar_3200x1200_SunSetTime.png";;
4)
    gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/home/derrick/wallpaper/Solar_3200x1200_NightTime.png";;
*)
    echo "Usage: bgchange.sh [1|2|3|4]";;
esac

Then, using the solution that allows gconftool-2 to communicate using dbus while being run by cron, I created another script:

#!/bin/bash

# Export the dbus session address on startup so it can be used by cron
touch $HOME/.Xdbus
chmod 600 $HOME/.Xdbus

env | grep DBUS_SESSION_BUS_ADDRESS > $HOME/.Xdbus
echo 'export DBUS_SESSION_BUS_ADDRESS' >> $HOME/.Xdbus

# Export XAUTHORITY value on startup so it can be used by cron
env | grep XAUTHORITY >> $HOME/.Xdbus
echo 'export XAUTHORITY' >> $HOME/.Xdbus

As the post says, I made the script run each time I logged in by selecting System -> Preferences -> Sessions and adding /home/derrick/bin/.make_Xdbus as a Startup program.

Next, I edited by crontab by running ‘crontab -e’ and adding the following jobs:

00 07 * * * . /home/derrick/.Xdbus; /home/derrick/bin/bgchange.sh 1
00 08 * * * . /home/derrick/.Xdbus; /home/derrick/bin/bgchange.sh 2
00 17 * * * . /home/derrick/.Xdbus; /home/derrick/bin/bgchange.sh 3
00 18 * * * . /home/derrick/.Xdbus; /home/derrick/bin/bgchange.sh 4

The /home/derrick/.Xdbus file is created each time I log in after adding the previous script as an entry in Sessions. You can adjust at what time the script changes the background to what picture. If you’re not familiar with crontab syntax you can take a look at the crontab(5) man page using the command ‘man 5 cron’.

Friday, February 27th, 2009 Technology 2 Comments