エッジバインディングでランチャーを表示する

エッジバインディングでランチャーを表示する

私は 2 つのモニターを使用しています (そのうちの右側のモニターはピクセル数と物理メトリックの点で左側のモニターより小さい)。ランチャーは自動的に非表示になっているため、右側のモニターで何かを開きたいことがよくあります (ディスプレイ設定でスティッキー エッジがオフになっているため、画面間でカーソルを移動する方が自然に感じられます)。この場合、カーソルを右側のモニターの左端にゆっくりと移動する必要があります。通常どおりに速く動かすと、カーソルが左側のモニターに移動してしまうためです。

カーソルを下端に移動してランチャーをフェードインできればよいのですが、そのためのコマンドが見つかりません。

ランチャーをフェードインするコマンドや、これを行う他の方法がある場合は、お知らせください。

答え1

マウスが「トリガー」領域に入るとランチャーを表示します

以下のスクリプトは、マウスポインタが特定の領域に入ると(自動的に隠される)ランチャーを起動します(活性化エリア(画像内)

図面を描くのは不便なので、正確に直線ランチャーアイコンに向かって、ランチャーが起動した後、(右)画面の左側から200ピクセルの領域を作成し、ランチャーを再び隠すことなく自由に移動できるようにします(エリアを移動)。

ここに画像の説明を入力してください

使い方

  1. スクリプトはxdotoolマウスの位置を取得するために以下を使用します:

    sudo apt-get install xdotool
    
  2. スクリプトを空のファイルにコピーし、trigger_launcher.py

  3. スクリプトの先頭セクションでは、画面の組み合わせに適した上揃えの値を設定しました。ただし、スクリプトを他の画面 (サイズ) で使用する場合や、(トリガー) マージンを変更する場合は、スクリプトの先頭で変更できます。

    # the script assumes the two screens are top-alligned (!)
    
    #-- set the area to trigger the launcher (from left bottom of second screen) below:
    vert_marge = 50
    hor_marge = 200
    #-- set the width of the left screen below:
    width_screen1 = 1680
    #-- set the height of the right screen below:
    height_screen2 = 900
    #---
    
  4. 次のコマンドでスクリプトを試運転します。

    python3 /path/to/trigger_launcher.py
    
  5. すべて正常に動作する場合は、スタートアップ アプリケーションに追加します: ダッシュ > スタートアップ アプリケーション > 追加。次のコマンドを追加します:

    /bin/bash -c "sleep 15&&python3 /path/to/trigger_launcher.py"
    

スクリプト

#!/usr/bin/env python3
import subprocess
import time

# the script assumes the two screens are top-alligned (!)

#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--


vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
    "gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]

hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]

def set_launcher(command):
    subprocess.Popen(["/bin/bash", "-c", command])

def get_mousepos():
    curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
    return [int(it.split(":")[1]) for it in curr.split()[:2]]

current1 = get_mousepos()
while True:
    time.sleep(0.3)
    current2 = get_mousepos()
    if not current1 == current2:
        test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
        test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
        test3 = any([int(current2[0]) > hor_line2, int(current2[0]) < width_screen1])
        if (all(test1), all(test2)) == (False, True):
            set_launcher(show)
        elif test3 == True:
            set_launcher(hide)
    current1 = current2

編集

以下は、コメントで言及されているように、「移動エリア」の代わりに 3 秒のタイム ブレークがあるバージョンです。

#!/usr/bin/env python3
import subprocess
import time

# the script assumes the two screens are top-alligned (!)

#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--

vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
    "gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]

hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]

def set_launcher(command):
    subprocess.Popen(["/bin/bash", "-c", command])

def get_mousepos():
    curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
    return [int(it.split(":")[1]) for it in curr.split()[:2]]

current1 = get_mousepos()
while True:
    time.sleep(0.3)
    current2 = get_mousepos()
    if not current1 == current2:
        test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
        test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
        if (all(test1), all(test2)) == (False, True):
            set_launcher(show)
            time.sleep(3)
            set_launcher(hide)
    current1 = current2

関連情報