Archive

Author Archive

Re-enabling KDE touch pad

April 30th, 2013 3 comments

As I wrote in an earlier post, the ambient light button on HP EliteBooks is per default mapped to switch off the touch pad. Since it’s placed right next to the function keys that increase or decrease the screen brightness, it happens quite often that the key is hit by accident.

If you’re running KDE, hitting Fn+F11 not only switches off the touch pad. You can’t even re-enable it with the System Settings manager, since System Settings -> Input Devices -> Touchpad manipulates ~/.kde/share/config/kcmtouchpadrc but the touch pad is disabled in ~/.kde/share/config/ktouchpadenablerrc.

To re-enable the touch pad, open ~/.kde/share/config/ktouchpadenablerrc with an editor and change it to

[general]
touchpadEnabled=true
Categories: Uncategorized Tags: ,

Enabling HP EliteBook ambient light sensor

April 21st, 2013 No comments

To enable the ambient light sensor on an HP EliteBook 8440p or 8460p run

# echo 1 > /sys/devices/platform/hp-wmi/als

To disable:

# echo 0 > /sys/devices/platform/hp-wmi/als
Categories: Uncategorized Tags:

Fixing HP EliteBook ambient button

April 10th, 2013 No comments

The button that is supposed to toggle the ambient light sensor on HP EliteBooks 8440p and 8460p per default switches off the touch pad. That is because Fn+F11 (scancode 0x33), which is the ambient light button, is incorrectly mapped to KEY_TOUCHPAD_OFF (keycode 193) in kernel.

To remap the scancode to another keycode, you can use setkeycodes. An appropriate choice for a target keycode could be KEY_PROG1 (XF86Launch1, keycode 148) which can be easily reconfigured in KDE or any other desktop environment to run any custom command.

Run the following command as root to remap Fn+F11 to KEY_PROG1:

# setkeycodes e033 148

Resources:
http://www.linlap.com/hp_elitebook_8460p

Categories: Uncategorized Tags: , ,

C/C++ compound binary logic operations

March 22nd, 2013 No comments

I’ve always had trouble reading and understanding compound binary operations fluently. Whenever they appear in a piece of code, I have to decode them to actually understand what they are doing. This is mainly due to the fact that I infrequently work close to hardware were heavy bit manipulation is a daily occurrence. I won’t bother you with the truth tables of regular bitwise operators, but here’s list of combined bit operations that come in quite handy:

Setting a bit

foo |= 0x01;

The OR operation is used to set a particular bit that is specified in a BIT MASK. The bit mask is usually specified in hex. In this example it is 0x01 which indicates the first bit.

Clearing a bit

To clear bit 0 in foo, two different bit operations are required:

foo &= ~0x01;

This example uses the AND and the NOT operator. The NOT operator is used, because most programmers like to specify a mask, wherein the bit that should be changed, is set. You could of course just use a mask, wherein the bits that should be changed are unset, therefore eliminating the requirement for the NOT operator (note that this is highly uncommon though).

Flipping a bit

Another very useful tool is the XOR operator:

foo ^= 0x01;

This toggles the first bit, independent of its current state and leaves all other bits unchanged.

Checking if a bit is set

Because a statement anything other than zero is considered TRUE in C/C++ (and probably every other programming language, too), you can use

if(foo & 0x01) {
  (...)
}

to check, whether the first bit is set or clear.

Dynamically building a bit mask

Because it is much easier to specify the bit number that should be changed rather than the actual bit mask, programmers usually build up the bit mask dynamically. This is done by left-shifting 0x01 n-times. For example, to build a bit mask that has bit number 7 set, you left-shift 0x01 seven times:

(0x01 << 7)

To build a bit mask that has the first bit (bit number 0) set, you’d shift 0x01 zero times:

(0x01 << 0)
Categories: Uncategorized Tags:

Accessing PL2303 USB serial adapter as non-root user

March 8th, 2013 No comments

If you plug the PL2303 USB to serial adapter (or any other FTDI-like USB adapter) into your USB port, udev creates a /dev/ttyUSBX device with limited read and write permissions (0660 per default). Usually, only the root user and a specific group can access the device at all . To access the device as a regular user, you can either become a member of that group (distribution specific, dialout on fedora) or tell udev to create the device with different read and write permissions.

Become a member of dialout

Simply run

# usermod -a -G groupname username

to add the user username to the group groupname. To verify, that a certain user is a member of a specific group, you can grep the file /etc/group for a user name

