Friday, May 4, 2012

Switching CPUFreq Governors via acpid

The CPUFreq subsystem of the Linux kernel allows one to modify the CPU clock speeds on the fly depending on the system needs. Most Linux distributions use the ondemand CPUFreq governor by default to reduce overall power consumption but also provide performance when needed. However, on a laptop computer I prefer to have continuous high performance via the performance governor when it is connected to AC power and drop back to ondemand governor when on battery power. This results in an overall improvement in the responsiveness of the system when connected to AC power even under heavy loads.

The switching of governors can be easily automated using the acpid service that is installed on most modern Linux distributions. The procedure below describes the method for Ubuntu 12.04 but should work with minor modifications on most distributions.

  1. Start by installing the cpufrequtils package and ensuring that acpid is installed using the command:
    sudo apt-get install cpufrequtils acpid
  2. Create a file named /etc/acpi/events/governor with the following contents:
    # /etc/acpi/events/governor
    # Called when the user connects ac power to us
    # 
    
    event=ac_adapter
    action=/etc/acpi/governor.sh
    
  3. Similarly, create a file named /etc/acpi/governor.sh with the following contents:
    #!/bin/sh
    #
    # /etc/acpi/governor.sh
    #
    # Load the functions related to the state of the AC power.
    #
    POWER_FUNCS=/usr/share/acpi-support/power-funcs
    test -f ${POWER_FUNCS} || exit 0
    . ${POWER_FUNCS}
    #
    # Utilities used by this script.
    #
    LOGGER="/usr/bin/logger -t governor.sh"
    CPUFREQSET="/usr/bin/cpufreq-set"
    SEQ="/usr/bin/seq"
    AC_GOVERNOR="performance"
    BATTERY_GOVERNOR="ondemand"
    #
    # Get the state of the AC power.
    #
    getState
    #
    # Select the governor based on the state of the AC power.
    #
    GOVERNOR="ondemand"
    case "$STATE" in
        "AC")
            GOVERNOR=${AC_GOVERNOR}
        ;;
        *)
            GOVERNOR=${BATTERY_GOVERNOR}
        ;;
    esac
    #
    # Get the number of CPUs.
    #
    NUM_OF_CPUS=`/bin/ls /sys/devices/system/cpu/ | grep -E "cpu[0-9]+" | wc -l`
    #
    # Set the governor for all the CPUs.
    #
    $LOGGER "Setting governor to ${GOVERNOR}."
    for cpu_num in `${SEQ} 0 $[ NUM_OF_CPUS - 1 ]`
    do
        $CPUFREQSET -c ${cpu_num} -g ${GOVERNOR}
    done
    
  4. Finally, reload the acpid configuration using following command:
    sudo service acpid reload
Related Pages

Monday, April 30, 2012

Remove Overlay Scrollbar In Ubuntu

I prefer KDE over both Gnome and Unity desktops in Ubuntu. Even while using KDE several GTK-based applications on Ubuntu use the annoying "overlay scrollbar" by default. It is this stuff (in red rectangle):
Don't like it? Get rid of it using the following command in Ubuntu 12.04:
sudo apt-get remove overlay-scrollbar \
                    liboverlay-scrollbar-0.2-0 \
                    liboverlay-scrollbar3-0.2-0
Adios!

Saturday, April 28, 2012

"Updating Player" Message While Watching Amazon Instant Video on Linux

While watching several newly released movies or television episodes on Amazon Instant Video I have gotten the following message from the Flash Player on Ubuntu Linux:
After displaying the above message the Flash Player attempts to perform some kind of an update but fails with the following message:
This happens even though I have the latest version of Adobe Flash Plugin installed. As posted here, the problem turned out to be the fact that the Adobe Flash Plugin assumes that you are still using the ancient/deprecated hal package. This package is no longer installed on most modern Linux distributions. So, if you are using Ubuntu/Debian Linux, you can fix the above issue using the command:
sudo apt-get install hal
After the above command completes successfully, reload the Amazon Instant Video page and you ought to be good. Needless to say that Adobe's Linux software team is still living in 2008. This problem would have been fixed a long time ago if the Adobe Flash Player was open-source software. Sigh.

Sunday, October 23, 2011

Why I Use Linux: Reason #417

When I extract files from a compressed archive, I do not have to worry about ending up with a million files on my desktop or multiple nested folders with the same name:

Thursday, July 14, 2011

Why I Use Linux: Reason #418

Because it is 2011, Microsoft has released Windows 7, and users of their flagship operating system still have to use a tiny non-resizable 33.5-character wide window to type environment variables:

Wednesday, July 13, 2011

Why I Use Linux: Reason #419

So I do not have to deal with stuff like this (as experienced on Microsoft Windows 7):


Saturday, July 2, 2011

Pantech UML290 pppd Script

As reported in this article, one can utilize WvDial on Linux to use a Pantech UML290 modem on Verizon's 4G LTE network. For those who do not like using WvDial, this article provides a basic pppd script to connect to the network using this modem.
You will need the following two files:

Assuming that you have pppd installed on your machine (duh), place the file chat-Verizon-4G-LTE in /etc/ppp directory. Similarly, place the file Verizon-4G-LTE in /etc/ppp/peers directory.
Now insert the Pantech UML290 modem in a USB port of your machine and use the following command to connect:
sudo pppd call Verizon-4G-LTE

Update: If the above method fails with the error message mentioned in this comment, then please try the solution described here.
Enjoy!!