Ubuntu


Control which application launches when you attach your MP3 player – Ubuntu

So you plug in your iPod, and Rhythmbox automatically starts up. But maybe you want GTKPod to start up, or maybe you don’t want any application to automatically launch when you attach your music player. Here’s how to control this:

Open nautilus (file browser).
Click Edit -> Preferences -> Media tab. Click the button next to “Music Player”.

This is the setting that controls what happens when you attach your MP3 player. You can choose another program from the list, choose a program that is not listed, tell it to ask you each time, or choose “Do Nothing”.

This is a Gnome feature, so it should work on any Linux distribution that is running Gnome (Fedora, Suse, Arch, Debian, etc).

Posted in Ubuntu   |   Comments (0)

Ubuntu – Auto-login and lock screen

I like to set up my Ubuntu workstation to automatically log into my account and then immediately lock the screen. This allows all my processes to start up and also allows me to VNC into the main console session via the Remote Desktop (vino) server. There are a few ways to set this up:

First, set up auto-login:
System > Administration > Login Window > Security tab
Check ‘Enable Automatic Login’ and choose your username. Click ‘Close’.

As for locking the screen after login, you can try adding the following command to System > Preferences > Sessions:
gnome-screensaver-command --lock
or
xdg-screensaver lock

I found that these commands worked for me when logging in and out of the box. However, I found that they did not work for me when I rebooted my workstation. If any of the other commands listed Sessions utilize gnome-keyring, such as ‘mail-notification’, the gnome-keyring password prompt seems to keep the screen from being locked. To work around this, I created a script called ‘lockstartup’. This script does the following:

1. Pauses for 10 seconds (a step I found necessary in order to get the script to work correctly)
2. Locks the screen
3. Pauses for another 10 seconds (again, a step I found necessary)
4. Starts any applications that use gnome-keyring

Here is what my script looks like:

#!/bin/sh
sleep 10
xdg-screensaver lock
sleep 10
mail-notification

After you save the script, make it executable:
$ chmod +x lockstartup

And then add it to System > Preferences > Sessions. If you reboot, you should be automatically logged in and then see the screen lock. Once you unlock the screen you should be presented with the gnome-keyring password prompt.

I am using this on Ubuntu 8.10 Intrepid Ibex. I have not tested this on any other releases.

Posted in Ubuntu   |   Comments (9 )

Convert mp3 to swf on Linux

I had an mp3 file that I wanted to convert to an SWF Flash file so that I could share a link to it in a project I was working on. Here’s how I did it:

First, install ffmpeg and swftools
$ sudo apt-get install ffmpeg swftools

Convert the mp3 file to wav format
$ ffmpeg -i in.mp3 out.wav

Convert the wav file to an SWF Flash file
$ wav2swf -o filename.swf out.wav -s 44100 -l 100 -d

Posted in Ubuntu   |   Comments (3 )

Install PulseAudio on Xubuntu 8.10 (XFCE)

Here is how to install and use PulseAudio on Xubuntu 8.10 Intrepid Ibex.

1. Install packages for PulseAudio
$ sudo apt-get install libasound2-plugins pulseaudio pulseaudio-esound-compat pulseaudio-module-gconf pulseaudio-module-hal pulseaudio-module-lirc pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-utils paman padevchooser paprefs pavucontrol pavumeter libao-pulse

2. Configure Alsa
Edit the file /etc/asound.conf as root. Create it if it doesn’t exist. Enter the following in this file and save:

pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

3. Add your user account to the pulse groups:

$ sudo gpasswd -a YOURUSERNAME pulse
$ sudo gpasswd -a YOURUSERNAME pulse-access
$ sudo gpasswd -a YOURUSERNAME pulse-rt

4. Configure PulseAudio
Click Applications > Settings > PulseAudio Preferences
On the Network Access tab, check:
– Enable network access to local sound devices
– Allow other machines on the LAN to discover local sound devices
– Don’t require authentication

On the Multicast/RTP tab, check:
– Enable Multicast/RTP receiver
– Enable Multicast/RTP sender

Configure PulseAudio to run as a daemon and allow users to load modules. Edit the file /etc/default/pulseaudio as root.
Change PULSEAUDIO_SYSTEM_START=0 to 1
Change DISALLOW_MODULE_LOADING=1 to 0

Edit the file /etc/libao.conf as root, create it if it doesn’t exist. Enter the following into that file:
default_driver=pulse

Restart your session or reboot to have changes go into effect.

Sources: Ubuntu Wiki, ivotron on Ubuntu Forums, pulseaudio.org

Posted in Ubuntu   |   Comments (12 )

Remote Desktop (VNC) Access on Xubuntu (XFCE) 8.10

Gnome on Ubuntu comes with an included “Remote Desktop” feature (vino) that allows you to VNC into your existing desktop session (usually on the :0 display). However, XFCE does not have a native VNC package built in. The best option I have found is to use vino, the same VNC app that Gnome uses. Here’s how:

