Home Uniquely NZ Travel Howto Pauline Small Firms Search
Diary of System and Website Development
Part 19 (January 2011 - September 2011)

April 19th 2011

Ubuntu 11.04 Natty Beta with Unity Desktop LiveCD

I have been looking at the new version of Ubuntu which is a very major change from previous versions as it follows the desktops developed for Netbooks which are designed to make best use of the screen area, in particular with widescreen type layouts which are only 600 pixels high on a netbook which gives a stupid aspect ration when you have multiple toolbars. Unity uses a very much simplified launcher on the left, removes the lower panel and reduces and shares use of the top panel with the top toolbar (usually drop down menus like File Edit View ... .... .... Help) in the application which is In Focus. The Application Bar/Dock on the left lacks some features but there are other excellent touches such as automatic expansion to full screen when an application is draged to the top or half screen when dragged to a side. Some features have disappeared including the ability to run applets such as Netspeed completely and the system tray part of the top panel is only accessible to a few favoured and whitelisted applications which stopped Truecrypt from being usable as it reduces into an indicator icon in the systray. See below for the solution.

Restoring the Systray for some or all applications when running Unity

There are several places on the web which cover this and the best overall site covering such matters currently is Web UPD8 - there is a good article on How to re-enable the notification area (systray) for all aplications. How to Re-enable the Notification Area (systray) for all Applications which provides the basis for understanding how I got Truecrypt working.

First you need to instal the configuration tool for the Unity Desktop - the equivalent to gconf-editor for the gnome desktop. Not surprisingly it is called dconf-editor and most of it is very similar - there is however a useful addition of a return to defaults button for each setting. It can be installed in a terminal or you can use the Synaptic Package Manager. In this case I used a terminal to get the overall package of tools but first I had to enable the universe repository and the easy way was to run the Ubuntu Softwar Centre and use the drop down edit menu -> Software Sources and tick the Universe box on the Ubuntu Software tab - you should also be able to search and install from the Software Centre but it did not work on Beta 2:

sudo apt-get install dconf-tools

Now run dconf-editor using the terminal

dconf-editor

then navigate to desktop > unity > panel and enter: ['all'] in place of the existing string in Value for the for the Key systray-whitelist by clicking, overwriting with ['all'] and then a return

You now need to logout and log back in. If you are testing with a LiveCD this is more difficult and I got to a logout menu and loged back in as ubuntu with null password by doing in a terminal:

gnome-session-save --logout-dialog

I was also advised when I was using askubuntu.com (A very useful source of help) that the following in a terminal would restart Unity with the same effect:

(unity &)

This did the job but did produce some strange error messages!

Tests with Truecrypt showed the above proceedure worked. You can also add Truecrypt to the whitelist if you do not want any other extra programs to use the systray. I found it worked with the capital T.

LibreOffice

LibreOffice is a fork of OpenOffice resulting from the games being played by Sun and is being increasingly used by all Linux distributions. It looks and feels almost identical and I have upgraded one of my machines to use it as there is a PPA with more up-to-date versions than the equivalent OpenOffice version in Lucid. This is again based on the proceedures on Web UPD8 on how to install LibreOffice from a PPA

LibreOffice has an Ubuntu PPA so it's easy to install and stay up to date with the latest LibreOffice versions. The LibreOffice packages in this official Ubuntu PPA are backported from Natty so they come with all the patches/optimizations applied to LibreOffice for Ubuntu. Important note: You must remove OpenOffice so you cannot have both in the same time!

To remove OpenOffice, add the LibreOffice Ubuntu PPA and install it in Ubuntu 10.04 Lucid Lynx, 10.10 Maverick Meerkat and 11.04 Natty Narwhal, use the following commands in a terminal:

sudo apt-get remove openoffice*.*
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice
sudo apt-get install libreoffice-gnome
sudo apt-get install language-support-en

The last two commands integrate Libreoffice with the gnome desktop environment and replace the spellchecker and the language support packages which were removed with OpenOffice (you can replace "-en" with your language in the final command).

The version of OpenOffice is 3.2 and the integration has a few problems so this is possibly a good update to make to Lucid.

Installing Firefox 4 in Ubuntu Lucid Lynx 10.04

Natty uses the latest Firefox 4 and this is now available from Ubuntuzilla Repository which is a third-party repository. There seems to be no PPA but the repository contains the latest released versions of Thunderbird and Firefox and it can be added to the Third Party Software Sources lists used by the Synaptic Package Manager if you want to update an earlier (LTS) version such as Lucid. You should not use Ubuntuzilla with Natty as these versions do not integrate with the Unity Desktop or AppArmor and you should remove the repository before upgrading. The instructions are all clear at Ubuntuzilla and it only involves copy/pasting three commands and running in a terminal to make Firefox 4 available to Instal. In summary for 10.04 and 10.10:

Copy and paste the following command (as one line) into a terminal and run it. This adds the Repository to your sources.list :

echo -e "\ndeb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main" | sudo tee -a /etc/apt/sources.list > /dev/null

If you wish, verify that the repository has been added, by looking at /etc/apt/sources.list in your favourite text editor.

Then add the package signing key to your keyring, by running the following command in a terminal:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29

Now Update your package database by:

sudo apt-get update

You should now check that the new version is available in the Synaptic Package Manager by searching for firefox-mozilla-build and installing it. It will add links which bypass the Firefox 3.x you are using.

It is significantly improved but you may need to reconfigure your toolbars as items such as the + for a new tab may have gone. It is easiest to reset the toolbars to the default then start again when you have seen the changes. I have also moved the tabs back to their usual place. You may find that some of the Extensions need to be updated and some may not yet be compatible.

Unity Terminology and keyboard/mouse shortcuts

If you wonder about the terminology used for the various components of the Unity see here http://askubuntu.com/questions/10228/whats-the-right-terminology-for-unitys-ui-elements

 

  1. Launcher
  2. Launcher Items
  3. Workspace Switcher
     -- Menu Bar --
  4. Window Title
  5. Application Menus
  6. Status Menus (Indicators)
    • Network Menu
    • Sound Menu
    • Messaging Menu
    • Clock
    • Me Menu
    • Session Menu
      and others
  7. Window Decoration
  8. Window Buttons
  9. Toolbar
  10. Status Bar
  11. Desktop
  12. Ubuntu Button (Home Button)

There are more useful pages at askubuntu.com covering Unity keyboard and mouse shortcuts some of which I have reproduced here with some of my additions - Initially I found it difficult to see why Unity has any advantages without this information and then I realised that most of it is implemented via Compiz and is equally applicable whether you use Unity or not!

Unity Keyboard and Mouse Shortcuts

Ones I find useful are coloured

Ones I found did not work at present are Grayed out

Keyboard

Launcher

Dash

Panel

Window Management

Window Placement

If you cycle through the same key Unity will cycle through different placement widths, so experiment by hitting the numkey multiple times:

Workspace Management

Screenshots

Mouse Tricks

Launcher

Window Management

17th April 2011

O2 Pay and Go

I am having to change my O2 tariff because the legacy contract Leasure 600 tariff is no longer offered - it was £100 a year for 600 minutes off peak without data (except for dial-up) with a £75 discount if I did not take a new phone. I need to keep to O2 because it saves me £60 on my broadband from O2 which is excellent. Pay and Go is acceptable for the broadband discount if I top up £10 every three months and I can ask for the number to be transfered to my new SIM when I terminate the Contract and the prediction is 48 hours with only a dead time of 2 hours.

I have so far bought the new Pay and Go SIM - actually free with a £10 Topup in the Shop. One needs to chose an initial tariff but one can swop round using phone calls, Internet, TXT and in a shop. I agonised over tariffs - the Simplicity Tariff on P&G which is pushed is better than the Contract one but still needs a £10.50 deduction from the phone credit monthly to be useful.

The tariff I have chosen is Text and Web which needs no monthly deductions but depends on a Topup of £10 which provides 300 Texts and 500 Mbytes of Data (and Wifi) to be used in the next 30 days in addition to the Topup. Once you have this active it seems that the topup required to keep it going can be anytime during the month ie you do not need to wait till it has expired before topping up. The first month I monitored data use carefully and used 470 Mbytes and 6 TXTs

Boltons are not advertised in the brochures for the Tariff but I found I have the ability to buy a monthly Bolt-on giving 100 minutes of calls to Landlines for £5 on the Web which is very consistent with my previous use. Once started the bolt-on continues until cancelled or you run out of credit. Most other calls are 25p/min. including support calls

Automatic topups can be set up on the web by month or when your credit falls to a given level to ensure your bolt-ons continue.

O2 Pay and Go Settings for Data Access

The following were sent me during a chat session with O2 Support - I have coloured the information I have actually used so far:

GPRS Settings: Homepage: http://wap.o2.co.uk/ APN address: payandgo.o2.co.uk Gateway (IP) address : 193.113.200.195 Username : payandgo Password: password Session type: Continuous or permanent Authentication: Normal Security: Off Port number: 9201

Data Bearer : GPRS Access Point Node (APN): payandgo.o2.co.uk User ID: payandgo Password: password Authentication: Normal Gateway: 193.113.200.195 MMS Message Server: http://mmsc.mms.02.co.uk:8002 Session Mode: Permanent

O2 Text and Web Tariff Details

To Opt in to Text and Web Text TEXTANDWEB to 21300 or Call 2202 free

On top of your credit you get for the following month:

You can check your balances by calling 4444. Or text ‘balance’ to 20202. Both are free. Calling 4444 gives a comprehensive menu which allows you to topup, add and remove bolt-ons, change tariffs etc as well as checking your various balances.

Setting up MyO2 allows one to login and check and set up everything in a very convenient manner and also allows one to opt in and access ones 'Rewards' which are 10% of your topups which can be used for topup, new phones or various other things.

Voicemail 901 answers any calls you miss and lets you know when you have new messages. It is ready to go on all new O2 SIMs. If it's switched off, you can turn it on by calling 1750 free of charge from your mobile. To Switch it off - Dial 1760 from your mobile free of charge.

The alternative is O2 Call Alert - call 1710 free of charge from your mobile to toggle it on and off. Please note: you can only have one service or the other.

O2 Voicemail ring time

You can change the ringing time before Voicemail 901 is activated, simply enter the following code **61*901*11*(NO OF SECS)# send. No of secs must be 5,10,15,20,25 or 30 - also see http://www.talk3g.co.uk/showthread.php?6655-O2-Extending-the-Ring-Time-%28iPhone-and-others%29

 

28th April 2011

Unity Day - Ubuntu 11.04 Natty Installed

One of our MSI Wind U100 netbooks has been used as the guinea pig for this and was updated on the Internet first to 10.10 and then to 11.04. The upgrade to 10.10 froze and had to be restarted but fortunately picked up where it had left off from its cache and completed successfully. The next upgrade to 11.04 natty went without incident.

Natty - choice of Unity Desktop or conventional Gnome Desktop

This can be done at login - once the user has been chosen a series of choices are available in a bottom panel including the desktop - the desktop choice is sticky. As far as I can tell so far the settings are largely independent in both although the Desktop remains the same.

Natty Configuration - Launcher Icon Size and preventing hiding of Launcher

This is set in the Unity Plugin in the Compiz Window manager which is reached from System Settings (now under the 'Logout' button) -> CompizConfig Settings Manager -> Desktop -> Ubunty Unity Plugin -> Experimental -> Launcher Icon Size and set to 32 .

The Launcher can be kept fixed rather than being hidden by CompizConfig Settings Manager -> Desktop -> Ubunty Unity Plugin -> Behavior -> Hide Launcher and set to Never

The combination of smaller icons makes the use of Unity much quicker and easier, much more like the old bottom panel.

Natty Configuration - Restoring the Systray for all applications when running Unity

Many programs that I use require use of Indicators in the Systray (ie on the top panel) which is blocked by default for most programs in Natty. In my case this prevented use of Truecrypt, Kaffeine and Gnome-ppp to name a few.

There are several places on the web which cover this and the best overall site covering such matters currently is Web UPD8 - there is a good article on How to Re-enable the Notification Area (systray) for all Applications.

First you need to instal the configuration tool for the Unity Desktop - the equivalent to gconf-editor for the gnome desktop. Not surprisingly it is called dconf-editor and most of it is very similar - there is however a useful addition of a return to defaults button for each setting. It can be installed in a terminal or you can use the Synaptic Package Manager. In this case I used a terminal to get the overall package of tools but first I had to enable the universe repository and the easy way was to run the Ubuntu Software Centre and use the drop down edit menu -> Software Sources and tick the Universe box on the Ubuntu Software tab - you should also be able to search and install from the Software Centre:

sudo apt-get install dconf-tools

Now run dconf-editor using the terminal

dconf-editor

then navigate to desktop > unity > panel and enter: ['all'] in place of the existing string in Value for the for the Key systray-whitelist by clicking, overwriting with ['all'] and then a return.

Natty/Unity mouse click freezes

I have had a couple of program problems which have frozen the mouse clicks. Alt F4 will close a program and release the mouse. These intermittent freezes could be a problem with my use of mousemu alongside unity which also makes use of the 'Super' key. They seem to have largely gone away with the latest updates.