# grep username /etc/group

Note that you have to re-login for this changes to take effect.

Create the device with different permissions

Alternatively, you can tell udev to create the /dev/ttyUSBX device with different read and write permissions. Add a udev rule to /etc/udev/rules.d/, e.g. /etc/udev/rules.d/85-PL2303SerialPort.rules with the following content:

ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE="0666"

You can get the vendor and product id from lsusb or by looking at /var/log/messages when you plug in the device.

After saving the new udev rule, tell udev to reload it’s ruleset

# udevadm control --reload-rules

and eventually plug in your adapter.

Categories: Uncategorized Tags: ,

How to label a partition

February 26th, 2013 No comments

Labelling a partition can be quite handy, especially for partitions on usb drives that usually get auto-mounted to a folder that corresponds to their label.

Usually the label is set when the partition is created. If the label is not explicitly specified, it is usually auto-generated. To change the label, there are a couple of tools available:

ext2/ext3/ext4 partitions

You can either use e2label

# e2label device [newlabel]

or tune2fs

# tune2fs -L [newlabel] device

FAT/FAT16/FAT32 partitions

Again, there are multiple tools available, from simple perl scripts to mtools, but the easiest to use is probably dosfslabel from the dosfstools package

# yum install dosfstools
[...]
# dosfslabel device [newlabel]

NTFS partitions

ntfslabel is available as part of the ntfsprogs package

# yum install ntfsprogs
[...]
# ntfslabel device [newlabel]
Categories: Uncategorized Tags: ,

Inserting arbitrary unicode characters to kwrite

February 12th, 2013 No comments

While you can normally insert arbitrary unicode characters to any X11 application using Ctrl-Shift-u and four hex digits, it doesn’t work in kwrite or kate. Instead you’d have to press F7 to switch to command line and type in

char <unicode>

For example, to get the degree symbol (Unicode: U+00B0) you’d type in 'char 176' (176 being 0xB0 converted do decimal).

Categories: Uncategorized Tags: ,

Search for a package containing a certain file

January 30th, 2013 No comments

Assumed you want to find the package that contains the shared object libGLU.so.1, e.g. because a binary is dynamically linked against it, and ldd tells you that the shared library requirements are not met. On Fedora (or any yum-type os) you’d run

$ yum whatprovides */libGLU.so.1

and yum would tell you, that mesa-libGLU comes with /usr/lib64/libGLU.so.1 which could fulfill your need (could because you could also be missing the i686 version of the package, depending on your binary).

The Ubuntu way of achieving the same thing:

$ apt-file search libGLU.so.1

And of course the corresponding package would be libglu1-mesa on any recent Ubuntu os.

Categories: Uncategorized Tags: , ,

Changing the default displaymanager in Fedora 18

January 21st, 2013 1 comment

With the release of Fedora 18, there have been some changes to the /etc/sysconfig directory. For example, switching the default display manager is no longer done by altering parameters in /etc/sysconfig/desktop but via

# systemctl enable --force displaymanager.service 

Therefore, to switch from the default gdm to kdm you’d run:

# systemctl enable --force kdm.service 
Categories: Uncategorized Tags: ,

How to send a client’s hostname to the DHCP server

January 5th, 2013 1 comment

In contrast to Ubuntu (or even Microsoft Windows) default installations of Fedora do not send the client’s hostname to the DHCP server.

To change this behaviour, add a DHCP_HOSTNAME variable to your /etc/sysconfig/network-scripts/ifcfg-eth0 file (eth0 being your NIC’s interface name):

UUID="616426f3-ac0b-4a4a-9221-62a0055bfb07"
NM_CONTROLLED="yes"
NETBOOT="yes"
BOOTPROTO="dhcp"
DHCP_HOSTNAME="MyFedoraBox"
DEVICE="eth0"
TYPE="Ethernet"
ONBOOT=yes
NAME="DHCP"
HWADDR=00:25:22:4A:3F:F2
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
USERS=user

Of course, this only works if you actually get your IP address via DHCP (since the DHCP server hands off the hostname to the DNS server). If you use a static IP configuration, nsupdate can be used to dynamically update the DNS server records. Examples and instructions on how to use nsupdate can be found at http://linux.yyz.us/nsupdate/ or http://dijks.wordpress.com/2012/07/17/register-a-hostnames-static-ip-with-your-corporate-dns-server/.

Categories: Uncategorized Tags: ,