Disabling an nvidia graphics card with bbswitch on Fedora

Standard

bbswitch is a kernel module which automatically detects the required ACPI calls for two kinds of Optimus laptops. It has been verified to work with “real” Optimus and “legacy” Optimus laptops.

kernel-headers and kernel-devel are needed to install bbswitch with dkms. Now, installing with dkms ensures that bbswitch is going to survive future kernel upgrades.

sudo yum install kernel-headers kernel-devel dkms

Download the latest stable version of bbswitch, extract, and install with dkms.

wget https://github.com/downloads/Bumblebee-Project/bbswitch/bbswitch-0.5.tar.gz
tar -xf bbswitch-0.5.tar.gz
cd bbswitch-0.5
sudo make -f Makefile.dkms

The nouveau driver needs to be unloaded before bbswitch can be loaded. If nouveau driver is being used somewhere, then the way around is to blacklist nouveau, and rebuild initramfs.

A simple lsmod can reveal if nouveau driver is being used:

lsmod | grep nouveau

You can also try unloading nouveau:

sudo modprobe -r nouveau

If the above fails, we are heading over to blacklisting nouveau and rebuilding initramfs.

su -c "echo 'blacklist nouveau' >> /etc/modprobe.d/disable-nouveau.conf"
sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
sudo dracut --omit-drivers nouveau /boot/initramfs-$(uname -r).img $(uname -r)

If all goes well, reboot.

Nouveau driver can now be easily removed and bbswitch can be loaded once the system has restarted.

sudo modprobe -r nouveau
sudo modprobe bbswitch

Once, bbswitch is loaded, disabling and enabling the graphics card is just a walk in the park:

sudo tee /proc/acpi/bbswitch <<< OFF    # disable
sudo tee /proc/acpi/bbswitch <<< ON     # enable

Verifying the status of the card is as easy as:

cat /proc/acpi/bbswitch

Native apps using web technologies with Node-Webkit

Standard

node-webkit allows you to design and implement desktop applications using web technologies. Everything runs on the client side, and is backed up by node.js. It offers the perfect combo to build native apps using node.js + HTML.

node-webkit is an app runtime based on Chromium and node.js. You can write native apps in HTML and JavaScript with node-webkit. It also lets you call Node.js modules directly from the DOM and enables a new way of writing native applications with all Web technologies.

It’s created and developed in the Intel Open Source Technology Center.

node-webkit can be downloaded from here.

Setting the node-webkit command:


alias nw='path/to/node-webkit/executable'

node-webkit also  comes with the browser restrictions removed, so it perfectly adapts to native app development.

App creation:

A package.json and an index.html are the minimum requirements to create an app. An example package.json would look like:

Packaging:

Packaging the app is even simpler. We only need to create a zip archive, and change its extension to “.nw”.  This archive can then be exectued with the node-webkit command.

Or, the app can also be provided as a stand-alone one, users don’t need  to download node-webkit separately to run the app, making it easy for all kinds of end users. More information here.

Realtiming with Flask-socketIO

Standard

Small, realtimed applications are just beautiful. One can think of an idea, and implement it in no time, and still have a very lively app. I was searching for realtime possibilities which can couple up with Flask, and found a pretty decent solution, a Flask extension, Flask-socketIO.

In a nutshell, socketio is a nodejs realtime app framework, which allows realtimed bidirectional communication.

Since we are using Flask (python), and socketio is written in JavaScript, Flask-socketIO is in turn dependent on gevent-socketio.

On to the code, we need the following pythonic requirements:

  1. gevent-socketio
  2. flask
  3. Flask-socketIO
  4. gevent-websocket

Flask-socketIO makes it very simple to implement event based communication.

Here is a sample server code:

And this is the client JavaScript (Socket.IO required):

Messages in server logs:

Screenshot from 2014-12-20 23:01:17

Messages in client JavaScript console:

Screenshot from 2014-12-20 23:01:14

This example is extremely simple, and I hope is self-explanatory. The Flask-SocketIO provides a lot more than this, here are the links to the Flask-SocketIO documentation and this example’s source.

Another project of mine, “CodeCast“, has a  more practical implementation of Flask-socketIO, which might provide a better understanding of the scenario.