Natty/Unity Workround for Mouse Displacement and other anomolies using Dreamweaver and other programs running under Wine?

I could not use Dreamweaver which runs under Wine with Unity as the Mouse Pointer wass displaced by what seems to be a toolbar width down. This seems to come and go - cause unknown. I have now found a workround which is to avoid running wine/dreamweaver maximised but to run it in a window which is adjusted to be as big as possible. Dreamweave always seems to be launched maximised but it is simple to use the new mechanism of draging the top panel down to change it to a window then drag it back up where it parks in the correct position. I use the same trick for other programs running under Wine and it seems to cause confusion if you have more than one program running under wine. Even worse running Picasa shows up as another window of Dreamweaver or Paint Shop Pro - definitely some bugs here! It seems to now be recognised at https://bugs.launchpad.net/unity/+bug/755406 and at https://bugs.launchpad.net/ubuntu/+source/unity/+bug/704187/

Natty Customisation - Suitable Themes

I have had to change my themes and also put the control icons back on the left side as I had modified this for Lucid - I am currently using Ambience customised with Tangerine icons and a background picture of the QE2.

Natty Improvements

A major step forwards is that the addition of signal strength to the display when using a mobile broadband stick. The network monitor also now identifies the network name and type you are connected to. There is also improved handling of Mobile Phones connected via Bluetooth if you can fix all the bugs with Bluetooth. These are not dependent on using Unity.

Restoring Ctrl Alt Backspace function to restart Xserver and go to login screen

Unity is sufficiently flaky at present that one needs ways to escape from a major freeze such as restarting the Xserver.

Administration or System Settings -> Keyboard -> Layout -> Options -> Key Sequence to Kill the Xserver and tick box for Control Alt Backspace.

2 - 7 May 2011

I found great difficulty in making a Bluetooth connection to my mobile phone on searching I found there is currently a problem with Bluetooth see https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/762964 and Bluetooth needs to be restarted after a Cold Boot, Restart, Suspend and Hibernate. There are further problems if you want to use Bluetooth to connect to a modem in mobile phone as the devices rqeuired are no longer automatically connected so programs such as gnome-ppp will no longer work.

Short-term Fix to allow testing of Bluetooth - Restart Bluetooth in a terminal.

This is a simple way to allow one to test out and bluetooth but has the disadvantage that a command has to be entered and run in a terninal after every startup, reboot and when leaving suspend and hibernate. It may be an acceptable way to proceed for occasional use if one assumes the bug will be quickly fixed!

Open a terminal by Applications; Search for Terminal and in the terminal enter:

sudo /etc/init.d/bluetooth restart

A Way to automatically start bluetooth

I have tried adding restart bluetooth to /etc/rc.local which is run after all other init scripts. This works most of the time at cold starts and restarts but does not work after a return from suspend - there must be a better or extra place to place it for Natty

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Addition to ensure bluetooth is restarted
/etc/init.d/bluetooth restart

exit 0

Ways to restart BlueTooth after a Suspend or Hibernate

I have found out that the scripts which are run on Suspend, Hibernate, Resume and Thaw are in /etc/pm/sleep.d where I created a new fle as root called 99_bluetooth-restart and gave it execute permissions. It can be created by

sudo gedit etc/pm/sleep.d/99_bluetooth-restart

The permissions can be set most easily by starting nautilus (the file navigator) as root and navigating to the file, right clicking -> Properties -> permissions and seting the execution tickbox

gksudo nautilus /etc/pm/sleep.d

The contents have to follow a strict format I copied from other files giving:

#!/bin/bash
#
#This is run automatically after returning from a suspend or hibernate
#It restarts Bluetooth
#
case "$1" in
thaw|resume)
/etc/init.d/bluetooth restart
;;
*)
;;
esac
exit

There is a brief explanation of the file format at http://ubuntuforums.org/showthread.php?t=1484156

The end result of the three modifications mean that Bluetooth is turned on correctly with the rfcomm bindings (Bluetooth Device creation) carried out for 95% of the time and an extra suspend and resume will enable it almost for certain!

 

Natty Bluetooth - Connections to phone modems using Bluetooth Manager and Network Manager.

There is a new method of making a bluetooth connections to modems in phones which then appear in the Network Manager. The new way is described in https://help.ubuntu.com/community/BluetoothDialup for 10.10 and is a big step forwards although it does not work for 'tricky' phones like those running Windows mobile. The following assumes the Bluetooth problem in Natty has been fixed or you are prepared to do a Bluetooth restart in a terminal as above.

When Bluetooth is enabled on, for example, my MSI Wind U100 a Bluetooth icon appears in the Indicator Applet in the top panel. Right Click -> Preferences to see if you already have any BT connections set up from earlier versions as you need to clear them and set up the device including 'pairing' again to get to the new option to make a Dial Up Networking (DUN) connection to the modem in the phone in a way it will appear in Network Manager - this is alluded to in the reference above. So delete any existing connections to the phone - Set Up the device again using the Set Up New Device button, work through the wizard to pair the phone and at the end it offers a tick box to add a DUN connection - this then takes you to wizard to add the APN etc and eventually the connection ends up in the Network Manager (In System Applet in top panel) but, be warned, you do not seem to be able to edit the settings so if they are wrong you have to start again by deleting the device etc.

Using dialer applications such a gnome-ppp under Natty

The method above will not work with fancy phones such as Windows Mobile Devices because it is unable to detect and obtain details of these phones which do not follow the standards properly. You therefore need to use a connection application such as the excellent gnome-ppp which I have been using for many years.

I have found there is yet another problem with using Bluetooth through Gnome-PPP in that the rfcomm devices are not being created in Natty even when Bluetooth running correctly - it took me a while to remember that this is actually a problem I have met before and involving editing a system file in Lucid. I will reproduce the section from Ubuntu on the Move here for completeness:

Fix for a bug where the bluetooth modem (rfcomm) devices are not automatically created (Karmic - Natty)

There is a bug (see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/416056) starting in Karmic and the rfcomm devices are not automatically started - so one sets up the configuration file rfcomm.conf but the rfcomm program is not run so the rfcomm devices are not created. You can check by looking in /dev to see if /dev/rfcomm0 is present. The obvious thing to do is to modify /etc/init.d/bluetooth to add rfcomm bind all at the end of the startup sequence and rfcomm release all at the start of the stop sequence. So, in a terminal open the file for editing by typing:

gksudo gedit /etc/init.d/bluetooth

and add the lines in red to the file as in the section shown below for Lucid.

case "$1" in
start)
#currently this init script exists only because of what appears to be
#an egg and chicken problem
# bluetoothd normally starts up by udev rules. it needs dbus to function,
# but dbus doesn't start up until after udev finishes triggering
#
if [ ! -f /sbin/udevadm.upgrade ]; then
udevadm trigger --subsystem-match=bluetooth
fi
# Additional code to automatically bind the devices set up in rfcomm.conf during startup
rfcomm bind all

;;
stop)
# Additional code to automatically release the devices set up in rfcomm.conf when bluetoth stopped
rfcomm release all

pkill -TERM bluetoothd || true
;;
restart|force-reload)
$0 stop
$0 start
;;

Note that you should make any backup of the file /etc/init.d/bluetooth in a different folder as everything in the init.d folder is run at startup and you will end up doing everything twice in an unpredictable order.

The file /etc/init.d/bluetooth is slightly different for Natty although the changes are similar

case "$1" in
start)
#currently this init script exists only because of what appears to be
#an egg and chicken problem
# bluetoothd normally starts up by udev rules. it needs dbus to function,
# but dbus doesn't start up until after udev finishes triggering
#
log_daemon_msg "Starting $DESC"

if [ ! -f /sbin/udevadm.upgrade ]; then
udevadm trigger --subsystem-match=bluetooth --action=add
log_progress_msg "bluetoothd"
fi

log_end_msg 0

# Additional code to automatically bind the devices set up in rfcomm.conf during startup
rfcomm bind all

;;
stop)
# Additional code to automatically release the devices set up in rfcomm.conf when bluetoth stopped
rfcomm release all

log_daemon_msg "Stopping $DESC"
pkill -TERM bluetoothd || true
log_progress_msg "bluetoothd"
log_end_msg 0
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;

8 May 2011

Running Gnome-PPP under Natty with Unity

Gnome-PPP uses the system tray so the fix for the System tray has to carried out before one can run it.

Restoring the Systray for Gnome-PP and all other applications when running Unity

There are several places on the web which cover this and the best overall site covering such matters currently is Web UPD8 - there is a good article on How to re-enable the notification area (systray) for all aplications. How to Re-enable the Notification Area (systray) for all Applications which provides the basis for understanding how I got Truecrypt working.

First you need to instal the configuration tool for the Unity Desktop - the equivalent to gconf-editor for the gnome desktop. Not surprisingly it is called dconf-editor and most of it is very similar - there is however a useful addition of a return to defaults button for each setting. It can be installed in a terminal or you can use the Synaptic Package Manager. In this case I used a terminal to get the overall package of tools but first I had to enable the universe repository and the easy way was to run the Ubuntu Softwar Centre and use the drop down edit menu -> Software Sources and tick the Universe box on the Ubuntu Software tab - you should also be able to search and install from the Software Centre but it did not work on Beta 2:

sudo apt-get install dconf-tools

Now run dconf-editor using the terminal

dconf-editor

then navigate to desktop > unity > panel and enter: ['all'] in place of the existing string in Value for the for the Key systray-whitelist by clicking, overwriting with ['all'] and then a return

You now need to logout and log back in.

Gnome-PPP now connects fine once one has done the Systray, Bluetooth and the rfcomm Bindings fixes but I found it was quickly disconnecting when I was doing updates with an O2 connection.

Gnome-PPP - Modifications to PPP Options to prevent timeouts with Mobile Broadband Connections

Some modifications are required in /etc/ppp/options as the default settings cause timeouts with some mobile connectsions.

These settings can not be changed via the Gnome-PPP GUI interface and I change them in the the 'master' pppd (I think that stands for ppp daemon) set up file which is /etc/ppp/options so the changes apply to all users. We can look at the current options which are set by:

sudo egrep -v '#|^ *$' /etc/ppp/options

It is desirable to make a backup before editing the /etc/ppp/options file so to make a copy and open a terminal:

sudo cp /etc/ppp/options /etc/ppp/options_bak
sudo gedit /etc/ppp/options

I normally make three changes to the file. The first two are essential for most GPRS connections and disable the sending and checking of the echo response sent to check the connection is alive - the echo is not implemented by most mobile service providers and the default result is that 4 echo response requests are sent at 30 second intervals and after the 4th failure to receive a response the connection is broken. If you are disconnected after 2 minutes that is the cause. The new values of 0 inhibit the sending and checking:

lcp-echo-failure 0
lcp-echo-interval 0

The third change is essential, as far as I know, for the Vodafone PCMCIA Connect Card but does not impact other connections significantly so I do it routinely so I do not forget. It involves disabling negotiation of Van Jacobson style IP header compression by un-commenting

-vj

I have also tried modifying the /ect/ppp/options file to add an extra delay before connection as I was sometimes not getting a correct DNS delivered using gnome-ppp with the Vodafone but it seems to have little benefit but you can try it but only if you have problems as it will slow down making all connections.

connect-delay 5000

Note the information in the /etc/ppp/options file does not recommend that changes are made in this file. The documentation ( man pppd ) says that if there is a file ~/.ppprc which is used for user default options which could be used instead of modifying /etc/ppp/options - I have not tried that method as the simple way works for me and gives me a working system. I have the attitude that "if its not broken don't fix it" and this way works for all users.

Once all these fixes were complete I can use the T610, O2 XDA Exec and Palm to connect to the Internet via bluetooth just as I could on earlier versions of Ubuntu. There are a number of special techniques needed to use the XDA and Palm because they run Windows Mobile 5 which does not follow the 'rules'. This is why the new methods using network manager do not work - Windows Mobile Phone are not detected properly by Ubuntu Natty 11.04 but manual access via Gnome-PPP is fine.

10 May 2011

Wammu under Natty

Nothing special required - I loaded from the Synaptic Package Manager. It requires the Systray fix if you want to use the feature of minimising to the Systray otherwise everyhing worked as expected after a reboot - it complained about perpissions when trying to connect to a phone until the reboot. The T610 was connected via rfcomm0 so the fix for Bluetooth and the rfcomm device creations fix was required. The K3565 dongle connected via /dev/ttyUSB1 just as on my other machines with Lucid. I loged out nd switched to Ubuntu Classic mode to create a desktop launcher. See the Wammu Section in Ubuntu on the Lookout for more about Wammu.

11 May 2011

A Netspeed AppIndicator for Ubuntu 11.04 with Unity

The last outstanding facility I needed for Ubuntu 11.04 Unity was a replacement for the Netspeed Applet which would continuously display upload and download speeds in the 'panel'. Applets no longer work in Unity and the nearest replacements are called Appindicators so I have been looking for a replacement which I eventually found on Webupd8 in the article How To Display Network Upload / Download Speed On The Panel In Ubuntu 11.04 . This solution uses an existing Appindicator called Indicator-Sysmonitor which is very versatile and allows one to display almost anything on the Unity (or GNOME) panel by using a simple command or a bash script. In this case a script has been written by Alex to display any combination of network speeds, memory use and cpu loads using a system application called dstat to provide the information. I have modified the script slightly to display lower data rates for watch for data 'leakage' when operating mobile.

