シェルスクリプトを実行できません

シェルスクリプトを実行できません

そこで、次のようなスクリプトを用意しました:

#!/bin/bash
# Flips the screen (hopefully)

syntax_error=0
orientation=0

current_orientation="$(xrandr -q --verbose | grep 'connected' | egrep -o  '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"
case $current_orientation in
        normal)
                current_orientation=0
        ;;
        left)
                current_orientation=1
        ;;
        inverted)
                current_orientation=2
        ;;
        right)
                current_orientation=3
        ;;
esac

if [ $current_orientation -eq 0 ]; then
        orientation=2
fi

if [ $current_orientation -eq 2 ]; then
        orientation=0
fi
method=evdev

# LENOVO S10-3t CHANGE ==> Hard Coded my device number to 11!!!!!!!!

device=11

swap=0
invert_x=0
invert_y=0
real_topx=0
real_topy=0
real_bottomx=4020
real_bottomy=4020

case $orientation in
        0)
                swap=0
                invert_x=0
                invert_y=0
                topx=$real_topx
                topy=$real_topy
                bottomx=$real_bottomx
                bottomy=$real_bottomy
        ;;
        1)
                swap=1
                invert_x=1
                invert_y=0
                topx=$real_topx
                topy=$real_topy
                bottomx=$real_bottomy
                bottomy=$real_bottomx
        ;;
        2 )
                swap=0
                invert_x=1
                invert_y=1
                topx=$real_topx
                topy=$real_topy
                bottomx=$real_bottomx
                bottomy=$real_bottomy
        ;;
        3 )
                swap=1
                invert_x=0
                invert_y=1
                topx=$real_topx
                topy=$real_topy
                bottomx=$real_bottomy
                bottomy=$real_bottomx
        ;;
esac

if [ $method = "evdev" ]; then
        xinput set-prop "$device" "Evdev Axes Swap" $swap
        xinput set-prop "$device" "Evdev Axes Swap" $swap
        xinput set-prop "$device" "Evdev Axis Inversion" $invert_x $invert_y
        xinput set-prop "$device" "Evdev Axis Calibration" $topx $bottomx $topy $bottomy
        if [ $orientation = 2 ]; then           
                xrandr -o inverted
        fi
        if [ $orientation = 0 ]; then
                xrandr -o normal
        fi
fi

#

これは、Lenovo S10-3t の画面を反転するためのものです。ネットブックの wiki ページからコピーし、先頭に #!/bin/bash を追加しました。ファイル名は flipscreen.sh です。どうすれば動作させることができますか?

答え1

ファイルを右クリックして、「プロパティ」を選択します。ダイアログで、下の図のように「ファイルをプログラムとして実行することを許可する」にチェックを入れます。次にダイアログを閉じて、ファイルをダブルクリックして実行します。

代替テキスト

答え2

まずファイルを実行可能にする必要があります。

ディレクトリタイプでは、

sudo chmod+x flipscreen.sh

sudo bash flipscreen.sh

答え3

OpenNingia の回答は機能しますが、後で Google で検索する人のために、コマンドラインから実行することもできます。

ターミナルを開き、スクリプトが保存されているフォルダに移動します

chmod +x <yourScript>

それを次のように実行します

./<yourScript>

答え4

ファイルをダブルクリックします。ダイアログ ボックスが表示され、そのファイルは実行可能か、何をしたいか尋ねられます。「実行」をクリックすると、実行できるようになります。

関連情報