Install bumblebee on Ubuntu 16.10

The same as my last post, but we need to install bumblebee from testing ppa manually, because there are no packages for yakkety yet.

mkdir bumblebee-testing
cd bumblebee-testing
wget https://launchpad.net/~bumblebee/+archive/ubuntu/testing/+files/bumblebee-nvidia_3.2.1-96~xenialppa1_amd64.deb
wget https://launchpad.net/~bumblebee/+archive/ubuntu/testing/+files/bumblebee_3.2.1-96~xenialppa1_amd64.deb
sudo dpkg -i *.deb

And bumblebee can work fine with steam's games now, no need to update libstdc++ library inside steam folder.

Install bumblebee Ubuntu 16.04.1

Update and install latest driver

sudo apt-add-repository ppa:graphics-drivers/ppa
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt install nvidia-prime nvidia-370

Reboot Switch to intel card

sudo prime-select intel

Install bumblebee testing with primus

sudo add-apt-repository ppa:bumblebee/testing
sudo apt update
sudo apt-get install bumblebee bumblebee-nvidia primus nvidia-settings nvidia-370

Add kernel modules to load at boot time

sudo gedit /etc/modules i915 bbswitch

Blacklist nvidia

sudo gedit /etc/modprobe.d/bumblebee.conf # 370 blacklist nvidia-370 blacklist nvidia-370-updates blacklist nvidia-experimental-370

Configure bumblebee

sudo gedit /etc/bumblebee/bumblebee.conf nvidia-current -> nvidia-370 Driver=nvidia

Add user to bumblebee group, enable bumblebeed daemon service.

sudo gpasswd -a $USER bumblebee
sudo systemctl enable bumblebeed

Add boot flags (depend on each machine, my laptop is):

sudo gedit /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.modeset=0 acpi_osi=! acpi_osi=\"Windows 2009\" acpi_backlight=native idle=nomwait"
sudo update grub2

Reboot Check if bumblebee working

sudo apt-get install mesa-utils primusrun glxinfo | grep OpenGL lsmod | grep bbswitch
cat /proc/acpi/bbswitch
primusrun glxgears
cat /proc/acpi/bbswitch

There is a bug that prevent to run steam's games using bumblebee, here is how to fix:

sudo apt-get install lib32stdc++6
cd ~/.steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu
mv libstdc++.so.6 ~/backup/32
ln -fs /usr/lib32/libstdc++.so.6 libstdc++.so.6
cd ~/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu
mv libstdc++.so.6 ~/backup/64
ln -fs /usr/lib32/libstdc++.so.6 libstdc++.so.6

Open games in steam: open steam -> libraries -> right click a game -> properties -> set launch options primusrun %command%

Useful commands:

lspci | egrep 'VGA|3D' lsmod | grep bbswitch dmesg | grep bbswitch dpkg -l | grep bumblebee
lsmod | grep nvidia
optirun -b none
/usr/bin/nvidia-settings -c :8

Sources:

Use fcitx in hipchat on ubuntu

In my company, we use Hipchat to communicate while we work. But on my machine (Ubuntu 16.04.1) I can not type my native language (Vietnamese). That is because I switch from ibus to fcitx (there are lot of bug in ibus these days), and unfortunately, Hipchat only support ibus.

I used to use Hipchat web as an alternative. But recently I find out I can make Hipchat work with fcitx, with a simple command:

sudo ln -s /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so /opt/HipChat4/lib/plugins/platforminputcontexts

Hope this help some one.

Unison End_of_file exception raised in loading archive

Solution:

  1. Go to ~/.unison on your local and delete all cache files. e.g. ar82caecb482c04a8d000cc5f562acde60 and fp82caecb482c04a8d000cc5f562acde60
  2. Go to ~/.unison on your server and delete all cache files, just like above
  3. Delete unison.log if you want (This file is big)

Fix netbeans do not index drupal's files

When you open a drupal project using netbeans > 7.2.1, netbeans won't index files, so we can not go to functions or refactor code.

Here is the way to set up netbeans so that it can recognize drupal's files.

Then you have to delete netbeans's cache, so that it can re-index drupal project:

rm -rf ~/.cache/netbeans/8.0.2

Unison end of file exception

When your computer crash while a unison's profile is open, you will see this error: "End_of_file exception raised in loading archive" (this indicates a bug!)

You can run the command bellow to make it fix the profile, and then you can open the profile again without the error.

unison-gtk -ignorearchives

phpenv, drupalcs in fish shell

To add phpenv and other command to fish shell, run this command: vim ~/.config/fish/config.fish

set PATH $HOME/.phpenv/bin $PATH
set cmd phpenv init - eval $cmd
alias drupal8cs "$HOME/.composer/vendor/bin/phpcs --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"
alias drupal8pr "$HOME/.composer/vendor/bin/phpcs --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"

To reload the configuration, run this command:

exec fish

Install phpdbg on ubuntu 14.04

  1. Install phpenv
  2. Download bison 2.7 and install it http://mirror.esc7.net/pub/Ubuntu/pool/main/b/bison/
cd ~/.phpenv
cd libexec
vim phpenv-install
  1. Here is the most important part, we need to add more options to CONFIGURE_OPTIONS CONFIGURE_OPTIONS="--with-readline --enable-phpdbg"
  2. phpenv install php-5.6.2 At the time this post is published, the latest version of PHP is 5.6.2, you can change that.
cd /path/to/your/index.php
phpenv local 5.6.2
  1. Remember to restore configure options if you want to install other version of php via phpenv