Indicator-Sysmonitor is in a PPA which can be loaded using a terminal by:

sudo add-apt-repository ppa:alexeftimie/ppa
sudo apt-get update
sudo apt-get install indicator-sysmonitor

The script needs a system program called dstat to be installed - this is a very versatile way to monitor maany system parameters do a man dstat to find out more once it is installed. It can be installed in a terminal by:

sudo apt-get install dstat

My modified version of the script which follows should be stored as sysmon in a folder called scripts in the home folder - if you put it elsewhere the command in Indicator-Sysmonitor will need to be modified.

#!/bin/bash
# Script from http://www.webupd8.org/2011/05/how-to-display-network-upload-download.html#more
# Modified by Peter Curtis on 15th May 2011.

#settings:
netspeed=true
ram=false
cpu=false
#-------------------------------------------------------

#---------------- initialize ---------------------------
rm /tmp/.sysmon > /dev/null 2>&1
dstat --net --mem --cpu --output=/tmp/.sysmon 1 1 > /dev/null 2>&1

#----------- up/down speed -----------------------------
if [ $netspeed = true ]; then

#upspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024 | bc)
upspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1 | bc)

upkbmb=$(if [ $upspeed -gt 1024 ]; then
up1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024 | bc -l)
echo $up1 | head -c 4
else
echo $upspeed | head -c 3
fi)
#
#downspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024 | bc)
downspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1 | bc)

downkbmb=$(if [ $downspeed -gt 1024 ]; then
down1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024 | bc -l)
echo $down1 | head -c 4
else
echo $downspeed | head -c 3
fi)

#---------------- up/down speed unit --------------------

upunit=$(if [ $upspeed -gt 1024 ]; then echo "KB"; else echo "B"; fi)
downunit=$(if [ $downspeed -gt 1024 ]; then echo "KB"; else echo "B"; fi)

fi

#------------------- CPU % used -------------------------
if [ $cpu = true ]; then
cpufree=$(cat /tmp/.sysmon | tail -1 | cut -d ',' -f9)
cpuused=$(echo 100-$cpufree | bc | sed -e 's/\..*//')
fi

#------------------- RAM % used --------------------------
if [ $ram = true ]; then

memused=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 3)
memfree=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 4)
memtotal=$(echo $memused+$memfree | bc -l)

memusedpercent=$(echo 100-100*$memfree/$memtotal | bc)

fi

#------------------ The Indicator Sysmonitor actual output -
echo $(if [ $ram = true ]; then echo Mem: $memusedpercent% \|; fi) $(if [ $cpu = true ]; then echo CPU: $cpuused% \|; fi) $(if [ $netspeed = true ]; then echo↑$upkbmb$upunit↓$downkbmb$downunit; fi)

Open Indicator-Sysmonitor (it should show up as System Monitor Indicator in the menu), then click it on the panel and select "Preferences" and under "Use this command", enter this:

$HOME/scripts/sysmon

Close and re-open sysmon and it should now display upload and download speeds.

I start it automatically by System Settings -> Personal ->Startup Applications -> Add - and fill in the command as indicator-sysmonitor , the name as Netspeed Appindicator and the Description as Displays Download and Upload Speeds

12-16 May 2011

Fix to AppArmor to use a Firefox 4 profile on a separate drive/partition under Ubuntu Natty 11.04

I have always used a separate partition/drive for Data as well as having a separate partition for my home folder. When I upgraded to Ubuntu 11.04 I found none of my profiles would run under Classic Ubuntu or Unity. They still ran perfectly when I used the 'straight' Firefox 4 firefox-mozilla-build from the Ubuntuzilla PPA but that did not integrate with the Unity so that was not a long term solution. The error message on trying to start Firefox was:

Firefox cannot use the profile "??????" because it is in use. To continue, close the running instance of Firefox or choose a different profile.

This message is apparently given if the profile is locked or if the profile can not be found. It is clearly not a stale lock file as it also occured when I created a new profile so it would seem Firefox cannot find or has access blocked to the Profile.

I evetually narrowed the problem down even further and found my existing profiles would run in the default location ~/.mozilla/firefox or in a sub-folder below that location but nowhere else even via a symlink in ~/.mozilla/firefox. I could only create new profiles in the same locations. [ Click to reveal all the stages I then went through before finding the probable solution ]

The breakthrough came with a suggestion on AskUbuntu that I checked the AppArmor-Profile for Firefox. AppArmor ("Application Armor") is a security module for the Linux kernel designed to proactively protect the operating system and applications from external or internal threats, by enforcing good behavior and preventing application flaws, even unknown ones, from being exploited. AppArmor security policies completely define what system resources individual applications can access, and with what privileges. AppArmor works by implementing security profiles (apparmor-profiles) that restricts the capabilities of protected programs. Ubuntu has included AppArmor since 7.10 but up till now the apparmor-profile for firefox has present but not enabled.

This looked a likely cause of my problems but it took a lot of searching and background work over many days before I came up a very short and easy long term solution. [ Click to reveal all the background, detailed commands and terminal output from configuring AppArmor. ]

The bottom line is that any local modifications required to the 'policies' used by apparmor for firefox can just be added to the file /etc/apparmor.d/local/usr.bin.firefox and will remain in force through any system and firefox upgrades . In my case I want to allow access to the folder Profiles on any fixed drive, USB drive or encrypted volume from Truecrypt mounted at /media and read access to the whole of those drives

Edit the file in a terminal by:

sudo gedit /etc/apparmor.d/local/usr.bin.firefox

The resulting file in my case was:

# Site-specific additions and overrides for usr.bin.firefox.
# For more details, please see /etc/apparmor.d/local/README.

# Additions made by Peter Curtis 16 May 2011 to access profiles
# on removable media,additional filesystems and encrypted volumes
# in folder Profiles and to have read access to everything.

