3

TLDR I'm looking for a ubuntu replacement of windowpad

I know window placement can be defined with Ctrl-Alt-Numpad# and Ctrl-Super-arrow But those are not sufficent. I do have CompizConfig > Cycle Through Multiple Sizes

But I want to assign a hotkey to make a window stick to the left, full height, 1/3rd width. The same for the right. and one for the middle. I'm used to using Windowpad (on windows) which allows me to define pretty much anything. And I'm so used to it.

Any way to tweak this?

Clarify Edit. This is not about opening windows but about the current active windows.

3

1 Answer 1

2

Sounds like you're looking for xdotool or wmctrl. These are tools that let you script various interactions with the GUI. Both can be installed from the repositories, you can use whichever one you prefer:

sudo apt-get install wmctrl xdotool

My display is 1920 x 1080, so 1/3rd width would be 640. To place the active window at the left side of the screen, full height and 1/3rd width, I would run:

wmctrl -r :ACTIVE: -e 0,0,0,640,1080

The format is explained in man wmctrl:

-r <WIN>
     Specify a target window for an action.
-e <MVARG>
     Resize and move a window that has been specified with a -r action 
     according to the  <MVARG> argument.

 [...]

<MVARG>
     A move and resize argument has the format 'g,x,y,w,h'.  All five components  are  integers.
     The  first  value, g, is the gravity of the window, with 0 being the
     most common value (the default value for the window). [...]
     The four remaining values are a standard geometry specification: x,y 
     is the position of the top  left  corner  of  the  window, and w,h
     is the width and height of the window [...].

<WIN>
     This  argument  specifies a window that is the target of an action. [...]
     The  window name string :ACTIVE: may be used to instruct wmctrl to 
     use the currently active window for the action.

You could also make it more dynamic by detecting the width automatically. This command prints the width of your display:

$ xrandr | grep -Po 'current\s*\K\d+'
1920

You could, therefore, integrate it into wmctrl like this:

wmctrl -r :ACTIVE: -e 0,0,0,$(($(xrandr | grep -Po 'current\s*\K\d+')/3)),1080

Now, all you have to do is assign that command to a keyboard shortcut from the Unity Settings and you're all set.

12
  • I like your answers: "Sounds like ..." +1 =)
    – A.B.
    May 16, 2015 at 14:28
  • That seems to work. I do have a laptop which sometimes has a 2nd screen and sometimes not. Looks like I'll have to hit the docs.
    – janw
    May 16, 2015 at 15:18
  • 1
    @janw the output of xrandr should always give the right value. I've written a script that snaps to the left or right side of the screen and works with single or dual monitor setups. That might give you an idea of what is possible. I've posted it in my answer here: How can I start up an application with a pre-defined window size and position?
    – terdon
    May 16, 2015 at 15:34
  • Thanks. But after a bit more research for now I'm concluding that I don't have enough bash and regex skills to execute it, I do have the structure thought out and noted down. I'll check it again in a few months.
    – janw
    May 16, 2015 at 19:39
  • @janw do what you can and post a new question. That's how you learn! :)
    – terdon
    May 16, 2015 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .