카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/14

화면분할 CLI 설정

우분투 18.04 에서 gnome-shell이 4분할 기능이 현재 나오지 않음.
스크립트 작업에 필용한 응용프로그램 4분할 위치 지정 방법 시나리오.

윈도우 사이즈 설정
sudo apt-get install wmctrl
sudo apt-get install xdotool

wmctrl -r '제목 창' -t '작업 공간 번호 지정'

#epiphany 실행 뒤,
#3초 대기
# 해당 프로그램의 PID에 해당하는 창 ID를 획득.
# 해당 창 ID 정보로 지정된 작업공간 0번으로 옮긴다.
epiphany & sleep 3; t=$(wmctrl -lp | grep -F " $! " | awk '{ print $1 }'); wmctrl -i -r $t -t 0

스크립트 참고 (http://hungrylobster.tistory.com/136).
sudo vi ~/bin/setwindow.py
#!/usr/bin/env python3
import subprocess
import time
import sys

app = sys.argv[1]

get = lambda x: subprocess.check_output(["/bin/bash", "-c", x]).decode("utf-8")
ws1 = get("wmctrl -lp"); t = 0
subprocess.Popen(["/bin/bash", "-c", app])

while t < 30:   
    ws2 = [w.split()[0:3] for w in get("wmctrl -lp").splitlines() if not w in ws1]
    procs = [[(p, w[0]) for p in get("ps -e ww").splitlines() \
              if app in p and w[2] in p] for w in ws2]
    if len(procs) > 0:
        w_id = procs[0][0][1]
        cmd1 = "wmctrl -ir "+w_id+" -b remove,maximized_horz"
        cmd2 = "wmctrl -ir "+w_id+" -b remove,maximized_vert"
        cmd3 = "xdotool windowsize --sync "+procs[0][0][1]+" "+sys.argv[4]+"% "+sys.argv[5]+"%"
        cmd4 = "xdotool windowmove "+procs[0][0][1]+" "+sys.argv[2]+" "+sys.argv[3]
        for cmd in [cmd1, cmd2, cmd3, cmd4]: 
            subprocess.call(["/bin/bash", "-c", cmd])
        break
    time.sleep(0.5)
    t = t+1

실행 권한
chmod +x ~/bin/setwindow.py

setwindow.py 0 0 50 100 gedit /path/to/file.txt
setwindow <horizontal-position> <vertical-position> <horizontal-size (%)> <vertical-size (%)> <application> <file_to_open>
setwindow <수평> <수직> <수평-크기 (%)> <수직-크기 (%)> <응용프로그램> <파일명>

크기가 다른 듀얼 모니터 사용 예


wmctrl -lG | grep firefox
wmctrl -lG | grep Mozilla\ Firefox
0x04200011  0 14   94   1280 1386 linuxlee-11T750-GT58K Mozilla Firefox

0x04200011: 프로세스 메모리 로딩 위치
0: 작업 공간 번호
14 94: x, y 위치
1280 1386: 윈도우 가로, 세로 화면 크기

위치 지정
setwindow.py 사용프로그램 <x위치> <y위치> <가로크기> <세로크기>

setwindow.py firefox 1221 24 25 100
setwindow.py firefox 2332 24 25 100

setwindow.py firefox 1221 24 50 100
setwindow.py firefox 2332 24 0 100

댓글 없음:

댓글 쓰기