Categories
Command Line HowTo Linux Ubuntu

fatal error: libconfig.h: No such file or directory | Ubuntu 12.04

If you’re getting the following error:

fatal error: libconfig.h: No such file or directory

Then you’re probably missing the libconfig-dev package from your system. Simply run the following command and it’ll fix it:

sudo apt-get install libconfig-dev
Categories
Linux Ubuntu

gimp: error while loading shared libraries: libgegl-0.0.so.0: cannot open shared object file: No such file or directory

After upgrading from Ubuntu 11.10 to 12.04 I found gimp couldn’t access the shared libraries it needed, most likely an error with symbolic links as described by lovelyindia in this post.

Fix 1:

He managed to fix the issue by removing gimp and purging the offending libraries and then letting apt deal with the libraries when he re-installed gimp, as per the below commands:

sudo apt-get update 
sudo apt-get purge gimp libgegl* libbabl* 
sudo apt-get install gimp 
sudo apt-get clean

While this is likely to work for most people encountering this issue, it didn’t for me.

Fix 2:

Then I remembered I had used the repogen source list generator, in which I chose to include the gimp svn build. While you may not have gone about it the same way, you may also have a different repository in your sources.list file which is causing this issue, if the previous method did not resolve the issue.

In order to fix this, I had to open the sources.list file and comment out the offending repo.

sudo gedit /etc/apt/sources.list

Now search for any reference to gimp, in my case this was the lines I changed:

#### Gimp SVN - https://launchpad.net/~matthaeus123/+archive/mrw-gimp-svn
## Run this command: sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 405A15CB
deb http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu precise main

I commented out the line linking to the repo by adding a ‘#’ to the front, as below:

#### Gimp SVN - https://launchpad.net/~matthaeus123/+archive/mrw-gimp-svn
## Run this command: sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 405A15CB
# deb http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu precise main

I then uninstalled gimp, once I knew it may have been the newly added repository that I had added:

sudo apt-get purge gimp

Then I saved and exited the file and updated apt:

sudo apt-get update

I then re-installed gimp:

sudo apt-get install gimp

This solved the issue for me, I hope this helps!

Categories
Command Line Linux Ubuntu

Ubuntu 12.04 – Moving The Windows Buttons Back To The Right.

Those pesky windows buttons (maximise, minimise and close) default to the left of the menu bar after a new Ubuntu installations, and it’s been happening since 10.04. Most people, like myself, are stuck in our ways and just want them back where they belong. It’s pretty easy to do this, just open up a terminal (ctrl+alt+t) and copy in the following:

gconftool -s /apps/metacity/general/button_layout -t string menu:minimize,maximize,close

Once you hit enter, you should see the buttons return to their rightful place on the right, also in the right order.

Categories
Arch Linux Blog Command Line Fedora Linux Posts Ubuntu

Switching Between Two Resolutions in Linux

I have a TV and my monitor connected to my PC by a VGA switch box but what’s annoying is they aren’t the same resolution. This causes problems because I can’t see what I’m doing when I have switched to TV and usually have to leave the setting manager open so that when I change between them I just have to hit return and the resolution changes. That’s great and all but it’s far more effort than I want for something I do fairly often.

My plan was initially to create two xorg.conf files and switch between them using a script, I figured this would be the easiest way even though I haven’t messed around with xorg stuff for a few years ever since things just started working better in Linux. Turns out I couldn’t even find where they keep the xorg.conf file, it sure isn’t in /etc/X11 where it was the last time I looked..

On the search for this file though I came across another useful tool called xrandr, which essentially allows you to change the resolution from the command line.

Xrandr is used to set the size, orientation and/or reflection of the outputs for a
screen. It can also set the screen size.

If invoked without any option, it will dump the state of the outputs, showing the
existing modes for each of them, with a ‘+’ after the preferred mode and a ‘*’
after the current mode.

There are a few global options. Other options modify the last output that is spec‐
ified in earlier parameters in the command line. Multiple outputs may be modified
at the same time by passing multiple –output options followed immediately by
their corresponding modifying options.

For more information on xrandr check out the manual page (or type man xrandr in terminal).

It turns out it’s an extremely easy tool to use, with a command as simple as the following changing the resolution:

xrandr --output VGA1 --mode 1440x900

So the next thing I did was create the following script which allows the resolution to switch between 1440×900 and 1360×768 (my monitor and my TV native resolutions).

#!/bin/bash

TV="1360 x 768"
MONITOR="1440 x 900"

