Nick's Tech Blog: September 2011

Pages

Thursday, September 29, 2011

Ubuntu > Display notifications over the screensaver

I'm currently playing around with notifications, and I'm trying to "keep" notifications displayed above the screensaver, so that I can see if I've got new mail or an IM from afar, without having to unlock my pc.

Basically the opposite problem to these:
http://www.jwz.org/xscreensaver/faq.html#popup-windows
http://www.google.com/search?q=notifications+over+screensaver+ubuntu

I'm using a command similar to the following, to display messages with an infinite timeout:
Code:

$ notify-send -t 0 -i info "You've got mail" "mailbox (123)"

Currently notifications get displayed temporarily "above" the xscreensaver, but eventually xscreensaver will "raise" itself above the notification (e.g. after a minute or two).

Here are my options, as I see it currently:

1) Download the xscreensaver's source code, modify it to prevent it raising itself above the notifications, build and install it (painful... I've managed to build it from the source, but I don't know what I should be modifying.)

2) Write my own custom screensaver (not really path I want to take, when I already have a notification and screensaver framework).

Are there any other (easier) options I've missed? Can anyone help?

(There's an argument that nothing should be displayed over the top of screensavers... )

Some context:
Ubuntu 11.04
Unity
notification-daemon/natty uptodate 0.5.0-2ubuntu1 (better functionality than notify-osd - i.e. click to close, vertical stacking, customisation...)
xscreensaver/natty uptodate 5.12-0ubuntu3 (more customisable than gnome-screensaver).

See also:

The same question, posted on the ubuntu forums:
http://ubuntuforums.org/showthread.php?p=11292893#post11292893

Traceback to a thread, on customising notify-osd notifications:
http://www.webupd8.org/2011/05/configurable-notifyosd-bubbles-for.html#dsq-comment-199829486

Another alternative to notification-daemon and notify-osd is avant-window-navigator 
http://maketecheasier.com/2-ways-to-make-ubuntu-notification-more-user-friendly/2011/05/21

Unfortunately, this is the closest solution I've found to notifications whilst the screensaver is running (checkGmail lights up the scroll lock key on the keyboard).
http://ubuntuforums.org/showthread.php?t=1564412

Wednesday, September 28, 2011

Ubuntu > Compiling package/s from source

Just putting together a quick "cheatsheet" for compiling and installing a package from it's source code.

Start here: (it's all here and it's very simple...)
https://help.ubuntu.com/community/CompilingSoftware
https://help.ubuntu.com/community/CompilingEasyHowTo

Pre-requisites:
sudo apt-get install build-essential checkinstall

Optional - to assist in retrieving the source code:
sudo apt-get install cvs subversion git-core mercurial

By convention, put source code under here (extract the source if it's in a zip, tar.gz, etc):
/usr/local/src

From the root of the source code:
./configure

Resolve any missing dependencies:
sudo apt-get build-dep <package>
apt-file search <your-missing-file.h>


Build the code:
sudo make

Package the code into a *.deb:
sudo checkinstall

Install the code directly:
sudo make install

Clean up:
sudo make clean
sudo make distclean


Thats it, nothing ground breaking. Please let me know if there's anything else I've missed.

See also:
http://www.gnu.org/software/make/manual/make.html#Complex-Makefile

Monday, September 26, 2011

Fedora > libfontconfig.so.1: cannot open shared object file: No such file or directory

Problem

Received the following exceptions (seperately) when attempting to run a java program on Fedora 15 amd64.

/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
...
libstdc++.so.5: cannot open shared object file: No such file or directory
...
Exception in thread "main" java.lang.UnsatisfiedLinkError: /some/directory/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
...
libfontconfig.so.1: cannot open shared object file: No such file or directory


and so on.

Solution

Obviously a couple of dependencies were missing. To find out which package/s you need to install to fix a missing dependency, use "yum provides <missing_file>".
e.g.
# yum provides libfontconfig.so.1
fedora/metalink |  21 kB     00:00    
jenkins |  951 B     00:00    
updates/metalink |  12 kB     00:00    
fontconfig-2.8.0-3.fc15.i686 : Font configuration and customization library
Repo        : fedora
Matched from:
Other       : libfontconfig.so.1

Then install the packages...
e.g.
# yum install fontconfig

Repeat for all missing files.

CFEngine > Scalar item in package_list_command => { ls } in rvalue is out of bounds (value should match pattern "?(/.*))


Problem

Whilst validating a cf-promises file, I received the following output.
$ cf-promises -f ./promises.cf
cf3> ./packages.cf:23,28: Scalar item in package_list_command => { ls } in rvalue is out of bounds (value should match pattern "?(/.*)), near token 'ls"'


The associated line is:
package_list_command => "ls -1 /your/directory"

Solution

Basically, the error is trying to tell us that the "ls" command must be fully qualified.

The associated line should read:
package_list_command => "/bin/ls -1 /your/directory"

Thursday, September 22, 2011

Fedora > java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

Problem 

The following exception was encountered when running a java program on Fedora:
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

Assumptions: you know what an xserver is.

Solution

Basically, the java program is trying to access the xserver, and can't.

If it should be accessing the xserver, make sure the xserver is started/running:
  • e.g. ps -ef | grep Xvfb
If it shouldn't be accessing an xserver, make sure the "DISPLAY" environment variable is unset:
  • unset DISPLAY

See also:
Fedora > install Xvfb as a service

Ubuntu > Filter directory /usr/lib/cups/filter for printer "<yourprinter>" is not owned by root.

Problem

You receive the following error status message for a printer, once it is installed (e.g. in the "Print" window).

Filter directory /usr/lib/cups/filter for printer "" is not owned by root. 

You may also see "cups-insecure-filter". 

Solution

Execute the following commands, to change ownership back to root. 

  1. sudo chown -hR root:root /usr/lib/cups/filter/* 
  2. sudo chown -hR root:root /usr/lib/cups/backend/* 
  3. service cups restart 

Your printer should now no longer display the message. (May require closing and reopening the "Print" window). 

See also:
https://bugs.launchpad.net/ubuntu/+source/cups/+bug/436544

Fedora > install Xvfb as a service

Problem

I required Xvfb to be installed, and running as a service on a server.

Assumptions: you know how to use chkconfig, yum, vi and chmod.

Solution
  1. yum install xorg-x11-server-Xvfb
  2. vi /etc/init.d/xvfbd (copy contents below into the file, and save it)
  3. chmod 755 /etc/init.d/xvfbd (now we have a service)
  4. chkconfig --add xvfbd
  5. chkconfig --level 2345 xvfbd on

You can now start your service with:
sudo service xvfbd start

Check it's running:
ps -ef | grep Xvfb

Check it's listed to startup automatically for runlevels 2,3,4,5:
chkconfig --list


/etc/init.d/xvfbd

#!/bin/bash
#
# description: Xvfb server
#


# Get function from functions library
. /etc/init.d/functions


# Start the service Xvfb
start() {
        echo -n "Starting Xvfb server: "
        /usr/bin/Xvfb &
        ### Create the lock file ###
        touch /var/lock/subsys/Xvfb
        success $"Xvfb server startup"
        echo
}


# Restart the service Xvfb
stop() {
        echo -n "Stopping Xvfb server: "
        killproc Xvfb
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/Xvfb
        echo
}


### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status Xvfb
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 1
esac


exit 0

See also:
http://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

Friday, September 16, 2011

Ubuntu > Install Canon Pixma MX870 i386 drivers on amd64

Problem

Canon only provide i386 drivers for the PIXMA MX870 All-In-One Printer on their Australian website.

These work fine with amd64, but just need the scripts to be tweaked to allow it (very easy to do).

Solution

Ensure you have the latest versions for the following applications:

$ apt-show-versions | grep -E "libcups2|libcupsys2|libc6|libpopt0"
e.g.
libc6/natty uptodate 2.13-0ubuntu13
libc6-dev/natty uptodate 2.13-0ubuntu13
libc6-i386/natty uptodate 2.13-0ubuntu13
libcups2/natty-security uptodate 1.4.6-5ubuntu1.4
libpopt0/natty uptodate 1.16-1


Follow these steps:
  1. Download the MX870 series IJ Printer Driver Ver. 3.30 for Linux (debian Packagearchive)
  2. Extract the cnijfilter-mx870series-3.30-1-i386-deb.tar.gz into a directory
    1. Nautilus > right-click > Extract Here
    2. Command line > tar -xvzf cnijfilter-mx870series-3.30-1-i386-deb.tar.gz -C /your/target/dir
  3. Comment out the "i686" lines in the <extracteddir>/install.sh, as per the instructions here.
  4. Update all <extracteddir>/packages/*.deb packages by running repackage.sh (see below), and removing the line beginning with "Dependency: ..." during the "vi" step.
    1. e.g. ./repackage.sh <package>.deb
  5. Run <extracteddir>/install.sh


repackage.sh
#!/bin/bash
PACKAGE=${1}
dpkg -x $PACKAGE common
dpkg --control $PACKAGE
vi DEBIAN/control
cp -a DEBIAN/ common/
dpkg -b common $PACKAGE
rm -rf common DEBIAN


See also:
https://bugs.launchpad.net/ubuntu/+source/cups/+bug/701856/comments/20
http://ubuntuforums.org/showthread.php?t=1475336

Wednesday, September 14, 2011

Ubuntu Unity > remove Rhythmbox from the sound menu

Problem

Ubuntu 'Natty' 11.04
There's no (obvious) way to remove rhythmbox from the sound menu in unity.

Solution

According to the documents on the ubuntu wiki, rhythmbox must be removed by using gsettings. Execute the following in your console:

gsettings set com.canonical.indicator.sound blacklisted-media-players "['rhythmbox']"

See: https://wiki.ubuntu.com/SoundMenu#Music_player_integration

Install Java Plugin on Ubuntu Firefox

Current as of: 14 Sept, 2011

Versions
Ubuntu 'Natty' 11.04
Firefox 6.0.2
Sun Java6 Plugin

Add the 'universe' software source
  1. Open the "Ubuntu Software Center"
  2. In the menu, navigate to Edit > Software Sources...
  3. (Enter administrator password)
  4. Other Software > Add
  5. Enter "deb http://archive.canonical.com/ubuntu natty universe" in the apt line
  6. Click "Add Source"
  7. Check that "Canonical Partners universe" entry has been added.
  8. Click "Close"

Install the java6 plugin
Back in the "Ubuntu Software Center" window...
  1. Navigate to "Get Software" and search for "sun-java6-plugin"
  2. It should now return an entry for "sun-java6-plugin"
  3. Click "Install"

It's that simple. Once complete, you should now be able to start/restart firefox and the java plugin will be installed.

You can optionally check, that the following symbolic link has been created.
/usr/lib/mozilla/plugins/libjavaplugin.so -> /etc/alternatives/mozilla-javaplugin.so

Sunday, September 11, 2011

Fedora > WARNING: / partition has insufficient space to install the items selected

Problem

I received the following error, when installing an application on Fedora 15 (Tibco TRA as it happens).

WARNING: / partition has insufficient space to install the items selected.
XXX MB additional space would be needed to install the selected items.


Solution

Create a temp directory that can hold the amount of space required to install the application (e.g. /root/tmp).

Then append the following parameter on to your installation command.
-is:tempdir /root/tmp

See also:
http://publib.boulder.ibm.com/infocenter/iisinfsv/v8r1/index.jsp?topic=/com.ibm.swg.im.iis.productization.iisinfsv.install.doc/topics/iisri_verify_disk_space.html

Friday, September 9, 2011

Fedora > /bin/sh: bad interpreter: Permission denied

Problem

Received the following error message when attempting to install an application, in Fedora 15, where the current working directory is /tmp/somedir.
/bin/sh: bad interpreter: Permission denied

Solution

Security on Fedora/RHEL blocks executing scripts from /tmp. The solution/workaround is to move the directory to my homedrive, and run it from there instead.

http://www.velocityreviews.com/forums/t9645-bash-firefox-installer-bin-sh-bad-interpreter-permission-denied.html