SZ72B Hotkeys mapping

From MalaWiki

Jump to: navigation, search

Back to Vaio VGN-SZ72B.

#!/bin/sh

. /etc/vaio-sz

WHO=/usr/bin/who
CUT=/usr/bin/cut
GREP=/bin/grep

increase_brightness() {
        x_user=$($WHO -s|$CUT -d\  -f 1,4|$GREP ':0'|$CUT -d\   -f 1)
        if [ "$intel_detected" = "1" ] ; then
                local cur_b=$(/bin/cat /sys/class/backlight/sony/brightness)
                echo $((cur_b + 1)) > /sys/class/backlight/sony/brightness || /bin/true

        elif [ "$nvidia_detected" = "1" ] ; then
                [ -z "$x_user" ] || XAUTHORITY=/home/$x_user/.Xauthority \
                                    DISPLAY=:0.0 /usr/bin/nvclock -S +10 2&>1 >/dev/null;
        fi
}

decrease_brightness() {
        x_user=$($WHO -s|$CUT -d\  -f 1,4|$GREP ':0'|$CUT -d\   -f 1)
        if [ "$intel_detected" = "1" ] ; then
                local cur_b=$(/bin/cat /sys/class/backlight/sony/brightness)
                echo $((cur_b - 1)) > /sys/class/backlight/sony/brightness || /bin/true

        elif [ "$nvidia_detected" = "1" ] ; then
                [ -z "$x_user" ] || XAUTHORITY=/home/$x_user/a.Xauthority \
                                    DISPLAY=:0.0 /usr/bin/nvclock -S -10 2&>1 >/dev/null;
        fi
}

increase_volume() {
        /usr/bin/amixer -q -c 0 set PCM 2dB+
}

decrease_volume() {
        /usr/bin/amixer -q -c 0 set PCM 2dB-
}

toggle_mute() {
        /usr/bin/amixer -q -c 0 set Master toggle
}

suspend2ram() {
        if [ "$intel_detected" = "1" ] ; then
                /usr/sbin/s2ram -f -p -m
        elif [ "$nvidia_detected" = "1" ] ; then
                /usr/sbin/s2ram -f
        fi
}

case "$4" in

        "00000011")
                increase_brightness
                ;;

        "00000010")
                decrease_brightness
                ;;

        "0000000f")
                increase_volume
                ;;

        "0000000e")
                decrease_volume
                ;;

        "0000000d")
                toggle_mute
                ;;

        "00000017")
                suspend2ram
                ;;


        "00000029")
                # fn-key alone
                ;;

        "0000003b")
                # key release
                ;;

        *)
                echo "unmanaged key ($@)";
                exit 1;
esac
Personal tools