7

I am running Linux Mint 17 Cinnamon 2.4.8.

I really like xdotool, but it conflicts with Cinnamon's awesome snapping/tiling feature.

If I run the following command, it does NOT work if the current window is snapped to a corner/side/fullscreen.

xdotool getactivewindow windowsize 500 1080 windowmove 1420 0

I would like to keep it snapped, but with a custom width. If it is NOT snapped, it works.

Main goal: Snap a window to the right side, with 500 width (via a command)

However, it's probably impossible with xdotool.

I would prefer not to install anything else, and do it all with cinnamon, but if anyone thinks I can achieve my goal with wmctrl, then I'll give it a shot.

Desired output vs. current output

http://s115.photobucket.com/user/ericrazy2000/media/snapped.png.html

http://s115.photobucket.com/user/ericrazy2000/media/NOTsnapped.png.html

3

You might need to remove some maximization flags first:

wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;\
xdotool getactivewindow windowsize 500 1080 windowmove 1420 0;\
wmctrl -r :ACTIVE: -b add,maximized_vert
  • This did indeed help a bit. If the window is tiled at the top or bottom, the command works and resizes/relocates the window. However, if the window is tiled to the left or right, the command does not relocate/resize. Also, I would really like to have the final state of the window to be tiled to the edge of the screen – TuxForLife May 18 '15 at 0:13
  • How about now ? – PSkocik May 18 '15 at 0:28
  • Hmmm. While it is working very nicely, it does not put it in snapped mode. I can tell it is not in snapped mode since a shadow is visible, and the top corners are rounded. If the window is snapped, then this does not occur – TuxForLife May 18 '15 at 0:33
  • I am running out of time for the bounty. I would rather give the bounty points to someone rather than waste them. Unless someone provides the answer I anticipated for, I can give the bounty points to whoever gives me the best answer to the following question first. How can I unsnap/unfullscreen a window using just xdotool? – TuxForLife May 22 '15 at 1:02
  • You probably won't be able to tile the window using either wmctrl or xdotool. The reason is, muffin (the cinamon window manager) uses a nonstandard state for that (_NET_WM_STATE_TILED) as you can learn from xprop output. I don't think you can get at that reasonably efficiently from a currently existing higher level tool. You'd need to hack at muffin's C code. – PSkocik May 22 '15 at 1:14
3
+100

Does this command work for you (uses wmctrl):

dist500fromright=$((`xrandr | grep \* | awk '{print $1}' | sed 's/x.*$//'`-500));y=`xrandr | grep \* | awk '{print $1}' | sed 's/^.*x//'`;wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$dist500fromright,0,500,$y

Breakdown

xrandr outputs a list of geometries and the * shows the current mode. For example:

$ xrandr | grep \*
   1920x1200      60.0*+

We use awk to capture the first column of output, and sed to grab the dimensions delimited by the x character.

$ xrandr | grep \* | awk '{print $1}' 
1920x1200

$ xrandr | grep \* | awk '{print $1}' | sed 's/x.*$//'
1920

Bash allows us to do math on command output by wrapping it in $((...)):

$ echo 5+2
5+2

$ echo $((5+2))
7

So above, we wrap the command in $((...)) and subtract 500 to get the x-coordinate position 500 pixels from the right edge of the screen:

$ echo  $((`xrandr | grep \* | awk '{print $1}' | sed 's/x.*$//'`-500))
1420

Note, in order to subtract 500 from 1920, we had to put the command that produces 1920 in backticks first.

We set the output above to the variable dist500fromright, and do something similar to store the y-dimensions of the screen in the y variable:

$ dist500fromright=$((`xrandr | grep \* | awk '{print $1}' | sed 's/x.*$//'`-500))

$ y=`xrandr | grep \* | awk '{print $1}' | sed 's/^.*x//'`;

We are now ready to run the wmctrl command

$ wmctrl -r :ACTIVE: -b add,maximized_vert

$ wmctrl -r :ACTIVE: -e 0,$dist500fromright,0,500,$y

where the latter command resizes and moves the active window while the former allows the resize/move on snapped windows.

  • Your command works pretty much exactly as my xdotool example above. It also deals with the same problems with the xdotool method: 1. It does not move the window if it is tiled/snapped. 2. It does not leave the window tiled/snapped in the end – TuxForLife May 17 '15 at 23:56
  • 1
    @TuxForLife, I updated it for Cinnamon snapping. Please let me know if it works. – user1717828 May 18 '15 at 0:18
  • You are very close! However, I would like the final window to be snapped to the right. It is almost, there, it just needs to be snapped to the edge of my screen – TuxForLife May 18 '15 at 0:22
  • @TuxForLife, Does this command not align the window to the right edge of the screen? Could you describe (or post a screenshot) of what it is doing? Here is what I get. – user1717828 May 18 '15 at 0:36
  • The snapped one, I snapped it manually, then I adjusted the size by dragging the edge of the window. s115.photobucket.com/user/ericrazy2000/media/snapped.png.html s115.photobucket.com/user/ericrazy2000/media/… – TuxForLife May 18 '15 at 0:46
0

You can use wmctrl for this,

as example from the old linux mint mate forum, I think you also can use it in cinnamon:

wmctrl -r :ACTIVE: -e 0,0,0,width,height

This should work.

If your screen is fullscreen you should use:

wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
wmctrl -r :ACTIVE: -e 0,0,0,width,height

source:

http://forums.linuxmint.com/viewtopic.php?f=90&t=109020

or use ctrl + numpad to get the desired location

source:

http://www.reddit.com/r/linux/comments/tbqky/window_snapping_pseudotiling_wm/

  • Please take a look at the previous discussions I had with the other answers. I am aware I can manually snap it, but I am trying to do it with a command. – TuxForLife May 19 '15 at 15:03

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.