/media/** r,
owner /media/*/Profiles/** wmk,

Firefox has so far worked exactly as expected and required under Ubuntu 11.04 since this addition to /etc/apparmor.d/local/usr.bin.firefox whilst enjoying a high degree of protection from AppArmor.

18th May 2011

Taming Unity with Compiz

Unity has very efficient interface in terms of increasing the real estate available for Applications but it lacks far behind in offering even the most basic facilities. For years I have told beginners that if they they were ever uncertain how to do something then right clicking would almost inevitably give them a route to do it - just try that on a Unity launcher Icon. The answer lies in Compiz

Compiz is a compositing window manager for the X Window System that exploits most current 3D graphics hardware to create fast desktop effects for window management. A window manager is software that draws a graphical user interface on a computer display – it positions windows, draws additional elements on windows (such as borders and title bars), and controls how windows interact with each other, and with the rest of the desktop environment. With earlier window managers, each program was responsible for rendering its own window directly to display memory. A compositing window manager, however, combines the buffers of each window into a unified framebuffer representing the entire screen.

Compositing window managers such as Compiz can perform additional processing on the buffered windows, applying 2D and 3D animated effects such as fading, scaling, rotation, duplication, bending and contortion, shuffling, blurring, redirecting applications, and translating windows into one of a number of displays and virtual desktops. Computer graphics technology allows for visual effects to be smoothly rendered in real time such as drop shadows, live previews, and complex animation. Since, technically, the screen is double buffered, it does not flicker during updates. The most commonly-used compositing window managers for Linux are Compiz, KWin, and Mutter. Compiz can replace the default managers (Mutter in GNOME and KWin in KDE) because it conforms to the Inter-Client Communication Conventions Manual standard.

Compiz has split and rejoined in the last 6 years and now has all the developments from Beryl and Compiz Fusion back under the same roof. The best source of information is the Compiz Wiki wiki.compiz.org and the description of window managers above draws heavily on wikipedia.

In Compiz, the effects, are implemented as loadable plugins. Compiz plugins include many advanced effects as well as simple features such as Alt-Tab application-switching with live previews or icons, and a feature similar to Exposé. The projuect has been given a big boost now Canonical Ltd. has hired Sam Spilsbury, lead Compiz developer, to further develop Compiz for Ubuntu.

Unity was initially designed for netbooks and related touch-based devices. It includes a new panel and application launcher that makes it fast and easy to access preferred applications, such as the browser, while removing screen elements that are rarely used in mobile and netbook computing.

Unity has a vertical task management panel on the left-hand side and a menu panel at the top of the screen. Using a sidebar for task management conserves vertical screen space, which is much more valuable on a widescreen netbook. The task panel displays icons for commonly-used applications and programs that are currently running. Clicking on an icon will give the target application focus if it is already running or launch it if it is not already running. If you click the icon of an application that already has focus, Unity will activate an Expose-style view of all the open windows associated with that application.

Unity depends on Compiz to provide much of its functionality which has been lost from the panels to save valuable space. It is Compiz which enables you to move or resize windows, to switch workspaces, to switch windows easily and so on. The lose of the panels and panel space does come at a cost and I find that one is currently far more dependent on the keyboard and keyboard short cuts than in previous Ubunty releases although Unity/Compiz is looking to satisfy touch screens much more.

Many of the actions which have moved from a panel to a keystroke have actually been present for a long time through earlier versions of Compiz. The Super D shortcut to toggle revealing the desktop works almost the same in 10.04 as does Super W to Expose all the active windows and Super s for Workspace Switching.

First we must load the Compiz Configuration Settings Manager so search for compizconfig-settings-manager in the Synaptic Package Manager and install it. In 10.04 it will appear in System - Preferences and in 11.04 in System Settings (bottom of drop down on far right top icon) -> Personal - in both cases as CompizConfig Settings Manager. This will reveal the full power and complexity of Compiz. Most of the functions and effects are via plugins and you will see each has a tick box to enable it. There are a few features which are built in and these are accessed under General -> General Options (which is the only icon lacking a tick box). This contains many of the basic key-bindings which glue the system together including Super D for 'Show Desktop' which it took me ages to find.

Enhancing Show Desktop (Super D)

Having talked about Super D being 'bound' to the 'Show Desktop' action I will use this as the first example of an enhancement to Compiz for Unity. In the old days 'Show Desktop had a button on the left of the bottom panel - now we have to use Super D on the keyboard. However we can also bind to mouse gestures susch as a rapid mouse movement to a corner or side. So now lets replace the button by a rapid mouse movement to the bottom left corner - a reasonably safe place. In standard desktops (non Unity) you need Normal Visual Effects enabled for this to work - this requires a medium power graphics board Right click on the desktop -> Desktop background -> Visual Effects tab.

Open CompizConfiguration Settings Manager -> General -> General Options -> Key Bindings tag and scroll down to Show Desktop where you will find there are two lines one with a keyboard symbol and the other with a screen symbol. The keyboard is set to Super D and the screen is disabled. Click on the disabled and a little window appears showing the 'hotspots' - click on the bottom left which will turn green and thats it. Now when you move the mouse quickly to the bottom left corner everything will disappear! Do it again and after a couple of seconds it will be back. It can be mixed with Super D. This is not something to do on a shared machine - the unexpected and sudden loss of all your windows after a mouse movement causes panic in the average user especially when there is no obvious way back.

Changing the Number of Workspaces

Open CompizConfiguration Settings Manager -> General -> General Options -> Desktop Size and change Horizantal Vertual Size and Vertical Virtual Size (NOT Number of Desktops) to give the number and layout you want.

Enhancing the Window Picker (Super W)

The enhancement that transforms Unity for me is to the Super W action which uses the the Scale Plugin found under Windows in the CompizConfiguration Settings manager (CCSM). Here I have made 2 changes. Firstly under Key Bindings adding a TopRight 'gesture Initiate Window Picker for all Windows and ticked the box for Click desktop to Display Desktop.

We now need to enable two more Plugins. First enable Scale Addons found under Utility -> Appearance tab -> Window Title -> Window Title Display - Highlighted Window only. This displays the window title and workspace it is on when you hover over it in the Window Picker. The text display needs an addition Plugin enabled which is called Text and is found under Image Loading.

The Window Picker (Super W) displays all Windows on all Workspaces and now also works with a mouse gesture to top right and displays the Window Title and Workspace so it can be used instead of the Workspace Selection on the Unity Launcher and also to get to the desktop. you can get back from the desktop by Super D or my gesture to bottom left.

Ring Switcher (Super Tab)

If you switch Windows and use a lot of workspaces then you may want to enable the ring switcher plugin as an addition to the usual Window Switcher which is activated by Alt tab. It looks very pretty but I think it is actually less easy to use unless you have several similar windows and need a bigger image and a clear title to distinguish them. It probably needs the Text Plugin. If using it with many Workspaces then the Super Tab could be bound to All Windows and Workspaces instaed of using Super Alt Tab every time.

Unity Configuration using Compiz - Launcher Icon Size and prevent hiding of Launcher

This is set in the Unity Plugin in the Compiz Window manager which is reached from System Settings (now under the 'Logout' button) -> CompizConfig Settings Manager -> Desktop -> Ubunty Unity Plugin -> Experimental -> Launcher Icon Size and set to 32 .

The Launcher can be kept fixed rather than being hidden by CompizConfig Settings Manager -> Desktop -> Ubunty Unity Plugin -> Behavior -> Hide Launcher and set to Never

The combination of smaller icons makes the use of Unity much quicker and easier, much more like the old panels.

TIPS

You can get your old fashioned gnome panels back on a temporary basis to enable you to, for example put a launcher on the desktop. Enter in a terminal:

gnome-panel

It will look a mess with the Gnome panels over the top of the Unity top panel but it will work for long enough to make sme desktop icons from the Applications menu. You can exit by Ctrl C in the terminal

Removing surplus entries from the Unity Launcher

I do not have a lot of space even with reduced size icons on my Unity launcher so I removed an number of the applications by just right clicking and unticking Keep in Launcher. This does not work for 'Places' or 'Applications' so I used the following method which I found on Webupd8

First make a backup of the original files by

mkdir ~/backups
cp /usr/share/unity/places/applications.place ~/backups/
cp /usr/share/unity/places/files.place ~/backups/

To hide Unity Places icon, run this command:

sudo sed -i '14i ShowEntry=false' /usr/share/unity/places/files.place

I did not hide the Unity Applications icon but believe I could have done so by running this command:

sudo sed -i '12i ShowEntry=false' /usr/share/unity/places/applications.place

Note: Only run the above 2 commands once as they add entries to a file!

You must log out and log back in before the changes become effective.

If you want to restore the icons, remove the first "ShowEntry=false" entry in these two files:

/usr/share/unity/places/applications.place
/usr/share/unity/places/files.place

Or restore your backup:

sudo cp $HOME/backups/*.place /usr/share/unity/places/

(Original tip thanks to Richard Arkless; via Ubuntuforums and WebUpd8)

Reset Unity Launcher icons completely

If you want to reset the Unity Launcher icons to their initial state, run the following command:

unity --reset-icons

22 May 2011

Quicklists for Unity Launchers

It is possible to add items to the list of actions you have available when you right click on a Unity Launcher Icon. The default quicklist is just Quit, Keep in Launcher and the application or action although Places and LibraOffice Writer have some additional Quicklist items. See the best currently for specifications on the Unity Wiki . There is a simple tool described on Webupd8 and an excellent article at AskUbuntu - A list of custom launcher quicklists for unity . The tool will be very useful but is currently not foolproof so it is best to get an understanding of how to do it my hand before using the tool.

So what sort of quicklist items will save more time in the medium term than they take to create? One obvious for anybody doing system work is the ability to open additional terminals. Another couple are to add opening the file manager in your documents folder/drive and to open the file browser running as root which enable one to do almost anything with system files. The final ones I would pick out are additions to thunderbird to open in the address book or via the profile manager - there are dozens more which people find useful at AskUbuntu - A list of custom launcher quicklists for unity.

Before you start to edit your Unity Launcher Items you need to know about where the 'default' ones are stored and where the ones you have edited need to be stored to over-ride the defaults. Mostly you will find ones in the 'over-riding' folder already but sometimes you need to copy a fresh one in or you may wish to do so if you have messed up one so it does not work. Each of the launcher items is in a sensibly named file with the extension .desktop with the original/default for all users in /usr/share/applications/ and the modified versions which are user specific are in ~/.local/share/applications.

I am going to use a quicklist for 'Home Folder' as an example as it is well documented and the GUI tool does not currently work with it because an additional modification is needed. I am also going to add quicklist items that nobody has documented as far as I know for open nautalus as Root, Computer and Network as well as for my Data Drive

Copy 'Home Folder' launcher file to your home directory if it is not already present:

cp /usr/share/applications/nautilus-home.desktop ~/.local/share/applications

Open the file for editing in gedit:

gedit ~/.local/share/applications/nautilus-home.desktop

Now a critical step which is missed from the current GUI tool and without which nothing is displayed - find the following line from the file:

OnlyShowIn=GNOME;

Replace the above line with:

OnlyShowIn=GNOME;Unity;

Add this text to the bottom of the file, then close and save:

X-Ayatana-Desktop-Shortcuts=Videos;Documents;Music;Pictures;Downloads;Datadrive;Root;Computer;Network

[Videos Shortcut Group]
Name=Videos
Exec=nautilus Videos
TargetEnvironment=Unity

[Documents Shortcut Group]
Name=Documents
Exec=nautilus Documents
TargetEnvironment=Unity

[Music Shortcut Group]
Name=Music
Exec=nautilus Music
TargetEnvironment=Unity

[Pictures Shortcut Group]
Name=Pictures
Exec=nautilus Pictures
TargetEnvironment=Unity

[Downloads Shortcut Group]
Name=Downloads
Exec=nautilus Downloads
TargetEnvironment=Unity

[Datadrive Shortcut Group]
Exec=nautilus --no-desktop /media/DATA
Name=DATA
TargetEnvironment=Unity

[Root Shortcut Group]
Exec=gksudo nautilus /
Name=Open Nautilus as Root
TargetEnvironment=Unity

[Computer Shortcut Group]
Exec=nautilus --no-desktop computer:
Name=Computer
TargetEnvironment=Unity

[Network Shortcut Group]
Exec=nautilus --no-desktop network:
Name=Network
TargetEnvironment=Unity

Log out and log in again to see the changes - you will see nothing until you have logged out and in. [ Click to reveal my latest complete file as of 23 May 2011

Instructions for installing the latest version of Wine 1.3 from the WineHQ PPA:

The WineHQ web site cautions that The 1.3 packages are beta packages. This, they say, means they will periodically suffer from regressions, and as a result an update may break functionality in Wine. If the stable 1.2 Wine version works for you, then you may not want to use these beta packages. Ubuntu Natty also offers 1.3 but these will be better tested but slightly earlier versions. I want to use the latest versions to see if the pproblems of compatibility with Unity get fixed.

Run the following in a terminal:

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.3

12th July 2011

Bug Fix for Invisible Task List text in Lightning 1.02b in Thunderbird 3.1 when using 'Dark' Desktop themes such as Ambience - the default in Natty

The task list is impossible to read when certain themes are used with Lightning 1.02b. This bug https://bugs.launchpad.net/ubuntu/+source/lightning/+bug/703503 is caused by the text colour used for the items in the task list being displayed using the same default as menu items which is a very light colour with dark themes such as Ambience which has been available since Ubuntu 10.04 and is the default in 11.04 Natty. One way to avoid this is to make sure each task has been started when the display changes to green.

The best fix is to edit the file in the extension which determines the text colour. This is a .jar (Java Archive file) in Lightning 1.02b which has to be unpacked, the file changed and the file returned to the archive. The files are in the Thunderbird Profile which in my case has been moved to a separate drive and in a sub folder so it is at /media/DATA/Profiles/vortex-ubuntu/. You will need to change this string to point to your default profile in the terminal command below to something like ~/.thunderbird/xyz.default where xyz is a random 8 character string differing for each user. Note the " "s are important to avoid the {} being incorrectly interpreted. The following command opens the file in the Archive Manager on my machine.

file-roller "/media/DATA/Profiles/vortex-ubuntu/unjrox60.TB31_Peter/extensions/{e2fda1a4-762b-4020-b5ad-a41df1933103}/chrome/calendar.jar"

You then need to navigate in the archive and edit the file located at /skin/calendar/calendar-task-tree.css and change the two occurences of MenuText to WindowText . This can be done from within the archive manager and when the edit is finished yiu will be asked if you want to replace the changed file into the archive.

This bug ( https://bugs.launchpad.net/ubuntu/+source/lightning/+bug/703503 ) has been corrected in Thunderbird 5.0 so an alternative is to switch to the new version. I have done that on a couple of my machines.

12th July 2011

Thunderbird 5.0 with Lightning 1.0b4

The latest version of Thunderbird is version 5.0 which is available in the thunderbird-stable PPA which can be installed by the following sequence of commands in a terminal:

sudo add-apt-repository ppa:mozillateam/thunderbird-stable
sudo apt-get update
sudo apt-get upgrade

The only problem at the present 12 July 2011 is that many of my favourite extensions have either not been updated or do not work properly with natty, thunderbird 5.0 and lightning 1.04b. At present QuickMoveButton is not updated to thunderbird 5.0 and Sync Kolab needs the Nightly to be installed and that upsets the thunderbird status bar. Otherwise it seems to be a significant step forwards and I will change on all my machines as soon as the extensions are working.

15th July 2011

Allowing Extensions not yet upgraded to Firefox 5 or Thunderbird 5 to be Installed

It is possible to fudge this for some extensions by editing a file in .xpi archive to increase the value of the maximum version of Firefox or Thunderbird that is allowed in the compatibility check. This seems to be successful for Thunderbird 3.1 to 5 in some cases but may have disastrous effects in the case of other version changes. I have done it for:

Without any obvious problems so far

The procedure is to:

  1. Backup your profile.
  2. download a fresh copy of the .xpi
  3. open it in the archive manager by right click -> Open with Archive Manager
  4. Double click on install.rdf to open in gedit
  5. Change lines like <em:maxVersion>5.0</em:maxVersion> to contain 5.0 as the new maxVersion
  6. Save and close gedit then accept the offer to update the archive.
  7. Close the Archive (.xpi file)
  8. Within Thunderbird Tools -> Add-ons -> Extension and remove the existing add-ons which is disabled and restart Thunderbird
  9. Install the modified version which should now be accepted and restart Thunderbird
  10. Check everything is OK

NOTE on 30 December 2011 - There is a known bug in the latest version of the Archive Manager for Oneiric which prevents it recognising a .xpi file as an archive. The workround is to rename to a .zip before opening and rename back at the end to a .xpi

 

17th July 2011

Epson Printers, Scanners and 'All-in-Ones' under Ubuntu Linux

This is an update on my earlier Howto which described the steps necessary to use the Epson Perfection V200 Photo scanner with Ubuntu Hardy Heron which was based on an excellent Howto in Uellue's Blog. I have been using the V200 now for 3 years mostly under Ubuntu Lucid 10.04 and have had an Epson C66 printer for even longer which finally died and led to this update.

Epson SX515W All-in-One Multifunction Printer/Scanner

It is now very difficult to buy stand alone Printers or Scanners - most are 'All-in-One' Multifunction Devices. My old Epson C66 printer has been used via a wifi router as a wireless device so I looked for a printer offering wifi operation supported under linux. The other and main criterion was that I could get cheap ink cartridges. My hasty search led me to Epson once more and the SX515W printer was reduced in price at Argos to £59, offered Wifi and used the T0711 series of cartridges with the black available at 7dayshop.com for £8.99 for 10 and a full set including colour for £5.99 one off. But above all Epson offer good Linux support through their web site for both Printing and Scanning.

Wifi Setup on the SX515W - control panel details will be specific to the SX515W.

The SX515 is one of the modern Epson Printers which already has support built into Ubuntu for normal operation so although I downloaded ESC/P drivers from the Epson site for the first machine I found it was not needed on the others for direct USB cable or Wifi operation. In fact the majority of the work was in setting up the SX515W to connect to my Wifi Network via the small built in screen and keys - 26 long WEP key was a pain! The procedure is Setup -> Network Settings (two right arrows OK) - > Wireless Lan Setup (OK) -> Setup Wizard (OK) and follow instructions - you can Back out any time. The only difficult entry is the WEP or other key as the Menu key is used to select between Capitals, Lower Case and Numbers then the arrow keys and OK for the entries - all 26 in my case. I used an IP provided by DCHP but should have used a static one as next time the Wifi box is reset the IP may change so you need to know the range of IP addresses for your Wifi and choose one just outside or at the top of the DCHP range. The Wifi light should now be on. Once you have finished you can check the settings any time by Settings -> Network Settings (two right arrows OK) -> Confirm Settings (two down arrows OK) and scroll down through ( down arrows) then Back(s) till out of settings.

Epson Printer Drivers - should cover most if not all Epson Printers

The Printer and all other drivers are available on the Avasys - Epson Japanese vendor's site - this is much easier to navigate than it used to be but there are still a few things to note. Firstly there are several drivers for printers available in different sections. I loaded the driver from the link to Epson Inkjet Printer Driver (ESC/P) for Linux rather than follow the All-in-One Link as that was what I had used in the past. That presented a huge list and I picked the SX515W link and downloaded and double clicked to install it. That went fine. Later on I followed the links to All-in-One Printers and the print driver there would not install due to a dependence problem - there were scanner drive options to get round the problem with late copies of Ubuntu but not for the printer (but http://avasys.jp/eng/linux_driver/faq/id000613.php may give a way forwards). When I plugged in the USB connection the printer was installed automatically with just a notification - Linux has come a long way. On the first machine I did the driver install for Wifi using System -> Administration -> Printers and + Add Printer and then set up by hand. The next time I found that just selecting network was sufficient for it to go away and find the printer under 11.04 and I confirmed the same happened under 10.04! Forward then took me to an automatic search for the driver and all left was to edit any descriptions - I changed the port number to just be Wifi in the description. All trivially easy.

Epson Drivers for Scanners and Scanner functions of All-In-One Multifunction Printer/Scanners.

I have only tried these procedures on two scanners but other Epson scanners should work in a similar way, there is a list of supported devices on the Epson web site. The drivers provides support for 8 bit and 16 bit colour depth and 300, 2400 and 4800 dpi resolution when used by GIMP through Sane and an ImageScan! for Linux Scanner package from Epson.

Firstly a number of Ubuntu packages need to be added via System -> Administration -> Synaptic package manager and Search for each package and Install it. The packages are:

All the drivers are available on the Avasys - Epson Japanese vendor's site. Choose your scanner/multifunction scanner/printer and your distribution, fill out the small questionnaire and submit the form. You are directed to a download page.

From now on it will be a little different for a pure scanner or an All-in-One multifunction device

Scanner Only Example V200

To install the three .deb packages either just double click them or use dpkp from the folder containing them - note the iscan-data must be installed first and that you need the package with ltd7 in the name - the version numbers will probably have increased:

sudo dpkg -i iscan-data_1.9.0-1_all.deb
sudo dpkg -i iscan_2.26.4-2.ltdl7_i386.deb
sudo dpkg -i iscan-plugin-gt-f670_2.1.2-1_i386.deb

The third iscan-plugin package is a scanner specific extension only required for some scanners, most do not need it.

Multifunction Printer/Scanner Example SX515W

This part of the web site also offers print drivers but they need an extra library not in latter versions of Ubuntu as it has been superceded so use the ESC/P printer as described above in preference (although http://avasys.jp/eng/linux_driver/faq/id000613.php may give a way forwards if you want to experiment)

Now you need to download and install the scanner driver files. The procedure is well documented but note the one with iscan-data must be installed first and that you need the iscan package with ltd7 in the name.

sudo dpkg -i iscan-data_1.9.0-1_all.deb
sudo dpkg -i iscan_2.26.4-2.ltdl7_i386.deb

You will note that the files in this case are the same as for the V200 and in the case of the SX515W a plug-in is not required.

There is no mechanism to update these files and the only way is to uninstall the old version and install the new from the .deb. After doing that I found the set up above runs both my scanners, depending on which is plugged in/turned on, through 'ImageScan! for Linux' but we are getting ahead of ourselves.

There is a third file available for download to enable one to access the scanner via Wifi. I have not installed it as there seems no point in scanning remotely - I use USB cables to the desktop machine closest to the scanners and plug/turn on the one I want to use. If I need to scan onto a laptop or netbook I can carry it to the scanner.

Common to both

Now plug in and switch on the scanner and use lsusb in a terminal which should show the scanner. The output will look like this for V200:

pcurtis@triton-ubuntu:~$ lsusb
Bus 004 Device 003: ID 04b8:012e Seiko Epson Corp.
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
pcurtis@triton-ubuntu:~$ ]

Now use the utilities from sane-utils in a terminal. First use sane-find-scanner to check whether Sane finds the device. With scanimage -L you can find out if the driver is properly installed. The output looked like this for the V200:

pcurtis@triton-ubuntu:~$ sudo sane-find-scanner

# sane-find-scanner will now attempt to detect your scanner. If the
# result is different from what you expected, first make sure your
# scanner is powered up and properly connected to your computer.

# No SCSI scanners found. If you expected something different, make sure that
# you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04b8 [EPSON], product=0x012e [EPSON Scanner]) at libusb:004:003
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.

# Not checking for parallel port scanners.

# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.
pcurtis@triton-ubuntu:~$ sudo scanimage -L
device `epkowa:libusb:004:003' is a Epson Perfection V200 flatbed scanner

and for the SX515W

pcurtis@triton-ubuntu:~$ sane-find-scanner

# sane-find-scanner will now attempt to detect your scanner. If the
# result is different from what you expected, first make sure your
# scanner is powered up and properly connected to your computer.

# No SCSI scanners found. If you expected something different, make sure that
# you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04b8, product=0x0856) at libusb:001:005
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.

# Not checking for parallel port scanners.

# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.

# You may want to run this program as root to find all devices. Once you
# found the scanner devices, be sure to adjust access permissions as
# necessary.
pcurtis@triton-ubuntu:~$ sudo scanimage -L
device `epkowa:usb:001:005' is a Epson Stylus NX510/SX510W/TX550W Series flatbed scanner

Requirement to be member of Scanner Group: Depending on your exact installation only root may have access to the scanner although my original user was already in the scanner group. To allow other users to access the scanner, they must be members of the scanner group which has been renamed to saned in 9.10. You can do this by using System -> Administration -> Users and Groups -> Click to Unlock -> Groups and look for scanner or saned -> Click Properties and tick your username. You then need to reboot after adding the extra member.

After that my scanner works fine and can be accessed via GIMP and can also be accessed directly by xscanimage or xsane. Kalmic and the new driver package between them give you two direct routes to scanning from the Applications -> Graphics menu - Xsane which is a multiwindow application with many options and tweaks to the scan and a simpler package ImageScan! which seems to be part of the Avasys Driver download, to quote Avasys:

Image Scan! for Linux

You will find Image Scan! for Linux has been installed under Applications -> Graphics at the same time as the Epson Scanner Drivers. It makes it easy to obtain high quality images on Linux with an EPSON scanner. It:

Scanning over the Network with Image Scan! for Linux

I have not done this yet but the folowing Instructions come from the Epson web site

To set up your device for scanning via its network interface, follow the steps outlined below:

  1. Download and install the latest version of Image Scan! for Linux from here.
  2. If your device has a supported network interface, the iscan-network-nt plugin will also be available for download. Download and install the version appropriate for your system.
  3. Now configure your device for network access. You need to set or obtain the IP address of the device. Please consult the product manual for details on how to do this.
  4. Configure Image Scan! for Linux to connect to your device by editing /etc/sane.d/epkowa.conf. You need administrative privileges to do so. Read the instructions in the file about network configuration and add an entry for your device as indicated.
  5. Finally, disable the conflicting epson2 SANE backend. You can do so by changing the line consisting of "epson2" to "#epson2" in /etc/sane.d/dll.conf. This will require administrative privileges.

Conclusions on Epson Drivers for Linux

Epson are obviously trying very hard to support all their printers and scanners including the multifuntion printer/scanners which have been a problem in the past. The terms and conditions seem to be consistent with true Open Source Software. One wishes everyone else gave such good support.

4 August 2011

MediaTomb Server and the Humax HRD Fox T2 500 Gb

Introduction

We have bought a fancy High Definition Video Recorder which offers many additional features including the ability to access video, photo and sound files over a network. I am using MediaTomb as a server for this data. The MediaTomb for Ubuntu is set up slightly differently to the standard version and is configured to run as a Daemon which is started during the init.d sequence and runs as user mediatomb. This default gave some problems to me because I have my media files on a removable drive and:

I could not access files on the drive because of permissions when it was a NTFS volume as it was mounted with read permissions only for the current user. I could get round that by formating and mounting as a ext3 drive and setting the permissions to give read access to Others which allowed it to work in Daemon mode.

The daemon was started before the drive was mounted so it could not be found initially and the database was cleared. This needed the daemon startup to be removed from the the init.d sequence and the program started manually from a terminal or launcher. This also meant that the server was running as the same user as the one who had mounted the drives so now all drives and contents are accessible

The Humax is very choosy about the file formats it will play - it will play many formats but the number where the 'controls' to allow stepping forwards and back and pausing are strictly limited and undocumented. The good news is that all my 'captures' from my old Video8 tapes (360 Gbytes) are in one of the few formats that plays. The bad news is that all the files ready for authoring into DVDs are .vob files which will not play but I have a way of transcoding them which does not degrade the video stream which is copied unchanged into a new container with a converted audio stream - the cost is 80 Gbytes extra storage. Standard jpeg files can be put into a slide show which adds another 67 Gbytes. Audio is less important for the Humax at present but tests show that audio .mp3 files are handled perfectly and there is a sophisticated indexing allowing selections to be made.

About MediaTomb and how it is used.

MediaTomb is an open source Universal Plug and Play (UPnP) MediaServer complient with the required sections of the V 1.0 specification. A UPnP server allows one to stream digital media, usually from a local hard disk on the server, through ones home network for listening to/watching on a variety of UPnP compatible devices. Humax is advertised as being DLNA (Digital Living Network Alliance) compliant MediaRenderer (player). In practice these 'standards' are very similar so the Humax HRD Fox T2, being a DLNA complient player, ought to be able to browse, request and play audio, video and photos over a network from a UPnP server such as MediaTomb.

MediaTomb is somewhat differently to most programs - it can either be started either as a daemon running in the background when the machine is booted up or as a program started from a normal launcher or in a terminal. In both cases it is then almost 'invisible' - there is not even an icon in the status panel to show it is running. Whlst running, access is purely through the network and control is through a web interface connected to the IP address and port on which it is serving the media. Selection of the media for the database can therefore be from any machine on the network. In a similar manner 'Players' browse over the network the media which is available in the database and select what to play. In practice MediaTomb can serve far more media formats than the Humax can play. The initial configuration is almost entirely through a single options file after which you point your browser at the relevant Address and Port (usually port 49152) where you can view your local filesystem and chose which files and folder structures from which you will make selected classes of media available using a tree view of the database and the file system. The local database can updated on a regular timed basis or whenever a file or folder is added, removed or changed. The initial or timed scanning takes a significant time.

The Mediatomb Web Interface is accessed through your normal browser. You can provide the address in several ways:

  1. 192.168.2.234:49152
  2. http://computername:49152
  3. file:///.mediatomb/mediatomb.html

The first way using a standard IP address and port will change depending on the address allocated to your computer and will change everytime your router is turnered on and off. The second way uses you computer name depends on the software being enabled on your machine to resolve it. The third uses a file which is kept up-to-date by mediatomb itself so is ideal for the machine running Mediatomb.

You have two views options for the left panel - filesystem and database. You choose the folders to include in the database in filesystem view using the icons at the top of the right panel which produces a form to fill in - choose the Inotify Basic Recursive options. Then check what you have in Database view - it may take a while to complete the scan and fill it all in. I have my photo and video files on one USB drive and the audios on another.

Preventing Ubuntu 11.04 version of MediaTomb being run automatically as a daemon.

The version supplied with Ubuntu has been set to run as a Daemon and is started during the boot process automatically once it has been installed and run the first time. This may not be what you want so the first stage is to prevent the Daemon being started. The script which starts the mediatomb Daemon during the boot process is in /etc/init.d . A quick and dirty way to stop it being run is to change it from being executable by changing the permissions:

sudo chmod 0644 /etc/init.d/mediatomb

MediaTomb Configuration files

The MediaTomb runs in slightly different ways and has the configuration files in a different place depending on whether it is run as a Daemon during system bootup or has been run by a user.

It is now time to make some changes in the configuration file which is ~/.mediatomb/config.xml when run by a user.

gedit ~/.mediatomb/config.xml

All the important changes are at the top of the file and are in red below:

<?xml version="1.0" encoding="UTF-8"?>
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
<!--
Read /usr/share/doc/mediatomb-common/README.gz section 6 for more
information on creating and using config.xml configration files.
-->
<server>
<ui enabled="yes" show-tooltips="yes">
<accounts enabled="no" session-timeout="30">
<account user="mediatomb" password="mediatomb"/>
</accounts>
</ui>
<name>Matrix</name>
<port>49152</port>
<udn>uuid:b4669fad-3f8e-4d30-94a7-fec9bb4395e9</udn>
<home>/home/pcurtis/.mediatomb</home>
<webroot>/usr/share/mediatomb/web</webroot>
<storage>
<sqlite3 enabled="yes">
<database-file>mediatomb.db</database-file>
</sqlite3>
<mysql enabled="no">
<host>localhost</host>
<username>mediatomb</username>
<database>mediatomb</database>
</mysql>
</storage>
.........

  1. The first change is to enable the user interface via the web - it was not enabled on my version by default.
  2. The second change is optional and just changes the name of the server which is seen from the clients.
  3. The third line is an addition and fixes the port used to be 49152 rather than the first available starting at 49152 - this also prevent multiple copies on increasing ports. This will need to be different if you have servers on several machines

The choice of database is set to sqlite3 by default - this is the best option but note you need to have sqlite3 installed so check using the Synaptic Package Manager and install the sqlite3 package if required.

Using media on a USB drive in MediaTomb.

USB drives are normally mounted late in the booting process and after the user has logged in. They are mounted by the file manager - Nautilus in Ubuntu and Thunar in Xubuntu and the permissions only allow access by the user who was first logged in. This gives two problems when a Daemon is started during boot process - firstly the drive is not mounted by the time Mediatomb has been started and the database is first accessed and is then cleared. Secondly Mediatomb is run in the mediatomb group and drives mounted this way do not have the permissions for the mediatomb daemon to access them.

Auto-mounting a USB hard drive during system boot.The first approach I tried was to make an entry in the filesystem table for the USB drive in the same way that a fixed drive can have an entry. I have covered this for fixed drives in Ubuntu All Together - Sharing, Networking, Backup, Synchronisation and Encryption under Permanently Mounting a shared file-system - use of fstab (Advanced). The trick in this case is to make sure the mounting uses the UUID (Universal Unique IDentifier) which every disk has in the file system table /etc/fstab.

This worked well for me on Ubuntu 10.04 and 11.04 and I could get an early mount with the correct permissions for MediaTomb to run at startup in daemon mode however there are some serious disadvantages. One Must have the USB drive plugged in or the boot-up needs intervention to continue when the drive is not found and even if you then plug it in it will not mount through nautilus (only checked in U10.04) although it is still possible to mount it through the mount command in a terminal. I also discovered to my surprise that fstab does not like mount point folder names which have spaces even if you quote them in fstab (again only checked in U10.04). I have used 'defaults' and auto detection for the drive so my filesystem table (/etc/fstab) now looks like:

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
/dev/sdb6 / ext4 errors=remount-ro 0 1
# /home was on /dev/sdb7 during installation
UUID=a411101c-f5c6-4409-a3a1-5a66de372782 /home ext3 defaults 0 2
# swap was on /dev/sdb5 during installation
UUID=a7c16746-1424-4bf5-980e-1efdc4500454 none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
# /dev/sda5: LABEL="DATA" UUID="47859B672A5D9CD8" TYPE="ntfs"
UUID=47859B672A5D9CD8 /media/DATA ntfs nls=utf8,uid=pcurtis,gid=pcurtis,umask=0000 0 0
#
# USB Drive /dev/sdf1: LABEL="DE_MEDIA" UUID="4690477f-effa-4d60-a6f1-243cfdc7e065" TYPE="ext3"
UUID=4690477f-effa-4d60-a6f1-243cfdc7e065 /media/DE_MEDIA auto defaults 0 0

I have added information about this proceedure for USB drives into Permanently Mounting a shared file-system - use of fstab (Advanced) .

Starting Mediatomb with a delay after login is complete

The solution I have adopted is to start Mediatomb by using a script which I add to the users Startup Applications using System Applications -> Startup Applications -> Add and filling in the boxes.

The reason to use a script rather than just entering the program name is so I can add a long delay before the program is started to ensure the drive is mounted. I keep all my scripts in ~/bin and have added that folder to the PATH Environment Variable so it can be called just by name but if you do not want to modify ~/.bashrc by adding the liine PATH=$PATH:~/bin to the end you can specify the full path in the Startup Application details.

My additions to the end of ~/.bashrc so I can run scripts in ~/bin are:

.........
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# Additions to add path to ~/bin for local scripts
PATH=$PATH:~/bin

The script itself is very simple and the following can be copied into ~/bin/delayed_mediatomb using gedit.

gedit /bin/delayed_mediatomb

And paste in the following

#!/bin/bash
# Script to copy start mediatomb as a daemon after a 40 second delay.
# Lives in ~/bin/delayed_mediatomb where it must be given execute permissions
# and ~/bin should have been be added to to #PATH in ~/.bashrc
# by adding the line
# PATH=$PATH:~/bin
#
sleep 40
mediatomb -d

The file needs to be made executable

chmod 777 /bin/delayed_mediatomb

Now when I start the machine mediatomb is started and all my settings are preserved as the USB drives which contain the media files are alredy mounted.

More about Media Streams/Files

Media files are very large so that it is impossible or impractical to transfer them in their entirety between machines before playing them. The information is therefore requested as required and streamed from the server to the player. Depending on the server/player and type of file/stream it may, in order of complexity, be possible to pause, step forwards and backwards or fast forwards and back. Again, as a generalisation, it is easier to control a local file than one provided from a server. Most video media contains a number of streams, the audio, the video and sometimes other streams with, for example, subtitles or alternative audio streams. Almost all media is heavily compressed and there are many alternative formats for the audio and video streams in the same way that pictures may be in jpeg, png gif, etc formats. Within, say a video format, there are a huge number of options - some obvious like the size 720x578 or 1920x1080, the frame rate and whether the stream is interlaced. Others are more complex such as average, maximum and minimum bandwidths when variable bandwidth encoding is used and some which a normal person has great difficulty in understanding at all. If you want to get an idea of the complexity of the modern standards have a look at http://en.wikipedia.org/wiki/H264 for the latest video format H264. Again there are different audio formats and parameters for the streams, Dolby, Stereo, MP3, OGG etc with variable and fixed bandwidths. The audio and the video streams are not, of course, independent and need to be played in synchronisation so they are in a container - what you normally see is just a container such as AVI, MPG, TS, VOB. Startup Applications

Converting between Audio and Video Formats

There are many options for file convertors, some are gui based and are often part of a video player such as VLC but the best way is often to call the underlying conversion programs which usually means use of a terminal. perhaps the best of all is ffmpeg which many other programs use. This is what I have been using to convert VOB (.vob) files (containers) to MPG files (containers with extension .mpg) and whlst changing the format of the audio stream but leaving the video untouched as any changes seemed to lead to a stuttering video playback.

ffmpeg -i "/media/WD400EXT3/VOB Files for Authoring/The Thorn Birds Volume 4.vob" -f mpeg -vcodec copy -acodec mp2 -ab 384k -ar 48000 "/media/WD400EXT3/VHS Copies for Humax/The Thorn Birds Volume 4.mpg"
This is actually a very simple example! The input parameters for the file are automatically detected from the input file specified by -i filename and normally the container or output format is specified by the extension of the output file, in this case .mpg. In this case the output'container' is also forced by the -f mpeg parameter. The video codec is set by -vcodec copy to a straight copy and the audio codec by -acodec mp2 The audio sample rate is set by -ar 48000 and the badwidth by ab 384k .

The important bit of the output follows:

....................
Input #0, mpeg, from '/media/WD400EXT3/VOB Files for Authoring/The Thorn Birds Volume 4.vob':
Duration: 02:21:05.53, start: 0.500000, bitrate: 3273 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 6000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, mpeg, to '/media/WD400EXT3/VHS Copies for Humax/The Thorn Birds Volume 4.mpg':
Metadata:
encoder : Lavf52.64.2
Stream #0.0: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], q=2-31, 6000 kb/s, 90k tbn, 25 tbc
Stream #0.1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
...................................

Transcoding in MediaTomb

MediaTomb can transcode on the fly but I have not yet made it work satisfactorily.

....
<mappings>
<extension-mimetype ignore-unknown="no">
<map from="vob" to="video/mpeg"/>
<map from="mp3" to="audio/mpeg"/>
....
....
<transcoding enabled="no">
<mimetype-profile-mappings>
<transcode mimetype="video/mpeg" using="ffmpegcopy"/>
<transcode mimetype="video/x-flv" using="vlcmpeg"/>
<transcode mimetype="application/ogg" using="vlcmpeg"/>
<transcode mimetype="application/ogg" using="oggflac2raw"/>
<transcode mimetype="audio/x-flac" using="oggflac2raw"/>
</mimetype-profile-mappings>
<profiles>
<profile name="oggflac2raw" enabled="no" type="external">
<mimetype>audio/L16</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>no</accept-ogg-theora>
<agent command="ogg123" arguments="-d raw -o byteorder:big -f %out %in"/>
<buffer size="1048576" chunk-size="131072" fill-size="262144"/>
</profile>
<profile name="vlcmpeg" enabled="no" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
<buffer size="14400000" chunk-size="512000" fill-size="120000"/>
</profile>
<profile name="ffmpegcopy" enabled="no" type="external">
<mimetype>video/mpeg</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<agent command="ffmpeg" arguments=" -i %in -f mpeg -acodec mp2 -ab 384k -ar 48000 -y -vcodec copy %out"/>
<buffer size="576000000" chunk-size="1024000" fill-size="240000"/>

</profile>
</profiles>
</transcoding>

The transcoding can be seen to start when mediatomb is run in a terminal and a mpeg or vob file accessed but fails shortly into ffmpeg

djmount - a UPnP Client for Linux which mounts as a FUSE File system

I have had difficulty in identifying a client for UPnP for Linux. The best seems to be a very old utility called djmount which mounts as a Linux filesystem (using FUSE (File System in User Space)) the media content of compatible UPnP AV devices. The Audio and Video content on the network is automatically discovered, and can be browsed as a standard directory tree.It is available through the Ubuntu Software Center or Synaptic and needs the FUSE utilities to be installed. Mine seemed to be installed by default on 10.04 and 11.04 but check. You need to run in a terminal and to specify a mount point which needs to be set up with permissions to access for all users. I created a new folder /media/UPNP_APV and set up the permissions. This is best done in a terminal.

sudo mkdir /media/UPNP_APV
sudo chmod 777 /media/UPNP_APV

I could then mount the UPnP server by

djmount /media/UPNP_APV

The server should now be visible in /media/UPNP_AVP and as we are in a terminal it is worth checking:

xxxx@xxxx:~$ ls -l /media/UPNP_APV
total 1
-r--r--r-- 1 root root 7 2000-01-01 11:00 devices
dr-xr-xr-x 7 root root 512 2000-01-01 11:00 Triton
xxxx@xxxx:~$:~$ ls -l /media/UPNP_APV/Triton
total 2
dr-xr-xr-x 9 root root 512 2000-01-01 11:00 Audio
dr-xr-xr-x 4 root root 512 2000-01-01 11:00 PC Directory
dr-xr-xr-x 7 root root 512 2000-01-01 11:00 Photos
dr-xr-xr-x 5 root root 512 2000-01-01 11:00 Video
xxxx@xxxx:~$

We can see the server called Triton is mounted and the standard folders from MediaTomb are below it and have sensible permissions.

It should be possible to add the program to the autostart list but it might need a delay as for mediatomb

9 August 2011

Xubuntu 11.04 on the Toshiba Portege 3440 laptop

I still have a 1998 Toshiba Portege 3440 laptop, a very fine machine in its day which we obtained from Christine in NZ when it became time expired with Windows. It started life with Windows 98SE nad then gained its maximum memory (192Mbytes) and a 30 Gbyte hard drive when it was converted to Windows XP Pro. I used it for several years and in 2006 it was dual booted with Ubuntu Dapper Drake 6.06 and was finally relegated to playing media into our hifi. It has now run out of updates for 6.06 and the automatic upgrade did not work so I looked for a version of Ubuntu which I could load into 192 Mbytes off an alternate CD even if it was incapable of running a LiveCD. Xubuntu seemed the logical choice. So I downloaded an iso of the alternate CD.

The Portege 3440 does not have a built in CD drive but I have the additional bus extender with a CD, extra USB 1.1 port, VGA output and parallel port so I set off with the alternate CD. It died part way through just after it had detected all the devices and complained it could no longer find the CD. After a bit of head scratching I decided to add an USB CD/DVD drive through a powered USB 2 PCMCIA card and although it could not boot from it I found that when I got to the point where it lost the bus extender CD drive I could move the CD across to the USB drive it had just detected and carry on - a big sigh of relief as by then I had no way back.

It is a bit slow with Xubuntu but quite usuable for what I want despite only being a 400 Mhz machine with 192 Mbytes of memory. Whilst I was 'exploring' I had one panic as the upper and lower toolbars completely disappeared and did not return on a reboot. I tried a new user then loaded gnome panel whilst I was looking for a solution which made it very like the standard See Tip below on running gnome-panel for a session. If you want to run it for longer then you can add it to the startup programs. Ubuntu and I eventually found that if I deleted ~/.xfce4 completely it was forced to reconfigure Xubuntu from scratch and everything returned. I rather like Xubuntu - it is a much better interface than Unity and offers a slightly bigger screen area.

I uninstalled gnome-panel and also removed all its dependencies - there is an apt-get incantation which I must look for which came up as an option when I uninstalled gnome-panel. I have loaded gedit and nautilus as all my terminal strings on the web site depend on them. I also stopped as many of the start up programs as I dared to cut down memory use. I have installed rhythmbox 12.1 as a player which brought in quite a lot of dependencies and also the standard gstreamer plugins so I can play mp3s. I have not documented everything as much as I should have so I need some backfilling before I ever repeat it.

The Portege does not have an Ethernet port, Wifi and only a single USB1.1 conection so I have a powered PCMCIA card providing two USB 2 ports and a Firewire port. This allows me to connect a 120 Gbyte WD Passport portable drive and a USB Wifi dongle which is an Edimax EW7711UAn high gain 802.11n 150 Mhz adaptor with a little built-in antenna which can be adjusted - £10.99 from 7dayshop.com.

One thing I have done to help with the lack of memory is to try to reduce the use of the swap file as I can hear there are a lot of disk transfers. There is a parameter called swapiness which is normally reduced on netbooks using solid state memory which wears out faster than a hard drive! See Performance tuning with ''swappiness'' Swappiness controls the tendency of the kernel to move processes out of physical memory and on to the swap disk. As disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory and wear on solid state disks.

Reducing the default value of swappiness will actually improve overall performance for a typical Ubuntu desktop installation. There is a consensus that a value of swappiness=10 is recommended for a desktop and 60 for a server.

To check the swappiness value

cat /proc/sys/vm/swappiness
For a temporary change (lost on reboot) with a swappiness value of 10:

sudo sysctl vm.swappiness=10

To make a change permanent you must edit a configuration file:

sudo gedit /etc/sysctl.conf

Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:

vm.swappiness=10

Save the file and reboot.

At present the system grinds to a halt with 30 second breaks in the music if I run Firefox and Rhythbox together - I will try various values 25 seems about right.

Tricks when running programs from the command line eg gnome-panel

If you just open a shell and run a command, then the program or process is "owned" by that shell. When you kill a parent process ( the shell), all of its children are killed too.

What you need to do is type:

gnome-panel &
disown %gnome-panel

The & starts the panel as a background process (letting you still type at the terminal), and the disown command separates (disowns) the panel process from the terminal, so that when you close the terminal, you don't lose the panel. This is also useful when you run gedit or nautilus. Beware - if you exit the terminal before disowning or closing a copy of gedit you may get no warning about unsaved content when you close the terminal.

nautilus &
disown %nautilus

Firefox and Thunderbird Extension Updates to Version 6

Firefox and Thunderbird have gone onto a regular version update calendar which means that every extension has to be updated every few months. If the extension is not updated to include the new version in the range of versions under which it will run it will be disabled. It seems that the changes this time are minor and may not effect most extensions. There are two ways round this problem:

Edit a file in the .xpi archive before you load it. I covered that in my Diary part 19 but the folowing is much simpler.

Add a new extension which enables you to run the extensions. This is intended for testing and reporting but gives a short term solution until the extensions are updated. To quote: "After installing the Add-on Compatibility Reporter, your incompatible extensions will become enabled for you to test whether they still work with the version of Firefox or Thunderbird that you're using. If you notice that one of your add-ons doesn't seem to be working the same way it did in previous versions of the application, just open the Add-ons Manager and click Compatibility next to that add-on to send a report to Mozilla." This is a slightly risky solution so make sure you back up your profile first. If it all goes pear shaped you can start Firefox/Thunderbird in Safe Mode to disable everything again by using a terminal command:

firefox -safe-mode
thunderbird -safe-mode

Search for "Add-on Compatibility Reporter" and install as usual from Tools -> Add-ons -> Drop down list to left of the search box after you have downloaded it. It is the same for Firefox and Thunderbird.

Clearing the Rhythmbox Library

I have been moving my music library from one drive to another and onto the djmount and I have noticed that there isn't any clear way to change library locations once you have set them - you still have all the old locations in your music library as well as the new ones.

Deleting the file ~/.local/share/rhythmbox/rhythmdb.xml should just remove the music database and when you reopen Rhythbox it should rescan the new location.

rm ~/.local/share/rhythmbox/rhythmdb.xml

The remainder of the configuration can be cleared by removing these folders - they will be replaced next time Rythmbox is started:

~/.local/share/rhythmbox
~/.cache/rhythmbox
~/.gconf/apps/rhythmbox.

by:

rm ~/.local/share/rhythmbox/ ~/.cache/rhythmbox/ ~/.gconf/apps/rhythmbox/ -r

Clearing the Gmusicbrowser Library

I have had the same trouble with Gmusicbrowser as Rhythmbox when moving my music library from one drive to another and onto the djmount and I have noticed that there isn't any clear way to change library locations once you have set them - you still have all the old locations in your music library as well as the new ones.

The Music database and other settings are held in ~/.config/gmusicbrowser. If you delete this folder all the settings should be restored to that of a fresh install when you restart. The database file is called gmbrc and it may be possible to just edit (delete all the lines in the section called [songs] and retain your settings. But the simple way is to completely halt gmusicbrowser and:

rm ~/.config/gmusicbrowser

 

Secure access to a Remote File System using SSH and SSHFS (Advanced)

SSHFS (SSH File System) uses SSH to mounting a remote filesystem on a local machine. SSHFS uses FUSE (Filesystem in Userspace) which is included in Ubuntu and authenticates connections so only those who are authorised can mount them. SSH connections are encrypted, no one can see your files as they are transferred over the network and once mounted the FUSE filesystem is owned by the user that created it and other users on the local machine can not access them.

Firstly we must install sshfs using the Synaptic Package Manager by System -> Administration -> Synaptic Pacakage Manager -> Search for sshfs, Rigtht Click and Mark for Installation -> Apply.

Secondly add yourself to the fuse group by System -> Administration -> Users and Groups -> select user -> Properties -> User Privileges, then tick the following option:

Allow use of fuse filesystems ...

Once you have added yourself to the fuse group, you need to either log out and log back in again or reboot for the change to take effect.

There is a risk that your ssh session will automatically log out if it is idle. To keep the connection active add the following parameter to ~/.ssh/config or to /etc/ssh/ssh_config on the client.

ServerAliveInterval 15

This will send a "keep alive" signal to the server every 15 seconds.

Using sshfs in a Terminal

A local mount point must exist and have permissions set for you to use it before you connect. If you have it in your home directory you can use the file manager to create the new directory which will have the correct permissions.

Assuming that you have ssh installed and the server running on the remote machine you now just need to run the sshfs command to mount the remote directory. In a terminal type:

sshfs -o idmap=user username@remotemachine:/remotefolder ~/localfolder

The idmap=user option ensures that files owned by the remote user are owned by the local user. If you don't use idmap=user, files in the mounted directory might appear to be owned by a different user.

You can not unmount a FUSE file system mounted this way in a terminal using eject or unmount from a right click or nautilus; To unmount you again have to use the terminal and do:

fusermount -u ~/localfolder

Using ‘Connect to Server’ in the Nautilus file browser with the SSH option

An Alternative way to mount a secure remote file system is to open the Nautilus file browser then File -> Connect to Server and select SSH from the drop down menu. Fill in the server name and other parameters as required. This way will give you a mount on the desktop and you can unmount by a right click -> Unmount Volume. You still need SSH on both machines and the fix to the Hostname resolution problem using winbind covered above. I am not sure if you also need the keep alive signals as I already had the fix in place.

If this fails with a timeout error try deleting or renaming ~/.ssh/known_hosts - you will get a message saying that it is a new host you are connecting to and everything will then work. It seems to be caused by the IP address changing for the remote hostname and you not getting the warning message.

Using Places menu

This is very similar to the above but is accessed by Places -> Connect to Server and filling in as above. Nautilus is then opened. It seems less reliable than accessing the connection Window from in Nautilus under one of my machine with Hardy Heron whilst it works fine under Jaunty.

Conclusion

I discovered this way of working much later than Networking using samba. It has many advantages once the basics have been set up as it is a much more secure solution especially over Wifi as snooping is impossible with an encrypted connection. However you still need to have a strong password to prevent a remote login. I plan to bring it up in this document once I have more experience.

Using Public Key Authentication with ssh and sshfs to avoid password requests

It is often inconvenient to have to provide a password when one logs into a remote machine using ssh and impossible if you are automatically mounting a file system at login. The way round this is to use public/private key authentication instead. The key is encrypted and passed between the machines but there is obviously a slight security implication as anyone who gains access to one machine has access to the other. There is a good introducttion to ssh at http://kimmo.suominen.com/docs/ssh/ which covers this.

The following proceedure allows one to set up access via a public/private key pair between two machines running OpenSSH. You should first check that you can log in to the remote machine and are authenticated on it. When running ssh-keygen you will be prompted for a file name and a passphrase. Simply hit the return key to accept the default file name, and enter no passphrase at this time - you can and should enter one a latter stage to improve security. scp is a command for a secure copy using ssh which is part of the ssh package. The command examples below need to be edited to use your own machines and usernames. It assumes you are logged in as username1 on host1 and want remote access to username2 on host2. Run the following commands in a terminal.

cd .ssh
ssh-keygen -t dsa
scp id_dsa.pub username2@host2:/home/username2/.ssh/host1_username1_id_dsa.pub
ssh username2@host2:
cd .ssh
cat host1_username1_id_dsa.pub >> authorized_keys

You should find that you no longer have to provide a password when using ssh sshfs scp etc. If it ever stops working try ssh in terminal as it is possible the ip addresses have changed and you need to reset things by deleting ~/.ssh/known_hosts and doing a new ssh login. This gets tedious after a few IP address changes (due to DCHP) and I am mindfull to try the following change to configure the secure shell (ssh) on the local machine not to check the IP. You find the ssh configuration file in /etc/ssh/ssh_config and the section to change is:

####### CheckHostIP
#
# If this flag is set to "yes", ssh will additionally check the
# host ip address in the known_hosts file. This allows ssh to
# detect if a host key changed due to DNS spoofing. If the option is
# set to "no", the check will not be executed.
#
CheckHostIP no

Scripts to Mount and Unmount the Media on Matrix using sshfs

I have written two scripts to mount and unmount the media. The mounting script has delays to ensure that the Wifi is up when it is added to the startup program list activated at login. Both scripts check whether the file system was already mounted and has been successfully unmounted and put up alert boxes.

#!/bin/bash
# Script to mount server on matrix ~/mediamount using sshfs.
# Assumes that password is not needed.
# Assumes that local mount point has been set up and has correct permissions
# Lives in ~/bin/sshfs_mediamount where it must be given execute permissions
# and ~/bin should have been be added to to #PATH in ~/.bashrc
# by adding the line
# PATH=$PATH:~/bin
#
# Check if Media Folder already has contents
if [ "$(ls -A ~/mediamount)" ]; then
  zenity --info --text "Media Folder was already available for Media Players to use"
else
# Allow time for Wifi to come up when script automatically run at login
  sleep 20;
  sshfs -o idmap=user pcurtis@matrix:/media/DE_MEDIA ~/mediamount;
# Check mediamount folder now has contents
  if [ "$(ls -A ~/mediamount)" ]; then
    zenity --info --text "Media Folder has been successfully Mounted for Media Players to use"
  else
    zenity --warning --text "Media Folder mounting failed - is Matrix turned on? If not turn on and try again using the Desktop Icon";
  fi
fi

#!/bin/bash
# Script to unmount ~/mediamount
# Lives in ~/bin/unmount_localmedia where it must be given execute permissions
# and ~/bin should have been be added to to #PATH in ~/.bashrc
# by adding the line
# PATH=$PATH:~/bin
fusermount -u ~/mediamount
# Confirm folder is now empty
if [ "$(ls -A ~/mediamount)" ]; then
  zenity --warning --text "Media Folder Un-mounting failed - is it in use?"
else
  zenity --info --text "Media Folder has been successfully Un-mounted"
fi

Drivers for 3Com PCMCIA Wifi Card for Portege

The Wifi card no longer worked with any version of Ubuntu 11.04 until I installed the extra drivers for nonfree firmware linux-firmware-nonfree - This is mostly firmware for TV cards but also it seems the Wifi firmware for some Wifi cards including my 3Com.

Xubuntu

I have done a complete fresh install of Xubuntu 11.04 on my old Dell Dimension XPS 700R including reformating to ext4. I have added gedit and nautilus and may use it to try out options such as dockbarx to give an alternative to Ubuntu Unity. I also tried Lubuntu 11.04 from a LiveCD but am less impressed.

13 September 2011

Popups updates to epopup.js

Some brief notes for me! I have had a general tidy up of epopup.js to make sure it works with more of the current browsers especially Chrome.

I have had to move some of the variable declarations so they are 'global' and I have changed the checking for specific browsers to be 'global' rather than in popup5().

Chrome needs to have a fix involving blurring and focusing the window. Some redundant window.focus lines had to be taken out.

I have also taken out the check for browsers latter than version 3 as a surrogate for javascript 1.2 as some new browsers are lower versions and other will soon be in double digits whilst all take 1.2. Check now uses existance of the window.resizeTo method to check for JavaScript 1.2 or higher and a similar check has been included before calling the method in popup5(). See http://www.quirksmode.org/js/support.html

Also Firefox now allows the window to be brought into focus after resizing so firefox fudge removed (which closed and reopened the window) giving a much better experience.

Opera has a preference setting which, currently by default, prevents any popups being brought back into focus and this needs to be changed if you plan to spend much time on my pages. You reach it by clicking the Opera Button the Settings -> Preferences -> Advanced -> Content -> JavaScript Options and tick Allow raising of Windows.

Also checked in Microshaft IE8 (OK). Windows version of Safari (OK), Midori and Epiphany

Have added location=no to window.open preferences.

Check on screen.height to set initial value of broadband flag

17th September 2011

Popups again

The basic code above for the five parameter popup popitup5() formed the basis of all the popups on my web sites for a couple of years with the only significant development being in the way It was used. The code was put in an include file (.js) at the top of every page which had images.  The HTML has the following line in the head statement

<script src="epopup.js" language="JavaScript1.2" type="text/javascript"></script>

Note that I specified a relatively old version of JavaScript so almost every browser will work but one which is new enough to provide a couple of features I use for resizing a window, I now include extra .

The file also gained a script added to write a standard browser check into the web page and a script to make it easier to create the calling routines by writing them using only three parameters when I was using my standard size images.

The next major change came when we switched to digital cameras in 2004. The pictures now had the same aspect ratio as the video camera and also digital processing of the images became the norm. I developed code which allows the user to specify from two possible sizes of popup depending on bandwidth of his internet connection and screen size. The size can be toggles by a function call either from a link or by double clicking on any of the images and uses a cookie to maintain the choice throughout the browser session . The write up of our Australian trip in 2004 was the first example. Having all the code and 'scripts' to write the calling routines into the HTML pages in an 'include file'makes it very easy to make changes if required - for example the Firefox browser needs a title parameter as well as an alt parameter to allow text to be displayed when one hovers over an image and that change could be made for most of my pages by only a minor modification in the .js file. The downside of using 'java scripts' to write the complex calling routines into the HTML pages is that visitors who turn JavaScript off will not even see the small pictures (icons) on the pages so an addition warning if this is put in the HTML Body at the top of the page.

<noscript>
<p<font size="+1" color="#FF0000"><b>Caution:</b> You will not be able to see any images unless you enable Java on your Browser. </font></p>
</noscript>

Popup windows are extensively used on the site for the images on our travel pages. The popups for pictures are an essential part of the travelogues and a lot of thought has gone into their design. The objective is to enable the reader to be able to read the text with small 'icons' illustrating the places which are either at the left or right end of the paragraphs or in blocks of 3 or 4 pictures between paragraphs depending on the density of the illustrations. The optimum size seems to be about 160x120 pixels.

It is worth reviewing the requirements for the pop-up function namely it should:

The above covers the basic access to popups which is used on a number of my web pages, especially the technical pages where the popups are of screen shots which are of very different sizes and sometimes just have a link rather than an icon to click. I have been surprised to find how few, if any, popup windows one finds on commercial web sites achieve all the important first five requirements

The travel pages are rather more specific in there use of popup images - here I have standardised on a 4:3 image ratio which matches my digital camera and video camera grabs and I can then offer two image sizes depending on the screen size and bandwidth one has available. Every picture exists as a set of three .jpg images 160x120 400x300 and 600x450 or the vertical equivalent in a fixed format (imagexxxi.jpg, imagexxxw.jpg and imagexxxb.jpg). The image size is currently chosen depending on the height of the users screen but this may be changed to a combination now tablets are increasingly common. Links are provided to switch sizes at the start of the introduction page for each journey and the size can also be toggled by double clicking although the change seems to be delayed to the next popup as the browsers seem to see the first click of the double click to display and then the double click to toggle.

Each travel page which has popups has code/scripts to:

Popup Behavior in different common Browsers

The Popups for pictures on www.pcurtis.com and www.uniquelynz.com work well with most recent versions of the mainstream browsers, Mozilla Firefox, Microsoft Internet Explorer, Google Chrome, Safari and Opera. That is all the desktop browsers with more than 2% market share (September 2011). http://en.wikipedia.org/wiki/Usage_share_of_web_browsers . There are however various factors which can still cause problems.

 

Popups are abused by many advertisers and most browsers offer preference settings, extensions or other ways ways to limit the abuse of popups. The same goes for various security suites. In general the default settings should not inhibit popups which follow all the rules properly although you may find that you are asked if will permit use of popups on my sites and it is safe and desirable to say yes.

Most of the browsers these days have a tabbed display rather than a series of separate windows. The best source of information on forcing window versus tab behavior is at http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab I have not tried the _blank yet but I obviously use the parameter strings in all the advanced popups.

I have been looking at some some of the less common 'lightweight' browsers under Linux on my legacy machines and find some open a popup window in a tab instead of a correctly sized window. This is much more difficult to use and has the associated problem that the reuse of a window incorrectly displayed as a tab may not work correctly and they may not be closed when the page is left. This also makes them difficult to use with many other sites such as banking sites or anywhere that help information is displayed in a popup window. Midori and Epiphany are examples of browsers which do not handle popups in the way one would expect. Both are based on WebKit code.

Chrome uses Webkit code but handles popups fine although it has a number of idiosyncrasies including failing to bring a popup back into focus (ie displayed in front of the main page) - this meant I have included a dedicated 'fudge' in the popup code for Chrome as it now has over 20% of the browser 'market'. Thanks to Tony forputting me on to this problem and providing the solution below.

// Add test for Chrome at top with other variables
var is_chrome=navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

// Add before final newwindow.focus();
if (is_chrome) {newwindow.parent.blur();}

Your browser is identified as having userAgent " " - you can see this is quite complex and one has to be careful in selecting a suitable string to test.

Firefox 4 also initially tended to lose focus but updated version 4s and versions 5 and higher now handle focus correctly so an earlier 'fudge' I had to implement of closing and reopening has been removed as it had other undesirable side effects - it is best to updated if you have any ananomolies.

Opera has a couple of minor anomolies - the popup windows are displayed the correct size and are also attached to there own tab which is opened and closed in tandem with the windows - this is a good compromise between tabs and windows. However Opera has a preference setting which, currently by default, prevents any popups being brought back into focus and this needs to be changed if you plan to spend much time on my pages. You reach it by clicking the Opera Button then Settings -> Preferences -> Advanced -> Content -> JavaScript Options and tick Allow raising of Windows. You can in any case bring the popup window into focus from its tab or the operating system toolbar although this can be tedious if you have a system with a 'dock' such as Ubuntu Unity. I have also noticed that closing Opera does not always close down the tabs with associated popups - see http://www.quirksmode.org/dom/events/index.html for support of events including onUnload for possible cause of Opera shortfall. Even this would not be a problem - it could even be called a feature if the picture was reloaded - unfortunately the parent page is loaded and it all looks very confusing.

Some examples and a test area of the popups

Firstly I will display the major attributes of navigator object for your browser so you know what you are testing:

The next paragraph starts with my 'standard' browser checks to confirm that JavaScript is enabled and Cookies are enabled - you should only see anything if you turn them off during your tests. Following that is the explanatory text which is copied into every introductory page followed by a few randomly selected pictures from our travels so you can try everything out.

Caution: You will not be able to click to see large images unless you enable Java on your Browser.

All the pictures on the pages provide details of where they were taken if you hover the cursor over them and they can all be clicked to open a larger version in a popup window. The popup windows are reused and then closed up when you leave the page so you do not need to close them. Our digital pictures (from 2004) are in two resolutions and the initial size depends on your screen size. You can chose the small size if you have a slow internet connection or want to restrict data flow on a mobile connection. Click here for high detail popup images and click here for lower resolution images. You can also toggle the resolution by double-clicking an image but it may take an extra click to display the picture in the new size on some browsers. With some systems you may be asked to if you wish to allow popup windows as a protection against adverts. More

 

Finally the actual JavaScript Code I am using in epopup.js to produce the above

Contents of my current include file epopup.js as of 16th September 2011

// Browser check function to write warnings into the web page when placed within a <script type="text/javascript"> tag

function browser_caution() {
var browser = navigator.appName;
var version = navigator.appVersion;
// Check JavaScript supports resizing of windows - version 1.2 or higher
if (!window.resizeTo) { document.write('<font size="+1" color="#FF0000"><b>Caution:<\/b> You are running a browser identifying itself as ' + browser + ' version ' + version + ' which does not seem to support the JavaScript which would provide the Popup images when you click on the thumbnails on this page.</font><p>') }
}

// Routine for popup windows with title, size and background colour parameter (5 parameters)

var newwindow;
var wheight = 0, wwidth = 0;

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
// var is_epiphany = navigator.userAgent.toLowerCase().indexOf('epiphany') > -1;
// var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

function popitup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+30;
pheight=iheight+30;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=yes,top=50,left=10,status=no,location=no');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+30;
pheight=iheight+70;
// The resizeTo needs Javascript 1.2 or higher so the include for this javascript file should specify language="JavaScript1.2"
if (window.resizeTo) newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.document.writeln('<html> <head> <title>' + title + ' <\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();

if (is_chrome) {newwindow.parent.blur();}

newwindow.focus();
}

//Routines used specifically for popup feedback form windows

var fbwindow
function fbpopitup(url) {
if (fbwindow && !fbwindow.closed)
{ fbwindow.location.href = url; fbwindow.focus(); }
else
{ fbwindow=window.open(url,'fhtmlname','width=520,height=420,resizable=1,scrollbars=1,top=50,left=10'); }
}

//Routines to tidy up popup windows when page is left

function tidy() {tidy5() }
function tidy5() {
tidyh();
fbtidy();
}

function tidyh() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

function fbtidy(){
if (fbwindow && !fbwindow.closed) {fbwindow.close(); } }

//routines to simulate functions used on older pages.

function popitup(url) { popitup5(url , 'Digital Image 384x288', 384, 288, 'white') }
function ppopitup(url) { popitup5(url , 'Photographic Image 400x267',400, 267, 'white') }

function vpopitup(url) { popitup5(url , 'Digital Image 288x384', 288,384, 'white') }
function pvpopitup(url) { popitup5(url , 'Photographic Image 267x400', 267, 400, 'white') }

//Routines for cookies used to remember if user has broadband and large screen

/* Call function as setCookie("cookiename" , cookievalue, lifetime, cookiepath)
with the lifetime required in days, -1 to delete a cookie or zero
for a temporary cookie. The Cookie Path is optional.*/

