X61 on Gentoo
2007-12-11 23:40
Xorg
1. kernel config, CONFIG_DRM_I915=M
2. VIDEO_CARDS="i810" emerge xorg-server
3. xorg.conf
Section "Device"
Identifier "My Video Card out1"
Driver "intel"
Screen 0
VendorName "Intel Corporation"
BoardName "Mobile Integrated Graphics Controller"
BusID "PCI:0:2:0"
EndSection
屏幕亮度调节
1. sysutils
#include <stdio.h>
#include <string.h>
void stripwhite(char *str){
int i;
for (i=strlen(str)-1; i>=0; i--){
if (isspace(str[i])){
str[i] = 0;
}else{
break;
}
}
}
int main(int argc, char *argv){
char buf[1024];
int ret;
while (fgets(buf, sizeof(buf), stdin)){
stripwhite(buf);
if (strcmp(buf, "brightness_up") == 0){
ret = seteuid(0);
ret |= setuid(0);
system("echo up > /proc/acpi/ibm/brightness");
}else if (strcmp(buf, "brightness_down") == 0){
ret = seteuid(0);
ret |= setuid(0);
system("echo down > /proc/acpi/ibm/brightness");
}else{
ret = -1;
printf("unknown command\n");
}
printf("ret = %d\n", ret);
}
return 0;
}
编译后 suid
2. 修改 ~/.xbindkeysrc for xbindkeys
"echo brightness_up | /usr/local/bin/sysutils"
m:0x0 + c:212
NoSymbol
"echo brightness_down | /usr/local/bin/sysutils"
m:0x0 + c:101
NoSymbol
显示器切换(Fn+F7)
1. 需要 xorg-x11 >= 7.3, xorg使用intel的driver
2. xorg.conf
Section "Screen"
Identifier "Screen 1"
Device "My Video Card out1"
Monitor "My Monitor"
DefaultDepth 24
Subsection "Display"
Depth 24
ViewPort 0 0
Virtual 2304 1024
EndSubsection
EndSection
3. x61_fn_f7.sh
#!/bin/bash
# External output may be "VGA" or "VGA-0" or "DVI-0"
EXTERNAL_OUTPUT="VGA"
INTERNAL_OUTPUT="LVDS"
EXTERNAL_LOCATION="left"
export DISPLAY=":0.0"
case "$EXTERNAL_LOCATION" in
left|LEFT)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
right|RIGHT)
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
;;
top|TOP|above|ABOVE)
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
;;
bottom|BOTTOM|below|BELOW)
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
;;
*)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
esac
# Figure out current state
INTERNAL_STATE=$(xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")
EXTERNAL_STATE=$(xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")
if [ -z "$INTERNAL_STATE" ]; then
STATE="external"
elif [ -z "$EXTERNAL_STATE" ]; then
STATE="internal"
else
INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then
STATE="mirror"
else
STATE="both"
fi
fi
function screen_external(){
xrandr --output $INTERNAL_OUTPUT --off
xrandr --output $EXTERNAL_OUTPUT --auto
}
function screen_internal(){
xrandr --output $EXTERNAL_OUTPUT --off
xrandr --output $INTERNAL_OUTPUT --auto
}
function screen_mirror(){
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT
}
function screen_both(){
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
}
function screen_toggle(){
case "$STATE" in
internal)
screen_mirror
;;
mirror)
screen_external
;;
external)
screen_both
;;
both)
screen_internal
;;
*)
screen_internal
;;
esac
}
# What should we do?
DO="$1"
if [ -z "$DO" ]; then
if [ $(basename $0) = "thinkpad-fn-f7" ]; then
DO="toggle"
fi
fi
case "$DO" in
toggle)
screen_toggle
;;
internal)
screen_internal
;;
external)
screen_external
;;
mirror)
screen_mirror
;;
both)
screen_both
;;
status)
echo "Current Fn-F7 state is: $STATE"
echo
echo "Attached monitors:"
xrandr | grep "\Wconnected" | sed "s/^/ /"
;;
*)
echo "usage: $0 <command>" >&2
echo >&2
echo " commands:" >&2
echo " status" >&2
echo " internal" >&2
echo " external" >&2
echo " mirror" >&2
echo " both" >&2
echo " toggle" >&2
echo >&2
;;
esac
4. xbindkey.rc
"~/bin/x61_fn_f7.sh toggle"
m:0x0 + c:214
NoSymbol
黑屏
1. 自动黑屏
xorg.conf:
Section "Monitor"
... ...
Option "DPMS" "on"
Option "StandbyTime" "20"
Option "SuspendTime" "30"
Option "OffTime" "40"
EndSection
2. 收到黑屏
$ xset dpms force standby
Wireless (Intel 4965AG)
1. kernel module: mac80211 (CONFIG_MAC80211)
2. emerge iwlwifi
可能需要修改ACCEPT_KEYWORDS和/usr/portage/profiles/package.mask
TrackPoint
trackpoint will work fine in gentoo by the following steps:
1.enable "press to select"
2. to enable scrolling,put the following lines into xorg.conf's trackpoint section(it's an "InputDevice" section)
now restart X,and enjoy the trackpoint.
禁用firefox里的滚动键Move back/forward in history
mousewheel.horizscroll.withnokey.action = 0
TODO
待机
电池管理?
硬盘振动检测?
1. kernel config, CONFIG_DRM_I915=M
2. VIDEO_CARDS="i810" emerge xorg-server
3. xorg.conf
Section "Device"
Identifier "My Video Card out1"
Driver "intel"
Screen 0
VendorName "Intel Corporation"
BoardName "Mobile Integrated Graphics Controller"
BusID "PCI:0:2:0"
EndSection
屏幕亮度调节
1. sysutils
#include <stdio.h>
#include <string.h>
void stripwhite(char *str){
int i;
for (i=strlen(str)-1; i>=0; i--){
if (isspace(str[i])){
str[i] = 0;
}else{
break;
}
}
}
int main(int argc, char *argv){
char buf[1024];
int ret;
while (fgets(buf, sizeof(buf), stdin)){
stripwhite(buf);
if (strcmp(buf, "brightness_up") == 0){
ret = seteuid(0);
ret |= setuid(0);
system("echo up > /proc/acpi/ibm/brightness");
}else if (strcmp(buf, "brightness_down") == 0){
ret = seteuid(0);
ret |= setuid(0);
system("echo down > /proc/acpi/ibm/brightness");
}else{
ret = -1;
printf("unknown command\n");
}
printf("ret = %d\n", ret);
}
return 0;
}
编译后 suid
2. 修改 ~/.xbindkeysrc for xbindkeys
"echo brightness_up | /usr/local/bin/sysutils"
m:0x0 + c:212
NoSymbol
"echo brightness_down | /usr/local/bin/sysutils"
m:0x0 + c:101
NoSymbol
显示器切换(Fn+F7)
1. 需要 xorg-x11 >= 7.3, xorg使用intel的driver
2. xorg.conf
Section "Screen"
Identifier "Screen 1"
Device "My Video Card out1"
Monitor "My Monitor"
DefaultDepth 24
Subsection "Display"
Depth 24
ViewPort 0 0
Virtual 2304 1024
EndSubsection
EndSection
3. x61_fn_f7.sh
#!/bin/bash
# External output may be "VGA" or "VGA-0" or "DVI-0"
EXTERNAL_OUTPUT="VGA"
INTERNAL_OUTPUT="LVDS"
EXTERNAL_LOCATION="left"
export DISPLAY=":0.0"
case "$EXTERNAL_LOCATION" in
left|LEFT)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
right|RIGHT)
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
;;
top|TOP|above|ABOVE)
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
;;
bottom|BOTTOM|below|BELOW)
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
;;
*)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
esac
# Figure out current state
INTERNAL_STATE=$(xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")
EXTERNAL_STATE=$(xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")
if [ -z "$INTERNAL_STATE" ]; then
STATE="external"
elif [ -z "$EXTERNAL_STATE" ]; then
STATE="internal"
else
INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")
if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then
STATE="mirror"
else
STATE="both"
fi
fi
function screen_external(){
xrandr --output $INTERNAL_OUTPUT --off
xrandr --output $EXTERNAL_OUTPUT --auto
}
function screen_internal(){
xrandr --output $EXTERNAL_OUTPUT --off
xrandr --output $INTERNAL_OUTPUT --auto
}
function screen_mirror(){
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT
}
function screen_both(){
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
}
function screen_toggle(){
case "$STATE" in
internal)
screen_mirror
;;
mirror)
screen_external
;;
external)
screen_both
;;
both)
screen_internal
;;
*)
screen_internal
;;
esac
}
# What should we do?
DO="$1"
if [ -z "$DO" ]; then
if [ $(basename $0) = "thinkpad-fn-f7" ]; then
DO="toggle"
fi
fi
case "$DO" in
toggle)
screen_toggle
;;
internal)
screen_internal
;;
external)
screen_external
;;
mirror)
screen_mirror
;;
both)
screen_both
;;
status)
echo "Current Fn-F7 state is: $STATE"
echo
echo "Attached monitors:"
xrandr | grep "\Wconnected" | sed "s/^/ /"
;;
*)
echo "usage: $0 <command>" >&2
echo >&2
echo " commands:" >&2
echo " status" >&2
echo " internal" >&2
echo " external" >&2
echo " mirror" >&2
echo " both" >&2
echo " toggle" >&2
echo >&2
;;
esac
4. xbindkey.rc
"~/bin/x61_fn_f7.sh toggle"
m:0x0 + c:214
NoSymbol
黑屏
1. 自动黑屏
xorg.conf:
Section "Monitor"
... ...
Option "DPMS" "on"
Option "StandbyTime" "20"
Option "SuspendTime" "30"
Option "OffTime" "40"
EndSection
2. 收到黑屏
$ xset dpms force standby
Wireless (Intel 4965AG)
1. kernel module: mac80211 (CONFIG_MAC80211)
2. emerge iwlwifi
可能需要修改ACCEPT_KEYWORDS和/usr/portage/profiles/package.mask
TrackPoint
trackpoint will work fine in gentoo by the following steps:
1.enable "press to select"
echo -n 1 > /sys/devices/platform/i8042/serio1/press_to_select
2. to enable scrolling,put the following lines into xorg.conf's trackpoint section(it's an "InputDevice" section)
Option "Emulate3Buttons" "on"
Option "Emulate3TimeOut" "50"
Option "EmulateWheel" "on"
Option "EmulateWheelTimeOut" "200"
Option "EmulateWheelButton" "2"
Option "YAxisMapping" "4 5"
Option "XAxisMapping" "6 7"
Option "ZAxisMapping" "4 5"
now restart X,and enjoy the trackpoint.
禁用firefox里的滚动键Move back/forward in history
mousewheel.horizscroll.withnokey.action = 0
TODO
待机
电池管理?
硬盘振动检测?
没有评论:
发表评论