Latest Entries

Re-enable screen brightness Fn keys

My Fn brightness suddenly stopped working on my Thinkpad T510. I traced the problem back to the Nvidia section of my xorg.conf file. After the following small edit, the brightness keys worked again.

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "RegistryDwords" "EnableBrightnessControl=1"
EndSection

Change ‘fee’ value for ACM Latex Paper

Recently I submitted a paper to an ACM Conference. When I was reviewing the final draft I noticed that the fee value in the copyright block was incorrect. For example, in the block below the fee is automatically set to $5.00 but the Conference I’m submitting to has a fee of $10.00.

Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee.

ICIMCS’11, August 5-7, 2011, Chengdu, Sichuan, China
Copyright 2011 ACM 978-1-4503-0918-9/11/08 ...$5.00.

It looks like this value is hard coded into the sig-alternate.cls file. Just go in and modify it like so:

\global\copyrightetc{Copyright \the\copyrtyr\ ACM \the\acmcopyr\ ...\$10.00}

Export high resolution images from PowerPoint

PowerPoint makes it easy to produce professional looking graphics quickly. Sometimes I need to export high quality versions of those slides. By default, PowerPoint limits exports to a resolution of 96 DPI (by comparison, many printers use 300 DPI). However, it is possible to change the default DPI by creating a registry entry.

For Office 2007, browser to:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\PowerPoint\Options

And create a new DWORD value called “ExportBitmapResolution”. Finally set the value to the DPI you want, e.g., “300″.

Now you can export high quality slides by saving them as images.

Instructions for Office 2003 and a list of DPI values and their corresponding image sizes is available at http://support.microsoft.com/kb/827745

OCS Inventory (Where do I put cacert.pem?)

OCS Inventory is an inventory management system that can keep track of the machines connected to the network. It also features a package deployment system that can be used to run commands, install programs or copy files to the machines in the network.

There are a number of guides out there on how to set up the deployment system, but the problem I had is that they all tell you to copy your “cacert.pem” file in the “OCS Inventory Agent installation directory”. I thought that should be “/etc /ocsinventory-agent/” but it’s not.

The directory where you should put it actually depends on the hostname of the OCS Inventory Server. Lets assume that my server is called “jones” and that I would access the control panel at “http://jones/ocsreports”. Then the location where I should copy the “cacert.pem” file on the computers running the OCS Agent would be:

“/var/lib/ocsinventory-agent/http:__jones_ocsinventory/cacert.pem”.

Get VIM to use 256-bit color theme

All this time I’ve been stuck using vim in 8-bit color because I thought my terminal emulator couldn’t support any higher. Turns out all I needed to do was let VIM know that I wanted pretty colors.

Step 1: Make sure you have a VIM color scheme that supports 256 color.
I like the wombat256 theme.

Step 2: Tell VIM that you want 256 color by adding this to your ~/.vimrc file:
set t_Co = 256

Step 3 (optional): Depending on your terminal emulator, you may need to also add this line to your ~/.bashrc file:
export TERM="xterm-256color"

Multiple copies of program in “Open With” dialog

Why are there 20 copies of Photoshop?!

Sometimes duplicate copies of the same program seem to mysteriously show up in the “Open With” dialog. The problem seems to be worse for Windows programs installed with Wine.

The reason there are so many duplicate entries in the “Open With” dialog is due to the way file associates are handled in Wine. Every time a new program is installed in Windows, it has the opportunity to register itself as the handler program for a particular file type. This behavior is also present in Wine.

Each file handler is stored as a .desktop file in ~/.local/share/applications.

Sometimes though, Wine will create a new entry for each and every file type associated with a program. Take MS Excel for example, I have a distinct entry for .xls, .xlsx, .xlsm, .xltm, and .xlsb. These are just for Microsoft’s own variants of their Excel spreadsheet format and each one creates a new entry in the Open With dialog!

At this point, there are two options.

  1. Try to combine several entries together by allowing each one to handle several file types. This is accomplished by editing the “MimeType=” line in the .desktop file. The general format is “MimeType=catagory1/type1; catagory2/type2;” where “catagory1/type1″ is something like “text/csv”.
  2. The above method seemed like too much work, so I opted for the second choice. Copy all the file type entries that you don’t need to another directory. I moved all but the essential entires to ~/.local/share/applications-old.