Install vino:
$ sudo apt-get install vino

Configure vino:
$ vino-preferences

Then enter this command in your Autostarted Apps to start vino server:
/usr/lib/vino/vino-server

This works well for me, the only feature I have found that doesn’t work is the “disable wallpaper on remote login” setting.

Posted in Ubuntu   |   Comments (9 )

Change screen resolution from the command line with xrandr

The command xrandr can be used to change the screen resolution from the command line. Execute the xrandr command to see available screen resolutions. The output will look like this:

Screen 0: minimum 320 x 240, current 1440 x 900, maximum 1440 x 900
default connected 1440x900+0+0 0mm x 0mm
   1440x900       50.0*
   1360x768       51.0     52.0
   1152x864       53.0
   1024x768       54.0
   960x600        55.0
   960x540        56.0
   840x525        57.0     58.0
   800x600        59.0     60.0
   800x512        61.0
   720x450        62.0
   700x525        63.0
   680x384        64.0     65.0
   640x512        66.0
   640x480        67.0     68.0
   576x432        69.0
   512x384        70.0
   400x300        71.0
   320x240        72.0

To change the resolution:
xrandr -s 1024x768

Posted in Ubuntu   |   Comments (6 )

Pretty Anti-Aliased Fonts

sudo dpkg-reconfigure fontconfig-config

Select “Autohinter”, “Always” and “No” when prompted.
sudo dpkg-reconfigure fontconfig

Add the following to ~/.Xdefaults (create the file if it doesn’t exist):

Xft.antialias: true
Xft.hinting:   true
Xft.hintstyle: hintfull
Xft.rgba:      rgb
Xft.dpi: 96

Add this command to your startup commands:
xrdb -merge ~/.Xdefaults

Restart X.

Posted in Ubuntu   |   Comments (1)

Enable SHMConfig for Synaptics Touchpad on Ubuntu Intrepid Ibex 8.10

****EDIT****
These instructions are no longer needed for me. I don’t need to install Gsynaptics to disable my touchpad. I can now simply click System > Preferences > Mouse, click the “Touchpad” tab and uncheck “Enable Touchpad. The touchpad stays disabled, even through reboots. I’m leaving the original post here in case this doesn’t work on your system.

**** Original Post ****
In order to disable your Synaptics touchpad on previous releases of Ubuntu, you would set “SHMConfig” to “true” in xorg.conf and then install the program gsynaptics to disable/enable the touchpad.

The xorg.conf file is different in Intrepid Ibex, there is no section for the touchpad anymore. Now to enable SHMConfig you have to do it via HAL:

Edit this file:
/usr/share/hal/fdi/policy/20thirdparty/11-x11-synaptics.fdi

Find the section that starts with:
<match key="info.product" contains="Synaptics TouchPad">

And add this line to that section before :
<merge key="input.x11_options.SHMConfig" type="string">On</merge>

The file should end up looking something like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.touchpad">
      <match key="info.product" contains="Synaptics TouchPad">
        <merge key="input.x11_driver" type="string">synaptics</merge>
	<!-- Arbitrary options can be passed to the driver using
	     the input.x11_options property since xorg-server-1.5. -->
	<!-- EXAMPLE:
	<merge key="input.x11_options.LeftEdge" type="string">120</merge>
	-->
	<merge key="input.x11_options.SHMConfig" type="string">On</merge>
      </match>
      <match key="info.product" contains="AlpsPS/2 ALPS">
        <merge key="input.x11_driver" type="string">synaptics</merge>
      </match>
      <match key="info.product" contains="appletouch">
        <merge key="input.x11_driver" type="string">synaptics</merge>
      </match>
      <match key="info.product" contains="bcm5974">
        <merge key="input.x11_driver" type="string">synaptics</merge>
        <merge key="input.x11_options.LeftEdge" type="string">0</merge>
        <merge key="input.x11_options.RightEdge" type="string">1280</merge>
        <merge key="input.x11_options.TopEdge" type="string">0</merge>
        <merge key="input.x11_options.BottomEdge" type="string">800</merge>
        <merge key="input.x11_options.ClickFinger1" type="string">1</merge>
        <merge key="input.x11_options.ClickFinger2" type="string">3</merge>
        <merge key="input.x11_options.ClickFinger3" type="string">2</merge>
        <merge key="input.x11_options.HorizEdgeScroll" type="string">0</merge>
        <merge key="input.x11_options.VertEdgeScroll" type="string">0</merge>
        <merge key="input.x11_options.VertTwoFingerScroll" type="string">1</merge>
        <merge key="input.x11_options.HorizTwoFingerScroll" type="string">1</merge>
        <merge key="input.x11_options.HorizScrollDelta" type="string">0</merge>
        <merge key="input.x11_options.VertScrollDelta" type="string">40</merge>
        <merge key="input.x11_options.PressureMotionMinZ" type="string">10</merge>
        <merge key="input.x11_options.FingerLow" type="string">16</merge>
        <merge key="input.x11_options.FingerHigh" type="string">80</merge>
        <merge key="input.x11_options.FingerPress" type="string">256</merge>
        <merge key="input.x11_options.PalmDetect" type="string">0</merge>
        <merge key="input.x11_options.PalmMinWidth" type="string">10</merge>
        <merge key="input.x11_options.PalmMinZ" type="string">200</merge>
        <merge key="input.x11_options.MinSpeed" type="string">0.8</merge>
        <merge key="input.x11_options.MaxSpeed" type="string">1.2</merge>
        <merge key="input.x11_options.AccelFactor" type="string">0.10</merge>
        <merge key="input.x11_options.MaxTapMove" type="string">25</merge>
        <merge key="input.x11_options.MaxTapTime" type="string">223</merge>
        <merge key="input.x11_options.MaxDoubleTapTime" type="string">200</merge>
        <merge key="input.x11_options.TapButton1" type="string">0</merge>
        <merge key="input.x11_options.TapButton2" type="string">0</merge>
        <merge key="input.x11_options.TapButton3" type="string">0</merge>
        <merge key="input.x11_options.RTCornerButton" type="string">0</merge>
        <merge key="input.x11_options.RBCornerButton" type="string">0</merge>
        <merge key="input.x11_options.LTCornerButton" type="string">0</merge>
        <merge key="input.x11_options.LBCornerButton" type="string">0</merge>
      </match>
    </match>
  </device>
