I have created a bunch of chrome application shortcuts - gmail, tweetdeck, etc. They all launch in tiny windows in the upper left of the screen (see screenshot). It's easy enough to resize/maximize them - but I would like to know what controls their placement and sizing, and then be able to fix it? I've tried using compiz to maximize the window on launch but it doesn't work (compiz works fine for selecting which workspace to place it on, just not resizing). I expect there must be a setting somewhere that dictates this - any ideas?

Small Window

  • It can easily be fixed with the help (use) of wmctrl in your command to open the shortcut command, but the question is what causes it. What is the command? And a silly question, but does it persist after a log out/in? – Jacob Vlijm Mar 31 '15 at 6:59
  • wmctrl sounds like a good fix. The command is: Exec=/opt/google/chrome/google-chrome --app=feedly.com/i/my But I do see another property in the launcher file that may be relevant: StartupWMClass=feedly.com__i_my And yes, it persists. – Mike McKay Mar 31 '15 at 23:22

Just to see what happened, I created some webapp- launchers. What you describe occurred to me as well, but in an unpredictable way; sometimes it happens, sometimes it doesn't.

Opening a webapp window with a pre defined size

To guarantee that a newly created window of a certain application has a certain size, turned out to be a bit more complicated than I anticipated. I think however that the solution below works elegantly.

What it does and how to use

The solution below redirects the command to run the webapp to a script. The scripts runs the command, waits for the corresponding window to appear (waiting for the pid of chrome to produce a new window) and resizes it to the size that you define.

In practice:

Looking inside the webapp's .desktop file, you see in the Exec= line (as you mentioned) a command, looking like:

Exec=/opt/google/chrome/google-chrome --app=feedly.com/i/my

After you made the setup below, all you need to do is to replace the command in this (or any other webapps-) file to:

Exec=run_maximized "/opt/google/chrome/google-chrome --app=feedly.com/i/my" 100 100

The last to figures in the command are the horizontal/vertical sizes of the window (in %, related to the screen size)

The setup

  1. The script uses both wmctrl and xdotool:

    sudo apt-get install wmctrl
    sudo apt-get install xdotool
  2. Copy the script below into an empty file, save it as run_maximized (no extension) in ~/bin. Create the directory if it does not exist. Make the script executable.

  3. If you just created the directory ~/bin, either log out/in or run

    source ~/.profile
  4. In the webapp's .desktop file, replace the command in the Exec= line:

    Exec=/opt/google/chrome/google-chrome --app=feedly.com/i/my


    Exec=run_maximized "/opt/google/chrome/google-chrome --app=feedly.com/i/my" 100 100

    Mind the quotes, and don't forget the horizontal/vertical size of the window

The script

#!/usr/bin/env python3
import subprocess
import getpass
import time
import sys

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

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 -u "+user).splitlines() \
              if "chrome" in p and w[2] in p] for w in ws2]
    if len(procs) > 0:
        command = "xdotool windowsize "+procs[0][0][1]+" "+sys.argv[2]+"% "+sys.argv[3]+"%"
        subprocess.call(["/bin/bash", "-c", command])
    t = t+1


  • I used xdotool to resize the window. It could also be done with wmctrl, but the maximize command of wmctrl has some side effects that xdotool does not have.
  • With a minor change of the script, it can be made usable to run windows of a predefined size (or position) of any application. Could be usefull in quicklists for example, to create multiple windows in a predefined layout.

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.