Показать лаунчер через привязку к краю

Показать лаунчер через привязку к краю

Я использую 2 монитора (правый из которых меньше левого по пикселям и физическим показателям) и часто хочу открыть что-нибудь на правом мониторе в лаунчере, который находится в режиме автоматического скрытия. (Липкие края отключены в настройках дисплея, поэтому перемещение курсора между экранами кажется более естественным.) Для этого мне нужно медленно перемещать курсор к левому краю правого монитора, потому что если я буду перемещать его так же быстро, как обычно, курсор переместится на левый монитор.

Мне бы хотелось, чтобы можно было переместить курсор к нижнему краю, чтобы лаунчер постепенно появился. Однако я не смог найти, как это сделать.

Если есть команда для постепенного появления лаунчера или какой-то другой способ сделать это, дайте мне знать, пожалуйста.

решение1

Показывать лаунчер, когда мышь попадает в область «триггера»

Приведенный ниже скрипт активирует (автоматически скрываемый) лаунчер, когда указатель мыши попадает в определенную область (область активациина изображении).

Так как было бы неудобно рисоватьточно прямая линияпо направлению к значку целевого лаунчера, после активации лаунчера, я создал область размером 200 пикселей с левой стороны (правого) экрана, в которой вы можете свободно перемещаться, не скрывая лаунчер снова (область перемещения).

введите описание изображения здесь

Как использовать

  1. Скрипт использует xdotoolдля получения положения мыши:

    sudo apt-get install xdotool
    
  2. Скопируйте скрипт в пустой файл, сохраните его какtrigger_launcher.py

  3. В разделе заголовка скрипта я установил значения, которые должны соответствовать вашей комбинации экранов и быть выровненными по верхнему краю. Однако, если вы хотите использовать скрипт с другими экранами (размерами) или хотите изменить (trigger-) поля, вы можете изменить это в заголовке скрипта:

    # 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. Если все работает нормально, добавьте его в список автозапускаемых приложений: Dash > Автозапуск приложений > Добавить. Добавьте команду:

    /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

Связанный контент