Fixing USB mouse or laptop touchpad freeze and hanging in Ubuntu

After upgrading from Ubuntu 12.04 to 12.10, I occasionally started facing a problem with my touchpad. All of a sudden the left and right clicks would stop working. Left click only worked on the unity panel (on the left) and the top Ubuntu menu bar (which contains the clock, network and sound icons). These are two three possible solutions to this problem -

1) Restart the laptop touchpad or USB mouse [1]
This can be done via the command line and does not require you to reboot or logout of your account.

To restart the laptop touchpad -
  • Open terminal (ctrl + alt + t) or press alt + f2 to bring up unity's command lens.
  • Execute the following commands (recommended to run using gksudo but can be run using sudo as well) - 
    • gksudo modprobe -r psmouse (removes the mouse interface from the linux kernel)
    • gksudo modprobe psmouse (adds the mouse interface to the linux kernel)
To restart a USB mouse -
  • Open terminal (ctrl + alt + t) or press alt + f2 to bring up unity's command lens.
  • Execute this command - 
    •  sudo /etc/init.d/hotplug restart
Edit - If you're using a laptop, you can also try this option (requires function keys). The function key combination might not be applicable on your laptop model.

2) Uncheck the 'Disable touchpad while typing' option [2]
This setting is specific to the laptop touchpad.
  • Go to System Settings -> Mouse and Touchpad (under Hardware section)
  • Click on the Touchpad tab and uncheck the Disable touchpad while typing option.

3) Ensure that the Unity HUD or any other Unity lens is off
I was watching a video in VLC fullscreen mode. I primarily use VLC's keyboard commands - ctrl + navigation keys & alt + navigation keys - to move around the playback. During playback I abruptly switched to another app. That's when I faced this problem yet again. I had already unchecked the option as mentioned in step 2 above sometime ago. I tried restarting my mouse by running the commands mentioned in step 1, but that didn't work as well.

While I was using the browser via my keyboard (alt + tab to the rescue) and searching google for help, I happened to press escape 2-3 times and lo and behold, the mouse started working again.

And then it struck me! Whenever you have any unity lens open - the application, video, audio lens or even the HUD - the only areas where you can click with the lens open are the unity panel on the left hand side and the top menu bar. You cannot click anywhere in the app display area when any lens is open. These were exactly the symptoms I was facing and it seems that pressing the escape button multiple times closed a lens which was open in the background (probably when VLC was in fullscreen mode).

To reproduce the above mentioned problem - open a video in VLC and switch to fullscreen mode. Press alt once - this does bring up the HUD for VLC, but it does not show up in front. Now since the HUD is active (but not visible though), you won't be able to use any keyboard commands in VLC! Press escape once which will close the HUD and you'll be able to use VLC keyboard commands again.

Alternatively, you can just open the unity lens once (by pressing the Windows/super button) and close it. This should fix the issue.

References -
[1] Restarting your touchpad/mouse in Ubuntu in simple steps
[2] Trackpad freezes often [closed]

Fixing the XAMPP/LAMPP phpMyAdmin access problem on Ubuntu

If you get a message like this on accessing phpMyAdmin, check this post for a fix -

Access forbidden!

New XAMPP security concept:
Access to the requested object is only available from the local network.
This setting can be configured in the file "httpd-xampp.conf".

If you think this is a server error, please contact the webmaster.

Backstetch - An awesome jQuery plugin for dynamically resizing background images to occupy full size!

Backstretch is a simple yet awesome jQuery plugin that lets you add background images to the whole page or specific div/blocks covering the full area.

While this can be achieved using CSS3's background-size property (using 'cover' as the value or the appropriate fixed/percentage length and width), there are still some issues with this approach -
  • This property is not supported by IE7 and IE8. Support was added in IE9.
  • You need to ensure that the dimensions of your body tag, especially the height, is set correctly to cover the full screen. This can be tricky to achieve across all browsers especially if your page content does not span the entire screen height or exceed it.

Backstretch automatically determines the dimensions and stretches the background images so that they cover the full area. And backstretch does this without skewing the width to height ratio which is an added advantage.

Background images can also be added as fully-stretched slideshows using backstretch!

And it's simple too. Adding a fully stretched background image to the whole page can be done in just one line with a single backstretch function call -

<!-- add jQuery before adding the backstretch plugin -->
<script src="jquery.min.js"></script>
<!-- add the backstretch plugin -->
<script src="jquery.backstretch.min.js"></script>

<script type='text/javascript'>
    $(document).ready(function() {

Check out the official backstretch page for download, demos and more.

Note: You can use this screen resolution simulator website to test your web page with different resolutions after adding backstretch.