TEST="$(xrandr | grep current | sed -e 's/.*current //;s/, maximum.*//')"

#echo $TEST

if [ "$TEST" == "$MONITOR" ]
        then
                xrandr --output VGA1 --mode 1360x768

elif [ "$TEST" == "$TV" ]
        then
                xrandr --output VGA1 --mode 1440x900

else

        exit

fi

This script simply checks what the current resolution is being used and then toggles between the two set resolutions.

Categories
HowTo Linux Posts Ubuntu

OpenShot, libmp3lame and Ubuntu

If you’re getting the following error while trying export a video under several different codecs in OpenShot including AVI, MOV and MPEG using (mpeg2, mpeg4 or h.264) chances are this might help you with that error.

The following formats/codecs are missing from your system:

libmp3lame

You will not be able to use the selected export profile. You will need to install the missing formats/codecs or choose a different export profile.

This is a simple fix:

  • Open up Synaptic Package Manager
  • Search “libavformat”,
    • If the current package installed is “libavformat52” select “libavformat-extra-52” (alternativly “libavformat-unstripped-52” should also work).
    • Else the package might be “libavformat53” so simply change to “libavformat-extra-53”, basically it might end in different numbers, it should work the same.
  • Hit Apply and approve the changes.
Categories
Linux Posts Ubuntu

Realtek RTL8191S in Ubuntu 10.10

Errors:

$ sudo ifconfig wlan1 up
SIOCSIFFLAGS: Resource temporarily unavailable

$ dmesg usb
rtl819xU:FirmwareDownload92S(): failed with TCR-Status: a
rtl819xU:ERR!!! _rtl8192_up(): initialization is failed!

Solution 1:

To get this wifi dongle working I simply had to download the above firmware and place it in /lib/firmware/RTL8192SU/ and then reboot my computer. You should check that location before hand and make a backup of anything inside of it if you’re not sure what you are doing. If it’s empty you can use the following commands to make the directory and then download the firmware directly.

sudo mkdir /lib/firmware/RTL8192SU/
cd /lib/firmware/RTL8192SU/
sudo wget http://svn.debian.org/wsvn/kernel/dists/trunk/firmware-nonfree/realtek/RTL8192SU/rtl8192sfw.bin

Solution 2:

Alternatively download the source and build it:

wget http://launchpadlibrarian.net/33927923/rtl8192se_linux_2.6.0010.1012.2009.tar.gz
tar -zxvf rtl8192se_linux_2.6.0010.1012.2009.tar.gz
cd rtl8192se_linux_2.6.0010.1012.2009
make
sudo make install

Downloads:
Firmware: http://svn.debian.org/wsvn/kernel/dists/trunk/firmware-nonfree/realtek/RTL8192SU/rtl8192sfw.bin

Source: http://launchpadlibrarian.net/33927923/rtl8192se_linux_2.6.0010.1012.2009.tar.gz

Categories
Kindle Linux Posts Ubuntu

Auto Sync Kindle in Ubuntu