function setCookie(cookie_name, cookie_value, cookie_life, cookie_path) {
var today = new Date()
var expiry = new Date(today.getTime() + cookie_life * 24*60*60*1000)
if (cookie_value != null && cookie_value != ""){
var cookie_string =cookie_name + "=" + escape(cookie_value)
if(cookie_life){ cookie_string += "; expires=" + expiry.toGMTString()}
if(cookie_path){ cookie_string += "; path=" + cookie_path}
document.cookie = cookie_string
}
} // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->

/* Call function as getCookie("cookiename") It returns the value of a cookie
if set or null. Beware of potential ambiguities in names of cookies -
getCookie is simple and will match the end of a string so xyname
will also be matched by yname and ame. */

function getCookie(name) {
var index = document.cookie.indexOf(name + "=")
if (index == -1) { return "undefined"}
index = document.cookie.indexOf("=", index) + 1
var end_string = document.cookie.indexOf(";", index)
if (end_string == -1) { end_string = document.cookie.length }
return unescape(document.cookie.substring(index, end_string))
} // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->

// Set broadband true provided the screen resolution is sufficient for the larger popups

var default_broadband = "true"
if (screen.height < 720 ) {default_broadband = "false"}
var cookie_time=0

// Functions to set and clear broadband

function set_broadband(){
setCookie('broadband',"true",cookie_time,"/")
}

function clear_broadband(){
setCookie('broadband',"false",cookie_time,"/")
}

// Function to toggle flag for broadband users

function toggle(){
if (getCookie('broadband') == "undefined") { setCookie('broadband',default_broadband,cookie_time,"/"); }
if (getCookie('broadband') != "true") {
setCookie('broadband',"true",cookie_time,"/");
}
else {
setCookie('broadband',"false",cookie_time,"/");
}
}

// Functions called for vertical and horizontal popups of two different sizes (image files end in i.jpg for icon, w.jpg for small image (400*300) and b.jpg for large images (600x450)

function popitup2v(url,title) {
if (getCookie('broadband') == "undefined") { setCookie('broadband',default_broadband,cookie_time,"/"); }
if ( getCookie('broadband') == "true") {url=url+'b.jpg';popitup5(url , title, 450, 600, 'white') }
else {url=url+'w.jpg'; popitup5( url , title, 300, 400, 'white')
} }

function popitup2h(url,title) {
if (getCookie('broadband') == "undefined") { setCookie('broadband',default_broadband,cookie_time,"/"); }
if ( getCookie('broadband') == "true") {url=url+'b.jpg';popitup5(url , title, 600, 450, 'white') }
else { url=url+'w.jpg'; popitup5( url, title, 400, 300, 'white')
}}
/*
Functions to put in the HTML to provide simplified calls for vertical and horizontal popups with a doubleClick event handler calling toggle() so that large popups can be displayed if user has broadband

<IMG src= "imagei.jpg" alt="title" title="title" width = "160" height = "120" border = "0" align="left" hspace = 10 vspace = 10 onDblClick="toggle()" onClick="popitup2h('image' , 'title')" </IMG>

*/

function hpop(image, title, alignment) {
document.write('<IMG src= \"' +image + 'i.jpg\" alt=\"' + title + '\" title=\"' + title + '\" width = 160 height = 120 border = 0 align=\"' + alignment + '\" hspace = 10 vspace = 10 onDblClick=\"toggle()\" onClick=\"popitup2h(\' '+ image+'\' ,\' ' + title+ ' \' )\" <\/IMG>') }

function vpop(image, title, alignment) {
document.write('<IMG src= \"' +image + 'i.jpg\" alt=\"' + title + '\" title=\"' + title + '\" width = 120 height = 160 border = 0 align=\"' + alignment + '\" hspace = 10 vspace = 10 onDblClick=\"toggle()\" onClick=\"popitup2v(\''+ image+ '\' ,\' ' + title+ ' \' )\" <\/IMG>') }

/*

Some experimental functions follow in my file and other functions not to do with popups which are not included here

*/

Valid HTML 4.01 Copyright © Peter & Pauline Curtis
Content revised: 2nd August, 2020