3 CONSOLE_NUMBER
=$
(fgconsole
)
6 if [ -S /tmp
/.X11-unix
/X0
]; then
8 user
=$
(who |
sed -n '/ (:0[\.0]*)$\| :0 /{s/ .*//p;q}')
9 # If autodetection fails, fallback to default user
10 # set in /etc/conf.d/acpi-eeepc-generic.conf
11 [ "x$user" == "x" ] && user
=$XUSER
12 home
=$
(getent passwd
$user | cut
-d: -f6)
13 XAUTHORITY
=$home/.Xauthority
14 if [[ -f $XAUTHORITY ]]; then
19 function eeepc_notify
{
20 /bin
/su
$XUSER --login -c "/usr/bin/notify-send -i $2 -t 1500 \"EeePC $EEEPC_MODEL\" \"$1\""
21 #/usr/bin/notify-send -i $2 -t 1500 "EeePC $EEEPC_MODEL" "$1"
22 logger
"EeePC $EEEPC_MODEL: $1 ($2)"
25 function execute_commands
() {
28 logger
"execute_commands = $cmds ($cmds_num)"
29 for ((i
=0;i
<${cmds_num};i
++)); do
31 logger
"execute_commands #$i: $c"
32 echo "execute_commands #$i: $c"
36 function execute_commands_as_user
() {
39 logger
"execute_commands_as_user = $cmds ($cmds_num)"
40 for ((i
=0;i
<${cmds_num};i
++)); do
42 logger
"execute_commands_as_user #$i: $c"
43 echo "execute_commands_as_user #$i: $c"
44 su
$XUSER --login -c "${c} &"
48 function volume_is_mute
() {
49 # 0 is true, 1 is false
50 on_off
=`amixer get iSpeaker | grep -A 1 -e Mono | grep Playback | awk '{print ""$4""}'`
52 [ "$on_off" == "[off]" ] && is_muted
=0
56 function get_volume
() {
57 echo `amixer get PCM | grep -A 1 -e Mono | grep Playback | awk '{print ""$5""}' | sed -e "s|\[||g" -e "s|]||g" -e "s|\%||g"`
60 function get_model
() {
61 (grep EEEPC_MODEL
/etc
/conf.d
/acpi-eeepc-generic.conf
>/dev
/null
2>&1) ||
echo "EEEPC_MODEL=$(dmidecode -s system-product-name)" >> /etc
/conf.d
/acpi-eeepc-generic.conf
62 (grep EEEPC_CPU
/etc
/conf.d
/acpi-eeepc-generic.conf
>/dev
/null
2>&1) ||
echo "EEEPC_CPU=`((grep Celeron /proc/cpuinfo >/dev/null 2>&1) && echo Celeron) || echo Atom`" >> /etc
/conf.d
/acpi-eeepc-generic.conf
65 function brightness_get_percentage
() {
66 actual_brightness
=`cat /sys/class/backlight/eeepc/actual_brightness`
67 maximum_brightness
=`cat /sys/class/backlight/eeepc/max_brightness`
68 echo $
((10000*$actual_brightness / (100*$maximum_brightness) ))
71 function brightness_find_direction
() {
72 actual_brightness
=`cat /sys/class/backlight/eeepc/actual_brightness`
73 previous_brightness
=`cat /var/eeepc/brightness_saved`
74 [ "x$previous_brightness" == "x" ] && previous_brightness
=$actual_brightness
76 [ $actual_brightness -lt $previous_brightness ] && to_return
="down"
77 echo $actual_brightness > /var
/eeepc
/brightness_saved