posted on: January 26, 2014
updated on: October 21, 2020
All of my recent FreeBSD/PCBSD efforts have been done on my trusty Lenovo T420. This post is going to highlight some tweaks I've done to make this laptop sing in FreeBSD (I'm running PCBSD 10 but I don't see why these won't work just fine in FreeBSD proper).
This is going to be a continually evolving post, I'll post update notices at the bottom of the post when new items are added.
Set the keyboard layout
First we want to turn on the special acpi for Lenovo laptops (remember that Lenovo bought the ThinkPad division from IBM).
in /boot/loader.conf add
acpi_ibm_load="YES"
manually load the module now so don't need to reboot
sudo kldload acpi_ibm
Now to get the "special" keys like volume up/down to work you need to set the keyboard layout. I'm currently running MATE as my desktop, in MATE open the System->Preferences->Keyboard menu. In the Keyboard Prefrences dialog that opens up click the Layouts tab and then the button next to Keyboard model: select the IBM ThinkPad R60/T60/R61/T61
Now you can open the menu System->Preferences->Keyboard Shortcuts, if Volume Down is set to XF86AudioLowerVolume and Volume Up is set to XF86AudioRaiseVolume, the built-in volume keys on the laptop should work. I've not gotten the mute key to work yet, if you know how please leave a comment. Fix brightness control when using Intel Graphics
The T420 I have has the Intel Integrated HD Graphics 3000 which works great in PCBSD 10 but controlling the screen brightness doesn't work out of the box. The following solution was pieced together with info from Nabble and FreeBSD forums
first the acpi_call package needs to be installed:
sudo pkg install acpi_call
manually load the module now so don't need to reboot
sudo kldload acpi_call
if you want the brightness controls to always be available edit /boot/loader.conf by adding:
acpi_call_load="YES"
need to enable the wheel group to use acpi, edit /etc/devfs.conf by adding:
perm acpi 0660
restart devfs with:
sudo service devfs restart
now you need to create 4 helper scripts
brup.sh
#!/bin/sh
# This will increase the screen brightness value
# that is stored in /tmp/brightlvl.
# valid range is 0-16
if [ ! -f /tmp/brightlvl ]; then
echo 0 > /tmp/brightlvl
fi
lvl=`cat /tmp/brightlvl`
if [ $lvl -gt 15 ]; then
exit 0
fi
lvl=`expr $lvl + 1`
echo $lvl > /tmp/brightlvl
echo $lvl
exit 0
brdown.sh
#!/bin/sh
# This will decrease the screen brightness value
# that is stored in /tmp/brightlvl.
# valid range is 0-16
if [ ! -f /tmp/brightlvl ]; then
echo 16 > /tmp/brightlvl
fi
lvl=`cat /tmp/brightlvl`
if [ $lvl -lt 1 ]; then
exit 0
fi
lvl=`expr $lvl - 1`
echo $lvl > /tmp/brightlvl
echo $lvl
exit 0
brightness_up.sh
#!/bin/sh
# This command will increment the brightness value if
# possible and use the appropriate acpi call for
# the Lenovo T420 with Intel Graphics
VAL=`brup.sh`
acpi_call -p '\VBRC' -i $VAL
brightness_down.sh
#!/bin/sh
# This command will decrement the brightness value if
# possible and use the appropriate acpi call for
# the Lenovo T420 with Intel Graphics
VAL=`brdown.sh`
acpi_call -p '\VBRC' -i $VAL
Place the 4 scripts in ~/bin and chmod the files:
chmod +x ~/bin/brup.sh
chmod +x ~/bin/brdown.sh
chmod +x ~/bin/brightness_up.sh
chmod +x ~/bin/brightness_down.sh
Now open up the System->Preferences->Keyboard Shortcuts menu and add two new shortcuts; Brightness Down and Brightness Up. For Brightness Down assign the command brightness_down.sh and for Brightness Up assign the command brightness_up.sh. Assign shortcuts for these commands and they should adjust the screen brightness. I've not been able to get the Fn+Home and Fn+End buttons to work as shortcuts, if you know how to get those working please leave a comment.
Update 2020-10-21 There is a thread on this post at Lobsters, my handle is cpuserf there.