After a little cleaning up my “Open With” dialog looks much better.

My New OpenBox Desktop

OpenBox is a minimalistic desktop window manager which can be run with or instead of Gnome or KDE. The whole environment is very customizable with nearly everything being controlled by a few scripts and XML documents.

Wallpaper: Arch gray
Icons: Elegant-AwOken (part of Elegant Gnome Pack)
OpenBox window decoration: 1977 OpenBox
GTK theme: Elegant GTK
Vim theme: wombat
Conky: .conkyrc plus power consumption script
Tint2: .tint2rc

Controlling Banshee and RadioTray via DBus

I recently began using OpenBox as my window manager in Linux. One issue I ran into was that my media players were unable to automatically bind to the global media hotkeys. My solution was to write a little bash script to control the media players using DBus. Right now I have support for Banshee and RadioTray. VLC support should be fairly easy to add, but I haven’t had the motivation to search for documentation on their DBus interface.

#!/usr/bin/env bash
#
# Controls playback on any running media players.
#
# usage: media-controller <command>
#
# Command:
#   play
#   pause
#   stop
#   next
#   previous
#
# Supported commands by player:
#   banshee
#       play
#       pause
#       stop
#       next
#       previous
#
#   radiotray
#       play
#       pause
#       stop

if [ ! $# -eq 1 ]; then
    ech o "usage: media-controller <command>"
    exit
fi

COMMAND=$1

BANSHEE_PID=`pgrep -x "banshee"`
RADIO_TRAY_PID=`pgrep -x "radiotray"`

if [ $BANSHEE_PID ]; then
    case $COMMAND in
        play)
            dbus-send --session --type="method_call" \
               --dest='org.bansheeproject.Banshee' \
               '/org/bansheeproject/Banshee/PlayerEngine' \
               'org.bansheeproject.Banshee.PlayerEngine.TogglePlaying'
            ;;
        pause)
            dbus-send --session --type="method_call" \
               --dest='org.bansheeproject.Banshee' \
               '/org/bansheeproject/Banshee/PlayerEngine' \
               'org.bansheeproject.Banshee.PlayerEngine.Pause'
            ;;
        stop)
            dbus-send --session --type="method_call" \
               --dest='org.bansheeproject.Banshee' \
               '/org/bansheeproject/Banshee/PlayerEngine' \
               'org.bansheeproject.Banshee.PlayerEngine.Close'
            ;;
        next)
            dbus-send --session --type="method_call" \
                --dest='org.bansheeproject.Banshee' \
                '/org/bansheeproject/Banshee/PlaybackController' \
                'org.bansheeproject.Banshee.PlaybackController.Next' \
                'boolean:false'
            ;;
        previous)
            dbus-send --session --type="method_call" \
                --dest='org.bansheeproject.Banshee' \
                '/org/bansheeproject/Banshee/PlaybackController' \
                'org.bansheeproject.Banshee.PlaybackController.Previous' \
                'boolean:false'
            ;;
        *)
            ech o "Command not supported for this player"
            ;;
    esac
fi
if [ $RADIO_TRAY_PID ]; then
    case $COMMAND in
        play)
            STATUS=`dbus-send --print-reply --session --type="method_call" \
                --dest='net.sourceforge.radiotray' \
                '/net/sourceforge/radiotray' \
                'net.sourceforge.radiotray.getCurrentRadio'`

            CURRENT_SONG=`ech o \'$STATUS\' | sed 's/.*"\(.*\)"[^"]*$/\1/'`

            dbus-send --session --type="method_call" \
                --dest='net.sourceforge.radiotray' \
                '/net/sourceforge/radiotray' \
                'net.sourceforge.radiotray.playRadio' \
                'string:'$CURRENT_SONG
            ;;
        pause)
            dbus-send --session --type="method_call" \
                --dest='net.sourceforge.radiotray' \
                '/net/sourceforge/radiotray' \
                'net.sourceforge.radiotray.turnOff'
            ;;
        stop)
            dbus-send --session --type="method_call" \
                --dest='net.sourceforge.radiotray' \
                '/net/sourceforge/radiotray' \
                'net.sourceforge.radiotray.turnOff'
            ;;
        *)
            ech o "Command not supported for this player"
            ;;
    esac
