현재 화면 또는 창을 강조 표시하는 방법은 무엇입니까? 가지 화면 설정을 사용하고

직장에서 두 가지 화면 설정을 사용하고 있으며 일반적으로 아파하는 것보다 많은 도움이되지만 몇 가지 문제가 있습니다.

그들 중 하나는 후행 초점에 문제가 있습니다. 때로는 잘못된 화면에서 입력하는 실수가 있습니다 (초점이 커서에 후행이지만, 급한 일을 할 때 커서가 다른 화면에 있음을 항상 쉽게 알 수는 없습니다). 타이핑 대신 다른 행동 (천둥에 하나의 키 단축키)을 유발할 때 이것은 매우 성가신 일입니다.

활성 화면이나 창을 더 잘 강조 표시하는 방법이 있습니까 (예 : 눈에 잘 띄는 테두리 사용-최대화 된 창에서도)?

편집하다:

창에 포커스가있을 때 멋진 해결책이 일종의 짧은 애니메이션 일 것이라고 생각합니다.



답변

초점이 맞춰진 화면을 강조 표시합니다 (또는 초점 변경시 흐리게 깜박임, 아래의 추가 편집 참조).

나란히 듀얼 모니터 설정 (왼쪽-오른쪽)에서 아래 스크립트는 포커스가있는 창을 가진 모니터의 밝기를 “정상”(100 %)으로 설정하고 다른 모니터는 60 %로 흐리게 설정합니다.

초점이 바뀌면 밝기가 초점을 따릅니다.

오른쪽 화면에서 (창)에 초점

왼쪽 화면에서 (창)에 초점

스크립트

#!/usr/bin/env python3
"""
In a side-by-side dual monitor setup (left-right), the script below will set
the brightness of the monitor with the focussed window to "normal" (100%),
while other one is dimmed to 60%. If the focus changes, the brightness will
follow the focus
"""
import subprocess
import time

def get_wposition():
    # get the position of the currently frontmost window
    try:
        w_data = subprocess.check_output(["wmctrl", "-lG"]).decode("utf-8").splitlines()
        frontmost = subprocess.check_output(["xprop", "-root", "_NET_ACTIVE_WINDOW"]).decode("utf-8").split()[-1].strip()
        z = 10-len(frontmost); frontmost = frontmost[:2]+z*"0"+frontmost[2:]
        return [int(l.split()[2]) for l in w_data if frontmost in l][0]
    except subprocess.CalledProcessError:
        pass

def get_onscreen():
    # get the size of the desktop, the names of both screens and the x-resolution of the left screen
    resdata = subprocess.check_output(["xrandr"]).decode("utf-8")
    if resdata.count(" connected") == 2:
        resdata = resdata.splitlines()
        r = resdata[0].split(); span = int(r[r.index("current")+1])
        screens = [l for l in resdata if " connected" in l]
        lr = [[(l.split()[0], int([s.split("x")[0] for s in l.split() if "+0+0" in s][0])) for l in screens if "+0+0" in l][0],
               [l.split()[0] for l in screens if not "+0+0" in l][0]]
        return [span, lr]
    else:
        print("no second screen seems to be connected")

def scr_position(span, limit, pos):
    # determine if the frontmost window is on the left- or right screen
    if limit < pos < span:
        return [right_scr, left_scr]
    else:
        return [left_scr, right_scr]

def highlight(scr1, scr2):
    # highlight the "active" window, dim the other one
    action1 = "xrandr", "--output", scr1, "--brightness", "1.0"
    action2 = "xrandr", "--output", scr2, "--brightness", "0.6"
    for action in [action1, action2]:
        subprocess.Popen(action)

# determine the screen setup
screendata = get_onscreen()
left_scr = screendata[1][0][0]; right_scr = screendata[1][1]
limit = screendata[1][0][1]; span = screendata[0]

# set initial highlight
oncurrent1 = scr_position(span, limit, get_wposition())
highlight(oncurrent1[0], oncurrent1[1])

while True:
    time.sleep(0.5)
    pos = get_wposition()
    # bypass possible incidental failures of the wmctrl command
    if pos != None:
        oncurrent2 = scr_position(span, limit, pos)
        # only set highlight if there is a change in active window
        if oncurrent2 != oncurrent1:
            highlight(oncurrent1[1], oncurrent1[0])
        oncurrent1 = oncurrent2

사용하는 방법

  1. 스크립트가 필요합니다 wmctrl:

    sudo apt-get install wmctrl
  2. 스크립트를 빈 파일로 복사하여 다른 이름으로 저장하십시오. highlight_focus.py

  3. 다음 명령으로 테스트 실행하십시오.

    python3 /path/to/highlight_focus.py

    두 번째 모니터가 연결된 상태에서 스크립트가 예상대로 작동하는지 테스트하십시오.

  4. 모두 제대로 작동하면 시작 응용 프로그램에 추가하십시오 : Dash> Startup Applications> 명령 추가 :

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

