wmctrl:移动全屏窗口

时间:2018-04-10 14:10:02

标签: linux bash shell scripting wmctrl

一个小的shell脚本应该修复我的重影屏问题。我试图在一个方向上移动每个窗口仅1px,在接下来的第二个窗口,它应该向后移动另一个方向。

photo_list.count()

是否可以在特定方向上移动1px的全屏窗口? (的 wmctrl )。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

来自Ask Ubuntu

我已经将@jacobs python代码重写为简单的bash并使其起作用(我在ubuntu 16肉桂上进行了测试)。

我必须添加remove,maximized_vert, remove,maximized_horz,但窗口不会移动。

#!/bin/bash

if [ ! -z "$1" ] || [ -z "$2" ]; then
    command=$(wmctrl -l | grep $1 | cut -d" " -f1)

    if [ ! -z "$command" ]; then
        position=$(xrandr | grep "^$2" | cut -d"+" -f2)

        if [ ! -z "$position" ]; then
            for window in $command; do
               wmctrl -ir $window -b remove,maximized_vert
               wmctrl -ir $window -b remove,maximized_horz
               wmctrl -ir $window -e 0,$position,0,1920,1080
               wmctrl -ir $window -b add,maximized_vert
               wmctrl -ir $window -b add,maximized_horz
            done
        else
            echo -e "not found monitor with given name"
        fi
    else
        echo -e "not found windows with given name"
    fi
else
    echo -e "specify window and monitor name;\nmove.sh window-name monitor-name"
fi
  1. sudo apt-get install xdotool wmctrl
  2. /path/to/script.sh "window-name" "monitor-name"