新しい端末を開くキーボードショートカットがこのデスクトップに存在しない場合。それ以外の場合は、現在に集中してください。

新しい端末を開くキーボードショートカットがこのデスクトップに存在しない場合。それ以外の場合は、現在に集中してください。

現在デスクトップにまだ存在していない場合にのみ、新しいターミナルウィンドウを開くキーボードショートカットを作成したいと思います。そうでなければ、現在存在することが中心になります。私はFedora 24からFedora 25にアップグレードしました。アップグレードする前に、次のスクリプトを次にバインドしましたctrl-alt-t

desktop="$(xdotool get_desktop)" # Get number of current desktop

#Check if there is an open terminal on the current desktop. 
output="$(xdotool search --onlyvisible --class --desktop $desktop gnome-terminal)" 

if [[ -n "$output" ]] 
then xdotool windowactivate $output #If there is, then move focus to it. 
else gnome-terminal &  #Otherwise, open a new terminal. 
fi

しかし、更新によってスクリプトが破損し、正常に動作しなくなったようです。既存の端末があるかどうかにかかわらず、常に新しい端末が開きます。テストでこのライナーを実行してみましたdesktop="$(xdotool get_desktop)" && for i in $(xdotool search --desktop $desktop --class ".*"); do xdotool getwindowname $i; done。当然、出力には既存の端末ウィンドウの名前は含まれません。問題は、xdotoolFedora 25ではgnome-terminalが認識されなくなったため、上記のスクリプトは常に新しい端末を作成することです。

編集する: また、xdotool getwindowfocus getwindowname端末で実行すると、以下が返されます。

xdo_get_focused_window_sane failed (code=1)
xdo_focus_window reported an error

したがって、xdotoolはもはや認識されないようです。gnome-terminal

ベストアンサー1

おすすめ記事