Categories
Command Line Linux Ubuntu

apt-get error “E: Unable to correct problems, you have held broken packages.”

The problem you have encountered is basically the package, or dependencies that are conflicting or broken and are therefore “held”.

You can check what (if any) packages are held using the following command:

dpkg --get-selections | grep hold

or

apt-mark showhold

If there’s no packages, or no output. That means it’s probably a dependency issue which apt-get isn’t able to resolve. apt-get is actually pretty bad at dealing with the dependencies and it’s often easier to try install via aptitude (an alternative to apt-get, which is widely regarded as a better solution to the default apt-get.

Solution:

First install aptitude:

sudo apt-get install aptitude

and then install the package:

sudo aptitude install [package_name]
Categories
Featured Linux Ubuntu

Toggle Touchpad With Keyboard Shortcut in Ubuntu

Install Jupiter

Instructions for Ubuntu 11.10, 11.04, 10.10, 10.04: http://www.webupd8.org/2011/09/jupiter-applet-finally-available-for.html

sudo add-apt-repository ppa:webupd8team/jupiter 
sudo apt-get update 
sudo apt-get install jupiter

Jupiter comes with a useful script to disable and re-enable the touchpad/track pad, it can be ran using the following command:

sudo /usr/lib/jupiter/scripts/touchpad

Now all you’ll need to do is add this command to a keyboard shortcut, below are instructions for several desktop environments.


In xfce:

Applications > Settings > Settings Manager

Click Keyboard

Click on the “Applications Shortcuts” tab.

Click Add:

Here you will be promped with a new window asking for the command you wish to run, enter the following:

sudo /usr/lib/jupiter/scripts/touchpad

Click OK and it will now ask for a keyboard shortcut. Simply press the key combination you want to assign to disabling the touchpad (for example, I used Alt+F1) the keys you’re pressing will show up and the window will close.

You’ll now see the command and shortcut in the list and you can now press that key combo to disable the trackpad and press it again to re-enable it.


In Gnome:

In Unity:

bish bash bosh.

Categories
HowTo Linux Ubuntu

Updating The Kernel in Ubuntu

Download the latest from here:

http://kernel.ubuntu.com/~kernel-ppa/mainline/

The folders correspond to kernel versions and should also include the ubuntu version, for example I chose to update 11.10 (oneiric) from “3.0.0-14-generic” to “3.1.4”, this was in a directory called “v3.1.4-oneiric/“.

You’ll need 3 files (replace * with the kernel version you’ve downloaded):

linux-headers-*_all.deb

For 64 bit systems (replace * with the kernel version you’ve downloaded):

linux-headers-*_amd64.deb
linux-image-*_amd64.deb

For 32 bit systems (replace * with the kernel version you’ve downloaded):

linux-headers-*_i386.deb
linux-image-*_i386.deb

Once you have the files, install them in the following order using these commands (of course, replacing the version number for the ones you’ve downloaded):
sudo dpkg -U linux-headers-3.1.4-030104_3.1.4-030104.201111281851_all.deb
sudo dpkg -U linux-headers-3.1.4-030104-generic_3.1.4-030104.201111281851_amd64.deb
sudo dpkg -U linux-image-3.1.4-030104-generic_3.1.4-030104.201111281851_amd64.deb

Once that’s done, reboot. Once you’re back use the following command to check that the kernel you’re using is the one you’ve just downloaded and installed!

uname -r
Categories
Arch Linux Linux Posts Ubuntu

HowTo: Disable Mouse Scroll to Switch Desktop – OpenBox

Open up the openbox config file, it should be located in /home/username/.config/openbox/ but if it’s not you might have to do a little digging.

nano /~.config/openbox/rc.xml

Find the following lines and remove or comment them out, you can use Ctrl+W in nano to find:

      
        
      
      
        
      

Note: XML comments are as follow:<-- Comment -->

Save with Ctrl+X, Y, Enter (if you’re using nano) and restart OpenBox (Preferences -> OpenBox Config -> Restart) and all should be done.

Categories
Arch Linux Blog Command Line HowTo Linux Posts Ubuntu

HowTo: Remove Every Other Line in Text Files – Linux

Let’s say you’ve got a text file, of any size, big or small, and you want to remove every other line of that file, well here are a few commands in Linux that allow you to do this.

Example, you want to get from this:

1
2
3
4
5
6
7
8
9
10

To this:

1
3
5
7
9

The sed way:

 sed -n "p;N;" file.txt > newfile.txt

The awk way:

 awk 'NR%2 != 0' file.txt > newfile.txt

Here you can actually specify N lines, replace 2 in the above command and you’ll be able to take out every N’th number. As an example, here’s the above replaced with a 3 on the file:

1
2
4
5
7
8
10

Easy as pie, right?

Categories
Arch Linux HowTo Linux Posts

Installing packages from CD in Arch Linux

Okay, so you have Arch Linux installed and let’s say you’re wifi isn’t working and you need the package “iwlwifi-3945-ucode-15.32.2.9-2-any.pkg.tar.gz” to fix this but you don’t have a wired connect. What do you do? Blast in your Arch cd, mount it, mount the packages sqfs file and install using pacman.

Mount cdrom:

mkdir /mnt/cdrom/
mount /dev/cdrom /mnt/cdrom/

Mount *-pkgs.sqfs:

mkdir /mnt/pkgs/
mount -o loop core-pkgs.sqfs /mnt/pkgs/
cd /mnt/pkgs/

Install pkg.tar.gz:

pacman -U package-name.pkg.tar.gz
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

Using pdfcrop to Remove White Margins | Ubuntu

One of the most annoying things about PDF files are their fixed font size, the only real way of getting a better view at the text is to zoom the whole page in. This isn’t really a fix for that annoyance but it’s a way of getting more info to screen ratio by removing the wasted white space around the body of the file for each page, this really comes in useful when displaying PDF files on your Kindle, Nook, Smart Phone or other eBook Readers.

 sudo apt-get install texlive-extra-utils

It’s really simple to use and by default it crops all the white space from around an image, it does this per page rather than for the entire document which allows for the best results (as long as you don’t mind changes in font size when you’re reading it).

Change input.pdf to the name of the file you want to crop and output.pdf to the output cropped file.

 pdfcrop input.pdf output.pdf

Some PDFs have better results than others and some PDFs will look the same on eBook readers if they crop the whitespace, but it’s a useful tool to have for some of those old pesky JPEG PDF files with massive borders all the way around.

Example: Left = input, right = output

Some PDF files seem to bring up the following error:

!!! Error: Ghostscript exited with error code 1!

I’m currently not sure what causes this, possibly something to do with the encoding type of the PDF? or maybe just some missing dependencies..

For more info about pdfcrop check out the Ubuntu Manpage: http://manpages.ubuntu.com/manpages/gutsy/man1/pdfcrop.1.html

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
Android HowTo Posts

HowTo: Take Untethered Screenshots in Froyo

With the latest update of Android “Froyo”, it’s now possible to take screenshots/screen captures without the need to be plugged into a computer, mess around with the Android SDK or Root your phone. You are easily able to take screenshots of the home screen and while in any app. I have only been able to test this with a Samsung Galaxy S (I9000-GT) running

Froyo so comment on your results.

Here’s how to take a screenshot in Froyo:

Hold down Back and then press the Home button.

You should now see a pop-up near the bottom saying “Screen captured. Saved as image file” as in the following image. The files will be saved to a folder named ScreenCapture in your home directory as a .PNG.

By holding down the Back button it doesn’t actually go back if held down, it waits for you to press Home. After a few seconds of holding it down however(I can’t quite figure it out) pressing Home will continue the “going back” operation as if the Back button was tapped.