노트

  • 스크립트의 리소스가 매우 부족합니다. “연료 절약”, 화면 설정; 스크립트 시작 중 (루프에 포함되지 않은) 해상도, 범위 크기 등은 한 번만 읽습니다. 이는 두 번째 모니터를 연결 / 연결 해제 할 경우 스크립트를 다시 시작해야 함을 의미합니다.

  • 시작 응용 프로그램에 추가 한 경우 모니터 구성을 변경 한 후 로그 아웃 / 로그인해야합니다.

  • 희미한 화면에 대해 다른 밝기 비율을 원하면 줄의 값을 변경하십시오.

    action2 = "xrandr", "--output", scr2, "--brightness", "0.6"

값은 0,0(검은 색 화면)과 1.0(100 %) 사이 일 수 있습니다 .

설명

스크립트가 시작되면 다음을 결정합니다.

  • 두 화면의 확장 해상도
  • 왼쪽 화면의 x 해상도
  • 두 화면의 이름

그런 다음 루프에서 (초당 한 번) :

  • 다음 명령으로 활성 창의 위치를 ​​확인합니다.

    • wmctrl -lG (창 목록과 위치를 얻기 위해)
    • xprop -root _NET_ACTIVE_WINDOW (맨 앞 창의 ID를 얻기 위해)

창의 (x-) 위치가 왼쪽 화면의 x 해상도보다 크면 창 은 두 화면의 확장 크기보다 크지 않는 한 분명히 오른쪽 화면에 있습니다 (그런 다음 작업 공간에 있음). 권리). 따라서:

if limit < pos < span:

창의 오른쪽 화면에 있는지 여부를 결정합니다 ( limit왼쪽 화면의 x-res pos는 창의 x- 위치이고 span두 화면의 결합 된 x-res입니다).

경우 (좌측 또는 우측 화면) 최 윈도우의 위치의 변화가, 스크립트는 함께 두 화면의 밝기 설정 xrandr명령 :

xrandr --output <screen_name> --brightness <value>

편집하다

영구적으로 흐리게 “비 초점”화면 대신 초점이 맞춰진 화면을 흐리게 플래시

댓글과 채팅에서 요청한대로 새로 초점을 맞춘 화면에서 짧은 희미한 플래시를 제공하는 스크립트 버전 아래 :

#!/usr/bin/env python3
"""
In a side-by-side dual monitor setup (left-right), the script below will give
a short dim- flash on the newly focussed screen if the focussed screen changes
"""

import subprocess
import time

def get_wposition():
    # get the position of the currently frontmost window
    try:
        w_data = subprocess.check_output(["wmctrl", "-lG"]).decode("utf-8").splitlines()
        frontmost = subprocess.check_output(["xprop", "-root", "_NET_ACTIVE_WINDOW"]).decode("utf-8").split()[-1].strip()
        z = 10-len(frontmost); frontmost = frontmost[:2]+z*"0"+frontmost[2:]
        return [int(l.split()[2]) for l in w_data if frontmost in l][0]
    except subprocess.CalledProcessError:
        pass

def get_onscreen():
    # get the size of the desktop, the names of both screens and the x-resolution of the left screen
    resdata = subprocess.check_output(["xrandr"]).decode("utf-8")
    if resdata.count(" connected") == 2:
        resdata = resdata.splitlines()
        r = resdata[0].split(); span = int(r[r.index("current")+1])
        screens = [l for l in resdata if " connected" in l]
        lr = [[(l.split()[0], int([s.split("x")[0] for s in l.split() if "+0+0" in s][0])) for l in screens if "+0+0" in l][0],
               [l.split()[0] for l in screens if not "+0+0" in l][0]]
        return [span, lr]
    else:
        print("no second screen seems to be connected")

def scr_position(span, limit, pos):
    # determine if the frontmost window is on the left- or right screen
    if limit < pos < span:
        return [right_scr, left_scr]
    else:
        return [left_scr, right_scr]

def highlight(scr1):
    # highlight the "active" window, dim the other one
    subprocess.Popen([ "xrandr", "--output", scr1, "--brightness", "0.3"])
    time.sleep(0.1)
    subprocess.Popen([ "xrandr", "--output", scr1, "--brightness", "1.0"])

# determine the screen setup
screendata = get_onscreen()
left_scr = screendata[1][0][0]; right_scr = screendata[1][1]
limit = screendata[1][0][1]; span = screendata[0]

# set initial highlight
oncurrent1 = []

while True:
    time.sleep(0.5)
    pos = get_wposition()
    # bypass possible incidental failures of the wmctrl command
    if pos != None:
        oncurrent2 = scr_position(span, limit, pos)
        # only set highlight if there is a change in active window
        if oncurrent2 != oncurrent1:
            highlight(oncurrent2[0])
        oncurrent1 = oncurrent2

답변

또한 다른 솔루션을 찾았습니다. 처음에 원하는 것과 약간 다르지만 제대로 작동합니다.

  1. 설치 compizconfig-settings-manager compiz-plugins
  2. ccsm 실행
  3. 에서 Effects섹션 수 있도록 Animations플러그인
  4. 에서 Focus Animation편집을 선택하여 원하는 애니메이션.

웨이브 효과 만 효과가 있었으므로 마음에 들지 않으면 내 얼굴만큼 슬퍼 할 것입니다.