Merubah Resolusi Layar Backtrack 5 Di Netbook
#22
(02-01-2012, 02:09 PM)konspirasi Wrote: boleh liat isi di dalem skrip newrez nya ga?

ni om scriptnya newrez :p
Code:
#!/bin/bash

# Marc Brumlik, Tailored Software Inc, [email protected]
# Mon Nov  8 18:34:40 CST 2010

# newrez v 0.8
# actually the same as 0.7, but bundled with newrez-v

# use xrandr to scale the display to a new resolution

umask 000

# we MUST be running xrandr 1.3 or higher
if xrandr -v | grep "RandR version 1.[012]"
    then    zenity --info --title="XRandR version is too old" --text="You must be running Xrandr
version 1.3 or newer!
Time to upgrade your system  :-)"
        exit 0
fi

# find the currently connected devices, make a list
devices=`xrandr -q | grep connected | grep -v disconnected | cut -d"(" -f1`

# if there is more than one, ask user which to change
case `echo "$devices" | wc -l` in
    1)    device=`echo $devices| cut -d" " -f1` ;;
    *)    devices=`echo "$devices" | sed -e 's/ /_/g' -e 's/^/FALSE /'`
        while true
        do
        device=`zenity --list --radiolist --title="Choose Device" --text="Which device do you\nwant to change" --column Select --column Device $devices` || exit 0
        device=`echo $device | cut -d"_" -f1`
        [ -z "$device" ] || break
        done ;;
esac

case $device in
    default)    zenity --info --title="Video Driver Issue" --text="
Cannot scale your video output!

Though your installed xrandr version is current
your video driver does not support the 1.3.x
options.  It is possible that switching to a
different driver would have this support."; exit 0 ;;
esac

current=`xrandr -q | grep "^$device" | cut -d" " -f3 | cut -d"+" -f1`
default=`xrandr -q | grep -C 1 "^$device" | tail -1 | awk '{print $1}'`
H=`echo $default | cut -d'x' -f1`
V=`echo $default | cut -d'x' -f2`
ratio=`echo -e "scale=2\n$V / $H\nquit" | bc`

echo DEFAULT: $H $V

while true
do
    newrez=`zenity --entry --title="Set New Resolution" --text="Default Resolution: $H"x"$V
Current Resolution: $current

New horizontal width (eg 1280 or 1600)"` || exit 0
    case $newrez in
        [0-9][0-9]*[0-9])    break ;;
    esac
done

scale=`echo -e "scale=2\n$newrez / $H\nquit" | bc`

echo SCALE $scale

H=`echo -e "scale=2\n$H * $scale\nquit" | bc | cut -d"." -f1`
V=`echo -e "scale=2\n$V * $scale\nquit" | bc | cut -d"." -f1`

echo NEW: H V $H $V

if xrandr --fb $H"x"$V --output $device --scale $scale"x"$scale 2>/tmp/xrandr.err
    then    : success
    else    zenity --info --title="Xrandr failed to set new resolution" --text="`cat /tmp/xrandr.err`

The problem could be that
Your video driver does not support version 1.3

Try a different resolution before giving up"
        exit 0
        rm -f /tmp/xrandr.err
fi

echo xrandr --fb $H"x"$V --output $device --scale $scale"x"$scale > ~/newrez-$device-$newrez

paneladds=`locate gnome-panel-add`
for each in "$paneladds"
do
    if file $each | grep "python script" >/dev/null 2>&1
        then    paneladd="$paneladd $each"
    fi
done
gpversion=`gnome-panel --version 2>&1 | awk '{print $3}'`
# "--version" not supported in newer releases
echo $gpversion | grep -y "version" && gpversion="9.99"
echo $gpversion | grep -y "command" && gpversion="0.00"
gpinteger=0`echo $gpversion | cut -c1,3-4`
gmsg=""
if [ "$gpinteger" -lt "0228" ]
    then    gmsg="
Your gnome-panel is version $gpversion
and gnome-panel-add requires 2.28.0"
fi

case `echo $paneladd | wc -w`$gmsg in
    0|*Your*)    zenity --info --title="Create Launcher" --text="
Cannot automatically create launcher icon.
\"gnome-panel-add\" could not be found.
$gmsg"; exit 0 ;;
    1)    zenity --question --title="Create Launcher" --text="Would you like a launcher
icon for the $newrez resolution?" || exit 0 ;;
    *)    zenity --info --title="Create Launcher" --text="
Cannot automatically create launcher icon.
It seems there is more than one python
script named gnome-panel-add on your
system and I do not know which to use"; exit 0 ;;
esac

icon=`find /usr/share/icons -name "*display*" -print | head -1`

echo "
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Newrez
Comment=$device $newrez
Exec=xrandr --fb $H"x"$V --output $device --scale $scale"x"$scale
Icon=$icon
Terminal=false" > ~/newrez-$newrez.desktop

$paneladd --launcher=$HOME/newrez-$newrez.desktop --right-stick
Every Second, Every Minutes, Every Hours, Every Days Its Never End


Messages In This Thread
RE: Merubah Resolusi Layar Backtrack 5 Di Netbook - by ekawithoutyou - 02-10-2012, 02:47 PM




Users browsing this thread: 1 Guest(s)