Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Monday, 15 December 2014

Install Bumblebee on Ubuntu 14.04

Bumblebee is a great tool to manage hybrid graphics on linux distribution(NVIDIA users). It switches the discrete graphics off to save battery in a smart way and turns it on whenever required. In this way it saves a lot of battery power. In my previous post i provided the steps to install bumblebee on Ubuntu 12.04. But on Ubuntu 14.04 its different and very easy as compared to older ways. The steps given on ubuntu wiki website are enough to achieve that. And the steps are :

  1. Enable the Universe and Multiverse repositories - you need to do this to allow the bumblebee and nvidia packages respectively to be installed.
  2. Enter the following command in the termianl
    sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic
  3. Reboot 
Simple! Now you can observe that your fan is not running very fast and battery backup has increased.

Tried On : Ubuntu 14.04 , Dell N51110 , NVIDIA GT 525M
May Also work with : Ubuntu 14.04 ,any laptop with NVIDIA graphics card.

Sunday, 16 March 2014

Bumblebee : The best way to disable discrete Nvidia graphic card on every startup Linux

GUI interface for Bumblebee
Screenshot of Bumblebee-ui
This is also the first and best step in order to increase battery life of your Laptop (only for laptops with Nvidia Graphic card and Ubuntu 12.04 or later, you may try for other linux distros ). This post will teach you how to disable discrete graphics at every startup automatically (without any crashes and freezes). But first i have some facts about this phenomenon here, if you're not interested in facts just move to the "Solution" section at the bottom of post.

