Friday, August 22, 2008

Squeezecenter & Ubuntu

After installing the .deb file from the Squeezecenter site, I had to delete a file and basically refresh a database to be able to connect through a browser. Here's how:
1. Stop apparmor and squeezecenter with the following commands-
sudo etc/init.d/apparmor stop
sudo etc/init.d/squeezecenter stop
2. Remove the problem file (/etc/apparmor.d/usr.sbin.mysqld.squeezecenter.orig). It is probably best to move this somewhere and not totally delete it. To move it to your home folder, type the following:
sudo mv /etc/apparmor.d/usr.sbin.mysqld.squeezecenter.orig ~/
3. Next delete the following database (this will be rebuilt when you restart squeezecenter):
sudo rm -fr /var/lib/squeezecenter/cache/MySQL/*
4. Now restart apparmor and squeezecenter with the following commands:
sudo etc/init.d/apparmor start
sudo etc/init.d/squeezecenter start
5. You may also have to reboot.
6. If all went well, you should be able to see your squeezecenter page by going to your server IP:9000 (Make sure you have used port forwarding, if needed, to open port 9000). For example, if your server is at 192.168.1.100, then point your browser to:
http://192.168.1.100:9000

Sources: flavor8's helpful post on the slimdevices forums

Wednesday, August 20, 2008

Apt-get Options

Here's a nice page with apt-get options and explanations.

Tuesday, August 19, 2008

Automatically Change Wallpapers

Lifehacker recently had a great article on ways to automatically rotate wallpapers including Gnome Wallchanger, Desktop Drapes, and Wallpaper Tray. As for the sunlight map mentioned in the article, I like the approach taken by areopa. The following will update the map as your wallpaper every hour:
1. First download the sunlight map here and change your background to use it as wallpaper (i.e. right click on your desktop and choose "change desktop background"). I will assume that you are downloading it to a folder called /home/user/wallpaper.
2. Then you need to write the following script:
wget -O /home/user/wallpaper/world_sunlight_map_rectangular.jpg http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg
Note: this is all on one line!
3. Next, move the script (I will assume you called it sunlight and saved it to your home directory) to cron.hourly with the following command:
sudo mv /home/user/sunlight /etc/cron.hourly

As a side note, to do this on a mac, follow the directions below:
1. Download the sunlight map from the link above and save it a folder of your liking. However, it must be the only file in that folder.
2. Set the file as your background and choose to have the wallpaper change. This should work because the file is the only one in the folder.
3. Download a program called Lingon and install it.
4. Run Lingon and add a new agent under "my agents."
5. Name it whatever you like such as "com.yourusername.sunlight"
6. In the what section, type the following command replacing "/path/to/world_sunlight_map_rectangular.jpg" to wherever you downloaded the file:
curl -o /path/to/world_sunlight_map_rectangular.jpg http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg
7. Finally, under the third section, "when," tell Lingon you want the command to run every 15 or 30 minutes.
8. Restart your computer and you should have an updating sunlight map as your wallpaper.

Sources:
Lifehacker article
World Sunlight Map
Lingon
cURL manual

Wget

Wget is basically a command line way to download things. I typically use it with the -O option which I have outlined below. See the sources for more options.

Using the "-O" option. This allows you to download a file to where you want on your system, rather than just in your home directory. With this option only, if you download a duplicate file, the older file will be overwritten.
Example: wget -O /path/to/file URL
(Note that URL is the full URL of the file on the web)

Using the "-r" option. With this option, a file will be downloaded on your system by duplicating its native folder structure. Try it out and you will see what I mean.
Example: wget -r URL

These options can, of course, be combined. A few rules I found confusing involved the following combinations listed below. These involve a situation where you are downloading a file that you had previously downloaded:

If no options are specified = Wget will not overwrite the previous file with the same name, but will simply download the new file adding a number to it. So if your original file is named cookie, if you download it again, it will be named cookie.1. If you download it a third time, it will be named cookie.2.


If you only use the "-nc" option = Wget will refuse to download newer copies of the file.

If you only use the "-r" option = re-downloading a file will result in the new copy simply overwriting the old. However, as noted, it will be downloaded in folders replicating its location on the web.

If you use both "-r" and "-nc" =
this causes the original version to be preserved and any newer copies on the server to be ignored (similar to only using the "-nc" option).

Therefore, I usually just use the "-O" option as described above so that a previous file of the same name can be overwritten and I avoid the extra folders.

Sources: Wget man page

Writing Scripts & Cron

Scripts are a way to simplify a list of commands or allow something else to execute commands. Here is an excellent summary of how they are written. Scripts must start by telling shell how to interpret them. Therefore, they often begin with:
#!/bin/bash
On the next lines, simply enter the commands you wish to be executed. Once you have made a script, you then usually want to then change the permissions so everything can execute it. For example, to give full read/write/execute permissions (which may not be appropriate in all situations), run the following command:
sudo chmod 777 /path/to/script

To have the script you have created executed at a regular interval, you can move it to one of the cron folders. These include /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly. For example, to have a script executed hourly, move it to cron.hourly with the following command:
sudo mv /path/to/script /etc/cron.hourly

Sources: Writing Shell Scripts

Aliases

Aliases are ways to simplify a command to one word. (Sometimes, moving a script to /usr/bin will accomplish the same thing). To setup an alias, you need to add it to ~/.bashrc (i.e. /home/user/.bashrc). It seems /etc/bash.bashrc might also work (see sources listed below). To add it to .bashrc, do the following:
1. Bring up .bashrc for editing with the following command:
sudo gedit /home/user/.bashrc
Note that user = your user name
2. Add an alias to the file and save. The syntax for an alias is the following:
Alias nickname='command'
For example, you might have something like this-
Alias songbird='/opt/Songbird/songbird'

Sources:
Lifehacker-Ten Handy Bash Aliases
Ubuntu-Environment Variables (explains why .bashrc is used)

Saturday, August 09, 2008

ipblock/java problems

ipblock (part of iplist and similar to moblock) wasn't working for me and the problem appears to have been with java. To fix it, I did the following:
1. First, make sure sun java, rather than openjdk, is your default. To do this, run the following command:
sudo update-alternatives --config java
Choose the sun version as your default by entering the appropriate number.
2. Then make sure your launcher command is correct. It should be:
sudo ipblock -g

Sources: iplist cli reference