</deviceinfo>

Reboot, and you should now be able to disable the touchpad with gsynaptics.
Note, System > Preferences > Mouse also has a section for touchpad, so disable it there as well.

Posted in Code, Family, Ubuntu   |   Comments (7 )

What repository did I install that package from?

To see what repository a package was installed via in Ubuntu using apt, use this command:
$ apt-cache policy packagename

Example:

$ apt-cache policy firefox
firefox:
  Installed: 3.0.3+build1+nobinonly-0ubuntu0.8.04.1
  Candidate: 3.0.3+build1+nobinonly-0ubuntu0.8.04.1
  Version table:
 *** 3.0.3+build1+nobinonly-0ubuntu0.8.04.1 0
        500 http://security.ubuntu.com hardy-security/main Packages
        100 /var/lib/dpkg/status
     3.0.2+build6+nobinonly-0ubuntu0.8.04.1 0
        500 http://archive.ubuntu.com hardy-updates/main Packages
     3.0~b5+nobinonly-0ubuntu3 0
        500 http://archive.ubuntu.com hardy/main Packages
Posted in Ubuntu   |   Comments (0)

Create a "whitelist" content filtering proxy for Firefox

When my kids use the internet, I set up Firefox so that they can only access a list of approved sites. Here’s how I do it (thanks to DrBacchus and skippy for the assist):

Install squid (Squid is a caching proxy for the Web):
$ sudo apt-get install squid

Modify squid.conf:
$ sudo vi /etc/squid/squid.conf

Set “visible_hostname” to the hostname of the machine:
visible_hostname yourmachinename
Replace “yourmachinename” with the name of your machine

Set “http_access” to allow access only to the domains specified in your whitelist (I store my whitelist at /opt/squid/allowed_domains):

acl allowed_dstdomains dstdomain "/opt/squid/allowed_domains"
http_access allow allowed_dstdomains

Set up your whitelist file, here is an example:

$ sudo vi /opt/squid/allowed_domains
.tamatown.com
.tamagotchi.com
.webkinz.com

Restart squid for the changes to take affect:
$ sudo /etc/init.d/squid restart

Then, set your child’s Firefox settings to use your squid instance as their proxy server. In Firefox, Edit > Preferences > Advanced > Network > Connection Settings > Manual Proxy Configuration:

Hostname: yourmachinehostname (or localhost)
Port: 3128 (this is the default port for squid)
Use this proxy server for all protocols.

Drawbacks: You must manually add any address you want your child to be allowed to access into your allowed_domains file (hence “whitelist” instead of “blacklist”). Also, if your child is savvy enough to know how to disable the Firefox proxy settings, then they can bypass this.

I created a shell script to automatically append a domain to my “allowed_domains” file and then restart the squid service:

#!/bin/sh
if [ "$#" != "1" ] ; then
echo "usage is $0 [domain] "
exit
fi
echo $1 | sudo tee -a /opt/squid/allowed_domains
sudo /etc/init.d/squid restart

Replace “/opt/squid/allowed_domains” with the location and name of your allowed domains list

Example usage would be:
./squid_add .wikipedia.org

Posted in Ubuntu   |   Comments (1)