デュアルモニタのFedora14の主モニタ上部パネルに置きたいのですが
そのスイッチをシェルスクリプトのランチャによって実現したい
と思っています
[root@fx8120 音楽]# xrandr
Screen 0: minimum 320 x 200, current 3360 x 1080, maximum 8192 x 8192
VGA-0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 410mm x 257mm
1280x1024 75.0 60.0
1440x900 75.0* 60.1
1280x960 60.0
1152x921 76.0
1280x800 74.9 59.8
1152x864 75.0
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 72.8 75.0 66.7 60.0
720x400 70.1
HDMI-0 connected 1920x1080+1440+0 (normal left inverted right x axis y axis) 597mm x 336mm
1920x1080 60.0*+
1680x1050 60.0
1600x900 60.0
1280x1024 75.0 60.0
1280x960 75.0
1360x768 59.8
1152x864 75.0
1280x720 60.0
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
720x480 59.9
640x480 72.8 75.0 66.7 60.0
720x400 70.1
[root@fx8120 音楽]#
ですから
主モニタがVGA-0のときには
xrandr --output HDMI-0 --primary
を実行し
主モニタがHDMI-0のときには
xrandr --output VGA-0 --primary
を実行する様にシェルスクリプトを組めばよいのですが
現在主モニタがどちらであるかを知るコマンドが分からなければなりません
どうしたら現在の主モニタを知ることができるでしょうか?
とりあえず今は以下のようにしています
my-monitor:
#!/bin/sh
n=`xrandr|grep -c connected`
if [ $n -ne 2 ]
then
exit
fi
monitor1=`xrandr|grep connected|sed -e "s/ .*//"|sed -e 2d`
monitor2=`xrandr|grep connected|sed -e "s/ .*//"|sed -e 1d`
if [ -e my-toggle ]
then
xrandr --output $monitor1 --primary
rm -f my-toggle
else
xrandr --output $monitor2 --primary
touch my-toggle
fi
よろしくお願いします
No.1ベストアンサー
- 回答日時:
環境変数か、識別用のファイルを作っておいて、随時書き換えでできるとは思います。
ただ、最初に起動する時に、適切に設定しないと機能しませんね。
下手すると、OS再起動後に、識別ファイルが逆になっちゃうこともありそうです。
この回答への補足
回答ありがとうございます
ご指摘の点を考慮して
ログイン時処理スクリプトとトグルスイッチを以下の様にしました
/root/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
export PATH
#追加分#
rm -f my-toggle
monitor=`xrandr|grep connected|sed -n 1p|sed "s/ .*//"`
xrandr --output $monitor --primary
/root/my-monitor:
#!/bin/sh
n=`xrandr|grep -c connected`
if [ $n -ne 2 ]
then
exit
fi
monitor1=`xrandr|grep connected|sed -n 1p|sed "s/ .*//"`
monitor2=`xrandr|grep connected|sed -n 2p|sed "s/ .*//"`
if [ -e my-toggle ]
then
xrandr --output $monitor1 --primary
rm -f my-toggle
else
xrandr --output $monitor2 --primary
touch my-toggle
fi
最終的には以下の様にしました
/root/.bash_profile:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
export PATH
#今回追加分#
rm -f my-toggle
if [ `xrandr|grep -c connected` -ne 0 ]
then
monitor=`xrandr|grep connected|sed -n 1p|sed "s/ .*//"`
xrandr --output $monitor --primary
fi
/root/my-monitor:
#!/bin/sh
if [ `xrandr|grep -c connected` -eq 2 ]
then
if [ -e my-toggle ]
then
rm -f my-toggle
monitor=`xrandr|grep connected|sed -n 1p|sed "s/ .*//"`
else
touch my-toggle
monitor=`xrandr|grep connected|sed -n 2p|sed "s/ .*//"`
fi
xrandr --output $monitor --primary
fi
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- ビデオカード・サウンドカード プロジェクタに背景しか映らない 2 2023/01/14 07:14
- UNIX・Linux プロジェクタに背景しか映らない 1 2023/01/15 03:04
- ビデオカード・サウンドカード ASUSマザー、グラボ2枚刺しで4モニタに制約がある?少し腑に落ちない事象発生・・・ 4 2022/07/21 19:02
- モニター・ディスプレイ 2017年にBenQ モニター ディスプレイ GW2265HM 21.5インチうつりません 5 2022/11/12 20:04
- モニター・ディスプレイ DisplayPortをHDMIに変換したらどっちの仕様になりますか? 3 2022/09/08 20:22
- 数学 ハイネボレルの被覆定理、内田伏一著 「集合と位相」定理22.1 1 2022/07/07 10:49
- モニター・ディスプレイ DELL S2422HZ-R(WEBカメラ内蔵)のモニタをご存じの方。 4 2022/10/08 21:16
- 数学 場合の数、確率 45 (浜松医科大学) 1 2023/07/29 13:52
- モニター・ディスプレイ マルチモニタでのカーソルの動き方 1 2022/06/15 14:59
- iPad iPadの画面をミラーリングする方法? 6 2023/08/25 15:50
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
スクリプトのエラー「unexpecte...
-
bashでシングルクォート内の変...
-
Linux 月を英語表示したい
-
crontabでjavaだけが上手く動い...
-
apachectl start command not f...
-
cronで実行できない
-
cronでifconfigコマンドを使用...
-
シェルスクリプト実行で”そのよ...
-
crontabでsql/plusの起動
-
ldapaddコマンドでエラー
-
sudoでNOPASSWDとしてもパスワ...
-
cgiのcron設定について(コアサ...
-
hp-uxで時間(時計)を合...
-
【UNIX】unzip がcron で作動し...
-
Bシェルで文字列が日付として正...
-
自動パスワード入力でscpするス...
-
CRONを使ってshファイルの書き...
-
主モニタと副モニタを切り替え...
-
bad interpreterで、シェルが使...
-
お教えください:TOMCATの起動...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
スクリプトのエラー「unexpecte...
-
bashでシングルクォート内の変...
-
シェルスクリプト実行で”そのよ...
-
Linux 月を英語表示したい
-
ロケールをutf8からsjisにする...
-
crontabでsql/plusの起動
-
自動パスワード入力でscpするス...
-
apachectl start command not f...
-
Linuxでシェルスクリプトがフル...
-
cron(javaプログラム)からroot...
-
シェルスクリプトで$RANDOMの値...
-
Linuxで自作バッチファイルの置...
-
cronの@rebootでのdateコマンド...
-
ログイン時にエラーメッセージ...
-
bad interpreterで、シェルが使...
-
mekeコマンド
-
Cronジョブの終了時刻を簡単に...
-
sudoでNOPASSWDとしてもパスワ...
-
/usr/local/bin/rubyを実行する...
-
Bシェルで文字列が日付として正...
おすすめ情報