私は2台目のモニターを備えたデスクのラップトップでUbuntu14.04を使用しています。 2台目のモニターから必ず切断すると、Emacsのウィンドウが画面から消えます。
Alt-TABでEmacsをアクティブウィンドウにし、盲目的に作業してEmacsを停止し、再起動できるようにします。これにより、画面に再表示されます。しかし、Ubuntuには、画面外のウィンドウを画面に戻す方法があるはずです。ありますか?
もちろん、より良い解決策は、モニターの切断に応答してウィンドウが画面から消えないようにすることです。私はその解決策を受け入れます 問題。
更新:
xrandr
の出力 2台目のモニターに接続している間:
Screen 0: minimum 320 x 200, current 3200 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+1280+0 (normal left inverted right x axis y axis) 382mm x 215mm
1920x1080 60.0*+ 59.9
1680x1050 60.0 59.9
1600x1024 60.2
1400x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x960 60.0
1360x768 59.8 60.0
1152x864 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
1280x1024 60.0*+ 75.0
1280x960 60.0
1152x864 75.0
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 75.0 72.8 66.7 60.0
720x400 70.1
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
xrandr
の出力 2番目のモニターから切断した後:
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 382mm x 215mm
1920x1080 60.0*+ 59.9
1680x1050 60.0 59.9
1600x1024 60.2
1400x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x960 60.0
1360x768 59.8 60.0
1152x864 60.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
また、ターミナルウィンドウとEmacsウィンドウの左右の位置を入れ替えてから切断してみました。これにより、2番目のモニターから切断した後もEmacsウィンドウを画面に表示したままにすることができます。そして、ターミナルウィンドウはEmacsを排除した位置で存続します。したがって、アプリケーションがこれと関係があるように見えます。
承認された回答:
すべてのウィンドウを表示領域に移動します
コメントで提案/要求されたように、以下のスクリプトはすべての「通常の」ウィンドウを現在のワークスペースの表示領域に移動します。
解決策は回避策です。 xrandr
の出力に違いがあるため、画面情報は正しく更新されます。 、切断の前後。別の答えで問題が解決しない限り、ウィンドウが自動的に移動しない理由は(現在)不明です。
スクリプト
#!/usr/bin/env python3
import subprocess
# get the resolution of the screen (+0+0)
res = [
int(n) for n in [
s.split("+")[0].split("x")\
for s in subprocess.check_output(["xrandr"]).decode("utf-8").split()\
if "+0+0" in s][0]
]
# create list of windows
w_list = [w.split() for w in subprocess.check_output(["wmctrl", "-lG"]).decode("utf-8").splitlines()]
# filter only "normal" ones
valid = [
w for w in w_list if "_NET_WM_WINDOW_TYPE_NORMAL" in\
subprocess.check_output(["xprop", "-id", w[0]]).decode("utf-8")
]
# get the number of valid windows and calculate a targeted position
# the targeted position is a hunch, it will be exact if the window fits completely inside the resolution
# it will work anyway
parts = len(valid)+2
positions = [(int(n*res[0]/parts), int(n*res[1]/parts)) for n in list(range(parts))[1:-1]]
# unmaximaize, move the windows to the visible area (current workspace)
for i, w in enumerate(valid):
subprocess.Popen(["wmctrl", "-ir", w[0], "-b", "remove,maximized_vert,remove,maximized_horz"])
# weird, but sometimes wmctrl refuses to move a window if it is not resized first (?)
subprocess.Popen(["wmctrl", "-ir", w[0], "-e", "0,200,200,200,200"])
subprocess.Popen(["wmctrl", "-ir", w[0], "-e", (",").join(["0", str(positions[i][0]), str(positions[i][1]),w[4],w[5]])])
使用方法
-
スクリプトには
wmctrl
が必要です :sudo apt-get install wmctrl
-
スクリプトを空のファイルにコピーし、
move_windows.py
として安全にします -
テスト実行:いくつかのウィンドウを開くか、別のワークスペースなどに配置するか、2番目のモニターを切断してみてください。次に、次のコマンドを実行します:
python3 /path/to/move_windows.py
すべての「通常の」ウィンドウは、現在のワークスペースの表示領域に移動する必要があります。
-
すべて正常に機能する場合は、ショートカットキーに追加します。[システム設定]>[キーボード]>[ショートカット]>[カスタムショートカット]を選択します。 「+」をクリックして、コマンドを追加します:
python3 /path/to/move_windows.py
これで、ショートカットキーを使用して、すべてのウィンドウを現在のワークスペースの表示領域に移動できるようになります。
関連:Ubuntuで静的IPを割り当てるKvmネットワークブリッジ?