Problem :
When we use any Linux distribution, we observe that the battery gets consumed very fast. But is this the case with Linux only ? NO, WINDOWS ALSO BEHAVES THE SAME UNLESS the dedicated graphics driver is installed. You can verify it by installing the intel integrated graphics driver only and not installing dedicated graphics driver. Your fan will run fast and battery backup will be very low.
It all happens because we do not install the dedicated graphics driver and both graphic cards (intedgrated and dedicated) remain turned on , thus consuming more battery (as if you're playing a high end game). Solution will be to turn off the discrete graphics card at every startup of linux. For windows users its simple (just install the Nvidia graphics driver from the official website). But on Linux its complicated.

Stats :
I noted down some readings showing battery percentage left vs. battery backup time in various situations.
On Fresh install of Ubuntu 12.04
Percentage Time Left (min.) Percentage/Time Left(min.)
       75.4 40.8 1.84
       74.5 44.3 1.68
       72 42.5 1.69
(Lesser the value of  Percentage/Time Left(min.) the better for us )
Somehow i turned the dicrete graphics card off with the following command as explained at http://planetoss.com/articles/how-to-disable-the-discrete-amd-graphics-card-in-linux/
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
(But don't edit rc.local to do this at every startup, your machine will start crashing and freezing at startup)
and the results are as follows :

Percentage Time Left (min.) Percentage/Time Left(min.)
     66 39 1.69
     65 66 0.98
     64 67 0.95

These results are what we need but this is not safe way to get it done, it causes freezes and crashes.
So , we have to move on to nvidia optimus technology (but only for windows). This technology is included in the drivers intself, and that is why you don't face the problem while using windows with these drivers.
Results after installing nvidia optimus on windows :

Percentage  Time Left (min.) Percentage/Time Left(min.)
       80 74 1.08
       79 116 0.68
       78 104 0.75
       77 72 1.06
Here are some solutions on other websites which failed for me

  1. http://planetoss.com/articles/how-to-disable-the-discrete-amd-graphics-card-in-linux/
  2. http://ubuntuguide.net/ubuntu-12-04-turn-off-discrete-graphic-card-on-boot 
  3. http://askubuntu.com/questions/166682/how-do-i-turn-off-the-discrete-card-on-boot-when-theres-no-option-in-the-bios
  4. http://rudrageek.com/hybrid-graphics-card-system-in-ubunru-fedora-intelati-vgaswitcheroo/
  5. https://github.com/peberlein/acpi_call failed because There was no code for my laptop model,
    Also i advice that never edit your /etc/rc.local file , It definitely causes crashes one day or another.

Now the question is how to achieve the above Nvidia-optimus technology on linux ?
The solution is Bumblebee.
What is the correct way to install Bumblebee ?
It is given below :

Solution
This solution is for Ubuntu 12.04 onwards. However Ubuntu 13.10 officially supports Bumblebee.

Installation

Basic Setup

You need to open your terminal and enter the commands below.
If on 12.04.3, replace linux-headers-generic with linux-headers-generic-lts-raring.

  1. sudo add-apt-repository ppa:bumblebee/stable
  2. Enable the Universe and Multiverse repositories (for bumblebee and nvidia packages respectively).
  3. sudo apt-get update
  4. Install Bumblebee using the default proprietary nvidia driver for 12.04 - 13.04 :
    sudo apt-get install bumblebee bumblebee-nvidia virtualgl linux-headers-generic
    • And for 13.10 :
    sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic
    Note : Keep an eye on the output of the above command. If at the end of output you are asked to run command with "--fix-missing?" , then do it.In my case i had to rerun the above command as :
    sudo apt-get install bumblebee bumblebee-nvidia virtualgl linux-headers-generic --fix-missing
   5. Reboot.

This will by default run all applications with integrated graphic card, thus saving your battery by keeping discrete graphics card turned off.You can Select any app(game) to run on discrete graphic card easily.You can read and learn more about the usage of Bumblebee at Ubuntu Wiki.

However you might want a GUI interface for BumbleBee rather than entering commands again and again. So , here it is :
  1. Go to https://github.com/Bumblebee-Project/bumblebee-ui.
  2. Click "Download zip" at the right end of page.
  3. Extract the zip file in home directory.
  4. In the extracted folder, find the "INSTALL" file and run it with :
    sudo ./INSTALL
  5. Its done , now you can run it by opening the dash and searching for "bumblebee applications settings" and "Bumblebee-indicator".
  6. You may want to add Bumblebee-indicator to startup :
    Open the dash.
    Type "startup applications" and press enter.
    Press "Add".
    Enter any name you would like.
    In Command , click browse and select the file "/usr/share/bumblebee-ui/Bumblebee-Indicator.py".
    click add and its done.
Note : To uninstall Bumblebee-UI , run the UNINSTALL file located in the extracted zip file setup (in the app direcotry i.e. /bumblebee-ui-master/app/UNINSTALL) Just run it as :
sudo ./UNINSTALL

Update :  Ubuntu 14.04 users can install Bumblebee with help of this post.
Tried On : Ubuntu 12.04 LTS , Dell N51110 , NVIDIA GT 525M
May Also work with : Ubuntu 12.04 and later versions, any laptop with NVIDIA graphics card. 

Wednesday, 19 February 2014

Running 32-bit eclipse ADT in 64-bit ubuntu 12.04

Here are the steps to safely install Android SDK on ubuntu 12.04 and avoid any errors.
1. Install eclipse Android SDK on 64-bit linux as directed                   at https://developer.android.com/sdk/installing/index.html.
Now eclipse will run fine but when we try to launch AVD emulator it may throw an error :
Cannot run program “ xx/sdk//tools/emulator”: java.io.IOException: error=2, No such file or directory
Info :
This is very common on 64-bit linux with a very simple solution.
mentioned at https://wiki.debian.org/Multiarch/HOWTO
solution according to them is :

Installing Android SDK compat libraries


Some users using the Android SDK might encounter problems when trying to run build-tools or platform-tools on amd64 bit platform. As replacement for ia32-libs, users should be fine just installing the following libraries:
dpkg --add-architecture i386
aptitude update
aptitude install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
 But this is not the solution for ubuntu 12.04 users
 because "--add-architecture" is not supported with the dpkg version (1.16.1.2 (amd64)) supplied with ubuntu 12.04. Thus we have to do the same thing in another way. Here is how :
Solution :
make sure the only file present in /etc/dpkg/dpkg.cfg.d/ is "multiarch"
ls /etc/dpkg/dpkg.cfg.d/
if output is multiarch, execute the following commands as it is else replace "multiarch" with the name of file present in that directory.
sudo sh -c "echo 'foreign-architecture i386' > /etc/dpkg/dpkg.cfg.d/multiarch"
The above commands will add i386 architecture (alternate command to "dpkg --add-architecture i386") . The rest commands are the same (you can use aptitude instead of apt-get if you have aptitude installed)

sudo apt-get update
sudo apt-get install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386 
 Run the above commands and you're done! The emulator should work fine now.

Tried On : Ubuntu 12.04 + eclipse+ADT Build : v22.3.0-887826
May also work on : Ubuntu 12.04 and later versions , but note that for versions later than 12.04 , the first official solution mentioned in this post is easier.

Sunday, 16 February 2014

Creating GUI applications with C++

Are you the person who has struggled enough in console programming (using cout, cin functions) and developing logics. But somewhere you want to develop Graphical user interface to start making your softwares for common people using linux or windows (any). For this you actually need a GUI library to work with. There are plenty of free portable GUI libraries, each with its own strengths and weaknesses:
We have got numerous reasons why we should use qt creator. You can search them on google. So lets get going with Qt creator.
Get Qt-creator
For Windows : 
1. Go to this and download Qt for windows. (There are two versions of it , one for Visual basic developers and other who want to work with minGW compiler.
2. After downloading , install it simply by double-clicking on the file.

For Ubuntu :
1.  Go to this page and download Qt for linux. (you should know whether your installed linux is 32 bit or 64 bit)
2. Open a terminal. In Gnome the terminal is found in Applications>Accessories>Terminal or just press ctrl+alt+t
3. Navigate to the directory of the downloaded .run file . For example, I have mine on the desktop so I would type in "cd ~/Desktop" and press enter.
3. Type "chmod +x example.run" (press enter).
4. Now type "./example.run", press enter, and the installer will run. 5. After installation open the terminal and run the following commands :
sudo apt-get install mesa-common-dev 
sudo apt-get install freeglut3 
sudo apt-get install freeglut3-dev 
sudo apt-get install glut3  
sudo apt-get install glut3-dev 
sudo apt-get install libglut3 
sudo apt-get install libglut3-dev 
sudo apt-get install libglu1-mesa-dev
Congrats! you have installed qt creator for ubuntu. To learn working with qt there are many tutorials available online . You can search for a torrent of Prentice Hall C++ GUI Programming with Qt4 2nd Edition
Tried On : Ubuntu 12.10 , windows 8 and Qt 5.0.1
May also work on : Any other versions of the above and any linux distribution.

Featured Post

PHP EmailMessage class for extracting attachments

Hi, recently I had to create a php program which fetches emails with attachments (including inline). I searched a lot and succeeded with h...