commit cf9e2b0cb47c791505d133867d96d661ad179413 Author: Mikael Hansson Date: Sun Sep 3 16:26:02 2023 +0200 First commit. diff --git a/README.md b/README.md new file mode 100644 index 0000000..45df033 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +FreeBSD on Lenovo x260 +====================== +This repository contains configuration files for a more-or-less working x260 laptop on FreeBSD 13. There's some additional work to do, but with the tweaks here, the following works: + +- Wayland with Sway (Sway settings in [separate repo](https://git.oxcrag.net/mikaelh/swayconfig)). +- Screen brightness can be controlled with the Fn+F5 and Fn+F6 keys. +- Computer goes to sleep when lid is closed. Unfortunately Wayland+Sway crashes upon wake-up, but it's possible to switch to a separate TTY, kill Sway and re-login. diff --git a/boot/loader.conf b/boot/loader.conf new file mode 100644 index 0000000..93a6d98 --- /dev/null +++ b/boot/loader.conf @@ -0,0 +1,5 @@ +cryptodev_load="YES" +zfs_load="YES" +acpi_ibm_load="YES" +acpi_video_load="YES" +efi_max_resolution="1920x1080" diff --git a/etc/devd.conf b/etc/devd.conf new file mode 100644 index 0000000..7ddb36f --- /dev/null +++ b/etc/devd.conf @@ -0,0 +1,282 @@ +# $FreeBSD$ +# +# Refer to devd.conf(5) and devd(8) man pages for the details on how to +# run and configure devd. +# + +# NB: All regular expressions have an implicit ^$ around them. +# NB: device-name is shorthand for 'match device-name' + +options { + # Each "directory" directive adds a directory to the list of + # directories that we scan for files. Files are loaded in the order + # that they are returned from readdir(3). The rule-sets are combined + # to create a DFA that's used to match events to actions. + directory "/etc/devd"; + directory "/usr/local/etc/devd"; + pid-file "/var/run/devd.pid"; + + # Setup some shorthand for regex that we use later in the file. + #XXX Yes, this is gross -- imp + set wifi-driver-regex + "(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|\ + run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+"; +}; + +# x260-specific config +notify 10 { + match "system" "ACPI"; + match "subsystem" "IBM"; + action "/usr/local/sbin/acpi_oem_exec.sh $notify ibm"; +}; + +# Note that the attach/detach with the highest value wins, so that one can +# override these general rules. + +# +# Configure the interface on attach. Due to a historical accident, this +# script is called pccard_ether. We omit the usbus devices because those +# devices are associated with the USB Bus and provide an ifnet device to +# allow usb traffic to be captured with usbdump(8). +# +# NB: DETACH events are ignored; the kernel should handle all cleanup +# (routes, arp cache). Beware of races against immediate create +# of a device with the same name; e.g. +# ifconfig bridge0 destroy; ifconfig bridge0 create +# +notify 0 { + match "system" "IFNET"; + match "subsystem" "!(usbus|wlan)[0-9]+"; + match "type" "ATTACH"; + action "/etc/pccard_ether $subsystem start"; +}; + +# +# Try to start dhclient on Ethernet-like interfaces when the link comes +# up. Only devices that are configured to support DHCP will actually +# run it. No link down rule exists because dhclient automatically exits +# when the link goes down. +# +notify 0 { + match "system" "IFNET"; + match "type" "LINK_UP"; + media-type "ethernet"; + action "service dhclient quietstart $subsystem"; +}; + +# +# Like Ethernet devices, but separate because 802.11 require spawning +# wlan(4) interface. +# +attach 0 { + device-name "$wifi-driver-regex"; + action "/etc/pccard_ether $device-name startchildren"; +}; +detach 0 { + device-name "$wifi-driver-regex"; + action "/etc/pccard_ether $device-name stopchildren"; +}; +notify 0 { + match "system" "IFNET"; + match "type" "LINK_UP"; + media-type "802.11"; + action "service dhclient quietstart $subsystem"; +}; + +# An entry like this might be in a different file, but is included here +# as an example of how to override things. Normally 'ed50' would match +# the above attach/detach stuff, but the value of 100 makes it +# hard wired to 1.2.3.4. +attach 100 { + device-name "ed50"; + action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; +}; +detach 100 { + device-name "ed50"; +}; + +# When a USB Bluetooth dongle appears, activate it +attach 100 { + device-name "ubt[0-9]+"; + action "service bluetooth quietstart $device-name"; +}; +detach 100 { + device-name "ubt[0-9]+"; + action "service bluetooth quietstop $device-name"; +}; + +# Firmware downloader for Atheros AR3011 based USB Bluetooth devices +#attach 100 { +# match "vendor" "0x0cf3"; +# match "product" "0x3000"; +# action "sleep 2 && /usr/sbin/ath3kfw -d $device-name -f /usr/local/etc/ath3k-1.fw"; +#}; + +# When a USB keyboard arrives, attach it as the console keyboard. +attach 100 { + device-name "ukbd0"; + action "service syscons setkeyboard /dev/ukbd0"; +}; +detach 100 { + device-name "ukbd0"; + action "service syscons setkeyboard /dev/kbd0"; +}; + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "atp[0-9]+"; + + action "service moused quietstart $cdev"; +}; + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "ums[0-9]+"; + + action "service moused quietstart $cdev"; +}; + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "wsp[0-9]+"; + + action "service moused quietstart $cdev"; +}; + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "DESTROY"; + match "cdev" "ums[0-9]+"; + + action "service moused stop $cdev"; +}; + +# Don't even try to second guess what to do about drivers that don't +# match here. Instead, pass it off to syslog. Commented out for the +# moment, as the pnpinfo variable isn't set in devd yet. Individual +# variables within the bus supplied pnpinfo are set. +nomatch 0 { +# action "logger Unknown device: $pnpinfo $location $bus"; +}; + +# Various logging of unknown devices. +nomatch 10 { + match "bus" "uhub[0-9]+"; + action "logger Unknown USB device: vendor $vendor product $product \ + bus $bus"; +}; + +# Some Cardbus cards don't offer numerical manufacturer/product IDs, just +# show the CIS info there. +nomatch 10 { + match "bus" "cardbus[0-9]+"; + action "logger Unknown Cardbus device: device $device class $class \ + vendor $vendor bus $bus"; +}; + +# Switch power profiles when the AC line state changes. +notify 10 { + match "system" "ACPI"; + match "subsystem" "ACAD"; + action "service power_profile $notify"; +}; + +# Notify all users before beginning emergency shutdown when we get +# a _CRT or _HOT thermal event and we're going to power down the system +# very soon. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Thermal"; + match "notify" "0xcc"; + action "logger -p kern.emerg WARNING: system temperature too high, shutting down soon!"; +}; + +# User requested suspend, so perform preparation steps and then execute +# the actual suspend process. +notify 10 { + match "system" "ACPI"; + match "subsystem" "Suspend"; + action "/etc/rc.suspend acpi $notify"; +}; +notify 10 { + match "system" "ACPI"; + match "subsystem" "Resume"; + action "/etc/rc.resume acpi $notify"; +}; + +/* EXAMPLES TO END OF FILE + +# Examples of notify hooks. A notify is a generic way for a kernel +# subsystem to send event notification to userland. + +# Here are some examples of ACPI notify handlers. ACPI subsystems that +# generate notifies include the AC adapter, power/sleep buttons, +# control method batteries, lid switch, and thermal zones. +# +# Information returned is not always the same as the ACPI notify +# events. See the ACPI specification for more information about +# notifies. Here is the information returned for each subsystem: +# +# ACAD: AC line state (0 is offline, 1 is online) +# Button: Button pressed (0 for power, 1 for sleep) +# CMBAT: ACPI battery events +# Lid: Lid state (0 is closed, 1 is open) +# Suspend, Resume: Suspend and resume notification +# Thermal: ACPI thermal zone events +# +# This example calls a script when the AC state changes, passing the +# notify value as the first argument. If the state is 0x00, it might +# call some sysctls to implement economy mode. If 0x01, it might set +# the mode to performance. +notify 10 { + match "system" "ACPI"; + match "subsystem" "ACAD"; + action "/etc/acpi_ac $notify"; +}; + +# This example works around a memory leak in PostgreSQL, restarting +# it when the "user:postgres:swap:devctl=1G" rctl(8) rule gets triggered. +notify 0 { + match "system" "RCTL"; + match "rule" "user:770:swap:.*"; + action "service postgresql restart"; +}; + +# Discard autofs caches, useful for the -media special map. +notify 100 { + match "system" "GEOM"; + match "subsystem" "DEV"; + action "/usr/sbin/automount -c"; +}; + +# Handle userland coredumps. +# This commented out handler makes it possible to run an +# automated debugging session after the core dump is generated. +# Replace action with a proper coredump handler, but be aware that +# it will run with elevated privileges. +notify 10 { + match "system" "kernel"; + match "subsystem" "signal"; + match "type" "coredump"; + action "logger $comm $core"; +}; + +# Let the init(8) know there's a new USB serial interface it might +# want to run getty(8) for. This includes device-side tty created +# by usb_template(4). +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "ttyU[0-9]+"; + action "/sbin/init q"; +}; + +*/ diff --git a/etc/gettytab b/etc/gettytab new file mode 100644 index 0000000..545a1f7 --- /dev/null +++ b/etc/gettytab @@ -0,0 +1,243 @@ +# $FreeBSD$ +# from: @(#)gettytab 5.14 (Berkeley) 3/27/91 +# +# Most of the table entries here are just copies of the old getty table, +# it is by no means certain, or even likely, that any of them are optimal +# for any purpose whatever. Nor is it likely that more than a couple are +# even correct. +# +# The default gettytab entry, used to set defaults for all other +# entries, and in cases where getty is called with no table name. +# +# cb, ce and ck are desirable on most crt's. The non-crt entries need to +# be changed to turn them off (:cb@:ce@:ck@:). +# +# lc should always be on; it's a remainder of some stone age when there +# have been terminals around not being able of handling lower-case +# characters. Those terminals aren't supported any longer, but getty is +# `smart' about them by default. +# +# Parity defaults to even, but the Pc entry and all the `std' entries +# specify no parity. The different parities are: +# (none): same as ep for getty. login will use terminal as is. +# ep: getty will use raw mode (cs8 -parenb) (unless rw is set) and +# fake parity. login will use even parity (cs7 parenb -parodd). +# op: same as ep except odd parity (cs7 parenb parodd) for login. +# getty will fake odd parity as well. +# ap: same as ep except -inpck instead of inpck for login. +# ap overrides op and ep. +# np: 1. don't fake parity in getty. The fake parity garbles +# characters on non-terminals (like pccons) that don't +# support parity. It would probably better for getty not to +# try to fake parity. It could just use cbreak mode so as +# not to force cs8 and let the hardware handle the parity. +# login has to be rely on the hardware anyway. +# 2. set cs8 -parenb -istrip -inpck. +# ep:op: same as ap. +# +default:\ + :cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:\ + :if=/etc/issue: + +# +# Fixed speed entries +# +# The "std.NNN" names are known to the special case +# portselector code in getty, however they can +# be assigned to any table desired. +# The "NNN-baud" names are known to the special case +# autobaud code in getty, and likewise can +# be assigned to any table desired (hopefully the same speed). +# +std:\ + :np:sp#0: +a|std.110|110-baud:\ + :np:nd#1:cd#1:uc:sp#110: +b|std.134|134.5-baud:\ + :np:nd#1:cd#2:ff#1:td#1:sp#134:ht:nl: +1|std.150|150-baud:\ + :np:nd#1:cd#2:td#1:fd#1:sp#150:ht:nl:lm=\E\72\6\6\17login\72 : +c|std.300|300-baud:\ + :np:nd#1:cd#1:sp#300: +d|std.600|600-baud:\ + :np:nd#1:cd#1:sp#600: +f|std.1200|1200-baud:\ + :np:fd#1:sp#1200: +6|std.2400|2400-baud:\ + :np:sp#2400: +7|std.4800|4800-baud:\ + :np:sp#4800: +2|std.9600|9600-baud:\ + :np:sp#9600: +g|std.19200|19200-baud:\ + :np:sp#19200: +std.38400|38400-baud:\ + :np:sp#38400: +std.57600|57600-baud:\ + :np:sp#57600: +std.115200|115200-baud:\ + :np:sp#115200: +std.230400|230400-baud:\ + :np:sp#230400: + +# +# Entry specifying explicit device settings. See termios(4) and +# /usr/include/termios.h, too. The entry forces the tty into +# CLOCAL mode (so no DCD is required), and uses Xon/Xoff flow control. +# +# cflags: CLOCAL | HUPCL | CREAD | CS8 +# oflags: OPOST | ONLCR | OXTABS +# iflags: IXOFF | IXON | ICRNL | IGNPAR +# lflags: IEXTEN | ICANON | ISIG | ECHOCTL | ECHO | ECHOK | ECHOE | ECHOKE +# +# The `0' flags don't have input enabled. The `1' flags don't echo. +# (Echoing is done inside getty itself.) +# +local.9600|CLOCAL tty @ 9600 Bd:\ + :c0#0x0000c300:c1#0x0000cb00:c2#0x0000cb00:\ + :o0#0x00000007:o1#0x00000002:o2#0x00000007:\ + :i0#0x00000704:i1#0x00000000:i2#0x00000704:\ + :l0#0x000005cf:l1#0x00000000:l2#0x000005cf:\ + :sp#9600:np: + +# +# Dial in rotary tables, speed selection via 'break' +# +0|d300|Dial-300:\ + :nx=d1200:cd#2:sp#300: +d1200|Dial-1200:\ + :nx=d150:fd#1:sp#1200: +d150|Dial-150:\ + :nx=d110:lm@:tc=150-baud: +d110|Dial-110:\ + :nx=d300:tc=300-baud: + +# +# Fast dialup terminals, 2400/1200/300 rotary (can start either way) +# +D2400|d2400|Fast-Dial-2400:\ + :nx=D1200:tc=2400-baud: +3|D1200|Fast-Dial-1200:\ + :nx=D300:tc=1200-baud: +5|D300|Fast-Dial-300:\ + :nx=D2400:tc=300-baud: + +# +#telebit (19200) +# +t19200:\ + :nx=t2400:tc=19200-baud: +t2400:\ + :nx=t1200:tc=2400-baud: +t1200:\ + :nx=t19200:tc=1200-baud: + +# +#telebit (9600) +# +t9600:\ + :nx=t2400a:tc=9600-baud: +t2400a:\ + :nx=t1200a:tc=2400-baud: +t1200a:\ + :nx=t9600:tc=1200-baud: + +# +# Odd special case terminals +# +-|tty33|asr33|Pity the poor user of this beast:\ + :tc=110-baud: + +4|Console|Console Decwriter II:\ + :nd@:cd@:rw:tc=300-baud: + +e|Console-1200|Console Decwriter III:\ + :fd@:nd@:cd@:rw:tc=1200-baud: + +i|Interdata console:\ + :uc:sp#0: + +l|lsi chess terminal:\ + :sp#300: + +X|Xwindow|X window system:\ + :fd@:nd@:cd@:rw:sp#9600: + +P|Pc|Pc console:\ + :ht:np:sp#9600: + +# +# Weirdo special case for fast crt's with hardcopy devices +# +8|T9600|CRT with hardcopy:\ + :nx=T300:tc=9600-baud: +9|T300|CRT with hardcopy (300):\ + :nx=T9600:tc=300-baud: + +# +# Plugboard, and misc other terminals +# +plug-9600|Plugboard-9600:\ + :pf#1:tc=9600-baud: +p|P9600|Plugboard-9600-rotary:\ + :pf#1:nx=P300:tc=9600-baud: +q|P300|Plugboard-300:\ + :pf#1:nx=P1200:tc=300-baud: +r|P1200|Plugboard-1200:\ + :pf#1:nx=P9600:tc=1200-baud: + +# +# XXXX Port selector +# +s|DSW|Port Selector:\ + :ps:sp#2400: + +# +# Auto-baud speed detect entry for Micom 600. +# Special code in getty will switch this out +# to one of the NNN-baud entries. +# +A|Auto-baud:\ + :ab:sp#2400:f0#040: + +# +# autologin - automatically log in as root +# + +autologin|al.9600:\ + :al=root:tc=std.9600: +al.19200:\ + :al=root:tc=std.19200: +al.38400:\ + :al=root:tc=std.38400: +al.57600:\ + :al=root:tc=std.57600: +al.115200:\ + :al=root:tc=std.115200: +al.230400:\ + :al=root:tc=std.230400: +al.Pc:\ + :al=root:tc=Pc + +# +# Entries for 3-wire serial terminals. These don't supply carrier, so +# clocal needs to be set, and crtscts needs to be unset. +# +3wire:\ + :np:nc:sp#0: +3wire.9600|9600-3wire:\ + :np:nc:sp#9600: +3wire.19200|19200-3wire:\ + :np:nc:sp#19200: +3wire.38400|38400-3wire:\ + :np:nc:sp#38400: +3wire.57600|57600-3wire:\ + :np:nc:sp#57600: +3wire.115200|115200-3wire:\ + :np:nc:sp#115200: +3wire.230400|230400-3wire:\ + :np:nc:sp#230400: + +Ly:\ + :lo=/usr/local/bin/ly:\ + :al=root: diff --git a/etc/rc.conf b/etc/rc.conf new file mode 100644 index 0000000..7e2e7dd --- /dev/null +++ b/etc/rc.conf @@ -0,0 +1,14 @@ +hostname="x260.oxcrag.net" +keymap="se.kbd" +wlans_iwm0="wlan0" +ifconfig_wlan0="WPA DHCP" +ifconfig_wlan0_ipv6="inet6 accept_rtadv" +moused_enable="YES" +ntpd_enable="YES" +powerd_enable="YES" +# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable +dumpdev="NO" +devd_enable="YES" +seatd_enable="YES" +dbus_enable="YES" +kld_list=i915kms diff --git a/etc/sysctl.conf b/etc/sysctl.conf new file mode 100644 index 0000000..4d2385a --- /dev/null +++ b/etc/sysctl.conf @@ -0,0 +1,15 @@ +# $FreeBSD$ +# +# This file is read when going to multi-user and its contents piped thru +# ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details. +# + +# Uncomment this to prevent users from seeing information about processes that +# are being run under another UID. +#security.bsd.see_other_uids=0 +# dev.acpi_ibm.0.handlerevents=0x04\ 0x10\ 0x11 +# dev.acpi_ibm.0.handlerevents=1 +hw.acpi.lid_switch_state=s3 +hw.usb.no_suspend_wait=1 +kern.vt.suspendswitch=0 +kern.vt.deadtimer=60 diff --git a/etc/ttys b/etc/ttys new file mode 100644 index 0000000..8ba20d9 --- /dev/null +++ b/etc/ttys @@ -0,0 +1,53 @@ +# +# $FreeBSD$ +# @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# This file specifies various information about terminals on the system. +# It is used by several different programs. Common entries for the +# various columns include: +# +# name The name of the terminal device. +# +# getty The program to start running on the terminal. Typically a +# getty program, as the name implies. Other common entries +# include none, when no getty is needed, and xdm, to start the +# X Window System. +# +# type The initial terminal type for this port. For hardwired +# terminal lines, this will contain the type of terminal used. +# For virtual consoles, the correct type is typically xterm. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. +# +# status Must be on or off. If on, init will run the getty program on +# the specified port. If the word "secure" appears, this tty +# allows root login. +# +# name getty type status comments +# +# If console is marked "insecure", then init will ask for the root password +# when going to single-user mode. +console none unknown off secure +# +ttyv0 "/usr/libexec/getty Pc" xterm onifexists secure +# Virtual terminals +ttyv1 "/usr/libexec/getty Ly" xterm on secure +ttyv2 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv3 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv4 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv5 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv6 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv7 "/usr/libexec/getty Pc" xterm onifexists secure +ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure +# Serial terminals +# The 'dialup' keyword identifies dialin lines to login, fingerd etc. +ttyu0 "/usr/libexec/getty 3wire" vt100 onifconsole secure +ttyu1 "/usr/libexec/getty 3wire" vt100 onifconsole secure +ttyu2 "/usr/libexec/getty 3wire" vt100 onifconsole secure +ttyu3 "/usr/libexec/getty 3wire" vt100 onifconsole secure +# Dumb console +dcons "/usr/libexec/getty std.9600" vt100 off secure +# Xen Virtual console +xc0 "/usr/libexec/getty Pc" xterm onifconsole secure +# RISC-V HTIF console +rcons "/usr/libexec/getty std.9600" vt100 onifconsole secure diff --git a/homedir/.profile b/homedir/.profile new file mode 100644 index 0000000..1152449 --- /dev/null +++ b/homedir/.profile @@ -0,0 +1,34 @@ +# $FreeBSD$ +# +# .profile - Bourne Shell startup script for login shells +# +# see also sh(1), environ(7). +# + +# These are normally set through /etc/login.conf. You may override them here +# if wanted. +# PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH + +# Setting TERM is normally done through /etc/ttys. Do only override +# if you're sure that you'll never log in via telnet or xterm or a +# serial line. +# TERM=xterm; export TERM + +EDITOR=vim; export EDITOR +PAGER=less; export PAGER + +# set ENV to a file invoked each time sh is started for interactive use. +ENV=$HOME/.shrc; export ENV + +# Let sh(1) know it's at home, despite /home being a symlink. +if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi + +# Query terminal size; useful for serial lines. +if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi + +# Display a random cookie on each login. +if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi + +# XDG_RUNTIME_DIR is required for Wayland. Don't forget to create user dirs +# and set the ownership for each respective user. +export XDG_RUNTIME_DIR=/var/run/user/`id -u` diff --git a/homedir/.zshrc b/homedir/.zshrc new file mode 100644 index 0000000..e8f39aa --- /dev/null +++ b/homedir/.zshrc @@ -0,0 +1,6 @@ +# I've been trying Starship to provide a richer command prompt for zsh. +eval "$(starship init zsh)" +# The XDG_RUNTIME_DIR is required for Wayland to work. +# Don't forget to actually create the directory for each relevant user and +# give them ownership of their respective directories. +export XDG_RUNTIME_DIR=/var/run/user/`id -u` diff --git a/usr/local/sbin/acpi_oem_exec.sh b/usr/local/sbin/acpi_oem_exec.sh new file mode 100644 index 0000000..dcddbc8 --- /dev/null +++ b/usr/local/sbin/acpi_oem_exec.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# +if [ "$1" = "" -o "$2" = "" ] +then + echo "usage: $0 notify oem_name" + exit 1 +fi +NOTIFY=`echo $1` +LOGGER="logger" +CALC="bc" +BC_PRECOMMANDS="scale=2" +ECHO="echo" +CUT="cut" +MAX_LCD_BRIGHTNESS=7 +MAX_VOLUME=14 +OEM=$2 +DISPLAY_PIPE=/tmp/acpi_${OEM}_display + +case ${NOTIFY} in +# 0x05) +# LEVEL=`sysctl -n dev.acpi_${OEM}.0.bluetooth` +# if [ "$LEVEL" = "1" ] +# then +# sysctl dev.acpi_${OEM}.0.bluetooth=0 +# MESSAGE="bluetooth disabled" +# else +# sysctl dev.acpi_${OEM}.0.bluetooth=1 +# MESSAGE="bluetooth enabled" +# fi +# ;; + 0x11|0x10) + LEVEL=`sysctl -n dev.acpi_${OEM}.0.lcd_brightness` + PERCENT=`${ECHO} "${BC_PRECOMMANDS} ; \ + ${LEVEL} / ${MAX_LCD_BRIGHTNESS} * 100" |\ + ${CALC} | ${CUT} -d . -f 1` + MESSAGE="brightness level ${PERCENT}%" + ;; +# 0x12) +# LEVEL=`sysctl -n dev.acpi_${OEM}.0.thinklight` +# if [ "$LEVEL" = "1" ] +# then +# MESSAGE="thinklight enabled" +# else +# MESSAGE="thinklight disabled" +# fi +# ;; + 0x03|0x02) + LEVEL=`sysctl -n dev.acpi_${OEM}.0.volume` + PERCENT=`${ECHO} "${BC_PRECOMMANDS} ; \ + ${LEVEL} / ${MAX_VOLUME} * 100" | \ + ${CALC} | ${CUT} -d . -f 1` + MESSAGE="volume level ${PERCENT}%" + ;; + 0x01) + LEVEL=`sysctl -n dev.acpi_${OEM}.0.mute` + if [ "$LEVEL" = "1" ] + then + MESSAGE="volume muted" + else + MESSAGE="volume unmuted" + fi + ;; + 0x04) + LEVEL=`sysctl -n dev.acpi_ibm.0.mic_led` + if [ $LEVEL -eq 0 ]; then + sysctl dev.acpi_ibm.0.mic_led=1 + mixer rec 0 + fi + if [ $LEVEL -eq 1 ]; then + sysctl dev.acpi_ibm.0.mic_led=0 + mixer rec 30 + fi + ;; + *) + ;; +esac +${LOGGER} ${MESSAGE} +if [ -p ${DISPLAY_PIPE} ] +then + ${ECHO} ${MESSAGE} >> ${DISPLAY_PIPE} & +fi +exit 0