0

The following animation demonstrates how I am unable to prevent a window from automatically maximising in Ubuntu 16.04 Unity upon opening.

GIF animation

2
  • only one specific window or you want to make it work for any window ? – Sergiy Kolodyazhnyy Oct 27 '16 at 17:35
  • Most windows behave correctly. However, in general any window. – orschiro Oct 27 '16 at 19:51
1

ComizConfig Settings Manager has a "Place Windows" plugin where you can configure where newly-opened windows should be placed. Below is screenshot example of my setup for Google Chrome placement.

enter image description here

If that doesn't work, here's alternative solution. The script below runs continuously and prevents maximizing of the window in focus.

#!/usr/bin/env python
#
#
# Author: Serg Kolo , contact: 1047481448@qq.com
# Date: Oct 27, 2016
# Purpose: prevents x11 windows form maximizing
# Written for: http://askubuntu.com/q/842317/295286
# Tested on: Ubuntu 16.04 LTS
#
# Copyright: Serg Kolo , 2016
#
#     Permission to use, copy, modify, and distribute this software is hereby granted
#     without fee, provided that  the copyright notice above and this permission statement
#     appear in all copies.
#
#     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
#     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#     DEALINGS IN THE SOFTWARE.
from __future__ import print_function
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, Gio
import subprocess
import signal
import time


def run_cmd(cmdlist):
    """ reusable function for running shell commands"""
    try:
        stdout = subprocess.check_output(cmdlist)
    except subprocess.CalledProcessError:
        pass
    else:
        if stdout:
            return stdout


def main():
    """ defines entry point of the program """
    screen = Gdk.Screen.get_default()
    while True:
        active_window = screen.get_active_window()
        active_xid = str(active_window.get_xid())
        wm_state = run_cmd(
            ['xprop', '-root', '-notype', '-id', active_xid, '_NET_WM_STATE'])
        if ('_NET_WM_STATE_MAXIMIZED_VERT' in wm_state and
                '_NET_WM_STATE_MAXIMIZED_HORZ' in wm_state):
            active_window.unmaximize()
            active_window.process_all_updates()
        time.sleep(0.25)

if __name__ == "__main__":
    main()
1
  • Great script, thank you! The Compiz approach did not work for me. – orschiro Oct 28 '16 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.