For Christmas I got a Kindle 3 and it was instantly filled with Free eBooks (http://www.gutenberg.org/wiki/Main_Page) and research papers (PDFs). I found myself wanting to be able to automatically synchronize it with a folder on my desktop when it was plugged in and found no one else had posted online how to do this, so I began researching into udev and rsync to get something working.

Setting up udev rules to run a script when the Kindle is plugged in.

Firstly, we need to find some parameters of the Kindle which are unique to it so that udev can identify that it is the Kindle being plugged in and not another USB mass storage device. We’ll need to find out where the device is mounted in /dev/ which can be a little tricky because this folder is pretty full.

An easier way to do this is to first, without the Kindle plugged in do the following command (list the directory and pipe the output to a file called dev1 in the home dir):

ls /dev/ > ~/dev1

Now plug the Kindle in and redo the command, changing the destination output:

ls /dev/ > ~/dev2

The difference between the two files will show what has changed in the /dev/ directory:

 sdiff ~/dev1 ~/dev2

The output for mine (show in the image below) shows that 3 things changed when I plugged in the Kindle, sdb, sdb1 and sg2 directorys were added (shown by the > sign to the left). The folder I am looking for is the sdb1, this is where the mass storage device is found.

Write down where it’s found in /dev/ and then you can clean up those two files you previously made:

rm ~/dev1 | rm ~/dev2

The next thing we want to do is use udevadm to collect some useful information about the device which we can do by the following command (I have chosen to pipe the output to a file called kindle in the home dir, because the output was pretty big. If you don’t want to remove the > ~/kindle from the end of the command):

udevadm info -a -p $(udevadm info -q path -n /dev/sdb1) > ~/kindle

WARNING: This can look pretty daunting but, (in the words of Douglas Adams) Don’t Panic.

  looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/host21/target21:0:0/21:0:0:0/block/sdb/sdb1':
    KERNEL=="sdb1"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{partition}=="1"
    ATTR{start}=="16"
    ATTR{size}=="6410672"
    ATTR{alignment_offset}=="0"
    ATTR{discard_alignment}=="4294959104"
    ATTR{stat}=="     151     3389     4239     3776        0        0        0        0        0     2424     3776"
    ATTR{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/host21/target21:0:0/21:0:0:0/block/sdb':
    KERNELS=="sdb"
    SUBSYSTEMS=="block"
    DRIVERS==""
    ATTRS{range}=="16"
    ATTRS{ext_range}=="256"
    ATTRS{removable}=="1"
    ATTRS{ro}=="0"
    ATTRS{size}=="6410688"
    ATTRS{alignment_offset}=="0"
    ATTRS{discard_alignment}=="0"
    ATTRS{capability}=="51"
    ATTRS{stat}=="     156     3389     4279     3808        0        0        0        0        0     2456     3808"
    ATTRS{inflight}=="       0        0"

  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/host21/target21:0:0/21:0:0:0':
    KERNELS=="21:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="3"
    ATTRS{vendor}=="Kindle  "
    ATTRS{model}=="Internal Storage"
    ATTRS{rev}=="0100"
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{iocounterbits}=="32"
    ATTRS{iorequest_cnt}=="0xe1"
    ATTRS{iodone_cnt}=="0xe1"
    ATTRS{ioerr_cnt}=="0x1"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{evt_media_change}=="0"
    ATTRS{dh_state}=="detached"
    ATTRS{queue_depth}=="1"
    ATTRS{queue_type}=="none"
    ATTRS{max_sectors}=="240"

While this many look daunting, what you want to do if find some attributes from the output which mean only your Kindle will be found when looking for them all, the problem I have found is that, with udev rules you cannot go too far down in the parent tree which stops me being able to use the Kindles serial to identify it. This could mean that my computer will sync any Kindle that’s plugged into it but I don’t have 2 to check. The following are the attributes I chose:

KERNEL=="sd?", ATTRS{vendor}=="Kindle  ", ATTRS{modalias}=="scsi:t-0x00"

Now you’ll want to write the udev rule in /etc/udev/rules.d/

cd /etc/udev/rules.d/

According to the readme the numbers represent the priority of the rule (higher overriding lower) followed by a descriptive name and it must end in .rules eg (xx-description.rules).

sudo gedit 81-kindle-sync.rules

The following is the whole line I used for the udev rule, the only addition to the above is the RUN+=”/home/alex/.scripts/kindlesync.sh” which will run the script in that directory, this script contains the rsync command.

KERNEL=="sd?", ATTRS{vendor}=="Kindle  ", ATTRS{modalias}=="scsi:t-0x00", RUN+="/home/alex/.scripts/./kindlesync.sh"

Save and close the file and then restart the udev service:

sudo service udev restart

Writing a script to sync a folder on the Desktop with a folder on the Kindle using rsync:
Change the first directory from “/home/alex/ebooks/kindle_sync” to the directory on your computer where you want to keep the files that will be synced onto your Kindle and the second from “/media/Kindle/documents/sync/” to the location on your mounted Kindle where you want the files to be stored, save this file as kindlesync.sh. This is the script you call from the udev rules so for mine it’s saved as “/home/alex/.scripts/kindlesync.sh”.

#!/bin/bash

#Sync
rsync -av /home/alex/eBooks/kindle_sync/ /media/Kindle/documents/sync/

Go to the location of the script and make it executable with the following command:

chmod +x kindlesync.sh

Now try plugging in your Kindle and make sure it syncs up!

Problems

In the udev rule, ACTION==”add” can be used to specify when the Kindle is first plugged in, however when trying to use this Ubuntu’s auto-mounting service mounts the drive after the script is ran so the sync becomes useless. Without this it runs the script 3 times, twice before it has mounted and then once it has mounted – this is currently the best I have found but it’s extremely messy.

Categories
Blog Command Line Linux Posts Ubuntu

A More Elegant Solution to Ubuntu Wi-Fi Reconnecting Issue

Previously I was having problems with Ubuntu dropping wifi connections and failing to reconnect, to solve this I wrote a script which would kill the network-manager and then connect using iwconfig commands (here). While this works fine, it felt a little hacky, having to have a script running as sudo constantly in the background checking for a dropped connection. After a little searching I came across cron (the time based job scheduler ) and /etc/rc.local (a script which is run after all other initialization scripts have ran, allowing for scripts to be ran on startup) so from this I decided to split the old script up into connection and checking scripts which could be ran from init.d/local and cron, respectively.

Firstly my startup script in /etc/init.d/local which sets up and connects to the wireless network, open the file as sudo:

 sudo gedit /etc/rc.local

Paste in the following:

#! /bin/sh

service network-manager stop && service networking stop

iwconfig wlan0 essid NETWORKNAME
iwconfig wlan0 key WEPKEY
ifconfig wlan0 up
dhclient3 wlan0

sleep 10

if iwconfig wlan0 | grep -o "Access Point: Not-Associated"
then
	ifconfig wlan0 down
	sleep 10
	ifconfig wlan0 up

fi

exit 0

Next the script for checking the network is still connected, if not attempt to reconnect (named wirelesscheck.sh):

#!/bin/bash

if iwconfig wlan0 | grep -o "Access Point: Not-Associated"
then

	ifconfig wlan0 down
	sleep 10
	ifconfig wlan0 up
	
fi

Make sure this script is executable (from the directory of the script):

 chmod +x wirelesscheck.sh 

Note: This is setup in the sudo crontab, only because this command needs root privileges – other commands could be added to a user crontab (by removing sudo from the following.)

Now, edit (-e) the crontab for sudo:

 sudo crontab -e 

If crontab has not previously been used choose an editor (I used nano – 2) and append this line to the bottom of the file and change the frequency and directory of the script. The current settings will run it every 5 minutes (*/5) every hour, day, month and year and the file is located in “/path/to/script/wirelesscheck.sh”.

*/5 * * * * /path/to/script/wirelesscheck.sh

If you have any issues, leave a comment and I will help if I can.

Categories
HowTo Linux Posts Ubuntu

How To: Fix “Failed to download repository information Check your Internet connection.”

If you’re getting this error but you’re still connected to the internet this page might help. This error is sometimes caused by repository’s which are down or broken.

Failed to download repository information
Check your Internet connection.

From terminal run the following command:

 sudo apt-get update

If the output runs through a few repositorys but ends with something similar to the below (most probably with different repositorys failing) and ultimately stopping your updating process then there is a good chance you can fix it by just removing those failing sources from the software sources.

Err http://ppa.launchpad.net maverick/main Sources
404 Not Found
Err http://ppa.launchpad.net maverick/main amd64 Packages
404 Not Found
W: Failed to fetch http://ppa.launchpad.net/bugs-sehe/gparted/ubuntu/dists/maverick/main/source/Sources.gz 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/bugs-sehe/gparted/ubuntu/dists/maverick/main/binary-amd64/Packages.gz 404 Not Found
E: Some index files failed to download, they have been ignored, or old ones used instead.

Software Sources can be found under either:

Applications > Ubuntu Software Centre > Edit > Software Sources..
OR
System > Administrator > Synaptic Package Manager > Settings > Repositorys

Click the Other Software tab.

Nnow find the repositories which caused the failure on the update and uncheck them and then close the Software Centre.

Re-run the update command and hopefully everything will work!

 sudo apt-get update

Check the example below where gparted was causing the error:

Categories
HowTo Linux Posts Ubuntu

How To: Restore Default sources.list

Having gone through several upgrades and countless repository’s added to the software sources, things can begin to get really messy really quickly and often begin to screw up when updating the system if you’re not careful. You may find yourself, like I have, wanting to restore your sources.list file back to its default in order to get things working again.

In order to do this there is a pretty handy webapp available called the “Ubuntu Sources List Generator” – http://repogen.simplylinux.ch/

By moving through each section it enables you to select your country, release and then check each repository you want to add, not only does it support all the official ones for things like security and updates, it also allows for 3rd party repos such as Banshee, Chromium, Conky and VLC amongst a bunch others. Once you have what you want hit generate and it’ll create a nice, comment, new sources.list file ready for you to replace your old one with.

You may want to backup your old sources.list just in case with the following command:

 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bkup

Once you have that you can open the sources.list and simply paste the new one in from the repogen:

 sudo gedit /etc/apt/sources.list

Paste, Save and Close the file and now you should paste the generated GPG keys, found just below the generated sources.list file, into your terminal.

Everything should be back to default and allow you to once again update everything.