Mostrar iniciador por meio de vinculação de borda

Mostrar iniciador por meio de vinculação de borda

Eu uso 2 monitores (o direito é menor que o esquerdo em pixels e métricas físicas) e muitas vezes quero abrir algo no monitor direito do inicializador que está em ocultação automática. (As bordas fixas estão desativadas nas configurações de exibição, portanto, mover o cursor entre as telas parece mais natural.) Isso exige que eu mova o cursor lentamente para a borda esquerda do monitor direito, porque se eu movê-lo tão rápido como de costume, o cursor se move para o monitor esquerdo.

Eu gostaria que pudesse mover meu cursor para a borda inferior para desaparecer no inicializador. No entanto, não consegui encontrar um elogio para fazê-lo.

Se houver um comando para ativar o launcher ou alguma outra maneira de fazer isso, me avise, por favor.

Responder1

Mostrar o inicializador quando o mouse entrar em uma área de "gatilho"

O script abaixo ativa o inicializador (oculto automaticamente) quando o ponteiro do mouse entra em uma determinada área (área de ativaçãona imagem).

Como não seria conveniente ter que desenhar umalinha exatamente retaem direção ao ícone do inicializador de destino, após o inicializador ser ativado, criei uma área de 200px no lado esquerdo da tela (direita), na qual você pode se mover livremente sem ocultar o inicializador novamente (omover área).

insira a descrição da imagem aqui

Como usar

  1. O script usa xdotoolpara obter a posição do mouse:

    sudo apt-get install xdotool
    
  2. Copie o script em um arquivo vazio e salve-o comotrigger_launcher.py

  3. Na seção principal do script, defino os valores conforme devem ser apropriados à sua combinação de tela e alinhados na parte superior. No entanto, se você usar o script com outros (tamanhos) de tela ou quiser alterar as margens (de gatilho), poderá alterá-lo no cabeçalho do script:

    # 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. Teste o script com o comando:

    python3 /path/to/trigger_launcher.py
    
  5. Se tudo funcionar bem, adicione-o aos seus aplicativos de inicialização: Dash > Aplicativos de inicialização > Adicionar. Adicione o comando:

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

O roteiro

#!/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

Editar

Abaixo uma versão com intervalo de tempo de 3 segundos, ao invés de “mover área”, como você mencionou em comentário.

#!/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

informação relacionada