fi

Actually getting the desired effect from the media keys required adding the following XML to my ~/.config/openbox/rc.xml file:

    <keybind key="XF86AudioNext">
      <action name="Execute">
        <command>media-controller next</command>
      </action>
    </keybind>
    <keybind key="XF86AudioPlay">
      <action name="Execute">
        <command>media-controller play</command>
      </action>
    </keybind>
    <keybind key="XF86AudioPrev">
      <action name="Execute">
        <command>media-controller previous</command>
      </action>
    </keybind>
    <keybind key="XF86AudioStop">
      <action name="Execute">
        <command>media-controller stop</command>
      </action>
    </keybind>
    <keybind key="XF86AudioPause">
      <action name="Execute">
        <command>media-controller pause</command>
      </action>
    </keybind>
 

Even Microsoft wants IE6 to die

Today Microsoft launched a new website in an effort to speed the demise of Internet Explorer 6. In a twitter post to the official Microsoft account the company proclaimed,

It’s not often that we encourage you to stop using one of our products, but for #IE6, we’ll make an exception: http://bit.ly/g0wt4m

The link redirects to the site, http://ie6countdown.com, which shows a map of estimated IE6 usage by country and announces the company’s goal to reduce the browser share of IE6 from 12% to 1%. From the map, it appears that the worst IE6 offender is China with 34% of Internet traffic coming from the browser compared with the United States’ meager 2.9%.

The site also offers suggestions on how to help friends and neighbors upgrade, declaring, “Friends don’t let friends use Internet Explorer 6.”

For anyone whose ever worked in web development, the demise of IE6 can’t come soon enough.

How much power is your laptop using?

Products like Kill-A-Watt show how much power appliances are using. It’s good way to measure your computer’s power consumption — when it’s plugged in. But what if I want to know how much power my laptop is using when I’m not plugged in?

Turns out it’s fairly easy to get battery info. Running cat /proc/acpi/battery/BAT0/state should return the current discharge rate and total battery capacity.

The trouble is that the “current rate” field sometimes switches between mW and mA. I have no idea why this is the case. Oh well, we can easily convert mA to mW with the formula: watts = amps \times volts .

The end result is this conky friendly bash script:

#!/usr/bin/env bash
# Print the current power consumption in watts.
# The script pulls the power consumption info
# from /proc/acpi/battery/BAT0/state
#
# Usage: power.sh [battery_num]
#
# Add to conky:
#   ${execi 10 ~/conkyscripts/power.sh 0}
#

# Default is BAT0
BATTERY=0
if [ $1 ]; then
    BATTERY=$1
fi

# Sometimes the "present rate" is returned in milliwatts,
# but sometimes it is in milliamps. If it's in milliwatts,
# we just convert to watts and return. Otherwise we
# convert to watts with the formula:
#   Watts = Amps * Volts

UNIT=`cat /proc/acpi/battery/BAT$BATTERY/state | \
    grep "present rate:" | awk '{ print $(NF) }'`

if [ $UNIT == "mW" ]; then
    MILLI_WATTS=`cat /proc/acpi/battery/BAT$BATTERY/state | \
        grep "present rate:" | awk '{ print $(NF-1) }'`
    e cho $[ $MILLI_WATTS / 1000 ].$[ ($MILLI_WATTS % 1000) / 100 ]
else
    MILLI_AMPS=`cat /proc/acpi/battery/BAT$BATTERY/state | \
        grep "present rate:" | awk '{ print $(NF-1) }'`
    MILLI_VOLTS=`cat /proc/acpi/battery/BAT$BATTERY/state | \
        grep "present voltage:" | awk '{ print $(NF-1) }'`
    POWER=$[$MILLI_AMPS * $MILLI_VOLTS]
    echo $[ $POWER / 1000000 ].$[ ($POWER % 1000000) / 100000 ]
fi


Copyright © 2004–2009. All rights reserved.

RSS Feed. This blog is proudly powered by Wordpress and uses Modern Clix, a theme by Rodrigo Galindez.