Commands used by keyboard shortcuts Tile windows to side of the screen

Forum rules
Before you post please read how to get help
Post Reply
aless80
Level 2
Level 2
Posts: 77
Joined: Wed Nov 28, 2012 5:20 am

Commands used by keyboard shortcuts Tile windows to side of the screen

Post by aless80 » Thu Oct 25, 2018 1:30 am

Linux Mint 19 Tara (but in part also the previous versions 17 and 18) has added keyboard shortcuts to run operations such as:

Tile windows to east (right) side of the screen
Tile windows to north-west (top left) corner
Move window to south-east (bottom right) corner
...

This is great, but I'd like to know what commands are run in the background so that I can try to write my own (e.g. tile to 2/3rd, left side, or move window a little bit to the right).
Attachments
Screenshot at 2018-10-25 07-29-34.png

User avatar
smurphos
Level 9
Level 9
Posts: 2996
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Commands used by keyboard shortcuts Tile windows to side of the screen

Post by smurphos » Thu Oct 25, 2018 1:59 am

You'll need to install and explore the delights of wmctrl to make custom scripts to invoke by shortcut keys to move windows around. The default shortcuts interact directly with the window manager which I'm pretty sure you can't do directly from the command line without this utility.

Good luck - it's a versatile if very complex command

https://www.freedesktop.org/wiki/Software/wmctrl/

Code: Select all

wmctrl --help
wmctrl 1.07
Usage: wmctrl [OPTION]...
Actions:
  -m                   Show information about the window manager and
                       about the environment.
  -l                   List windows managed by the window manager.
  -d                   List desktops. The current desktop is marked
                       with an asterisk.
  -s <DESK>            Switch to the specified desktop.
  -a <WIN>             Activate the window by switching to its desktop and
                       raising it.
  -c <WIN>             Close the window gracefully.
  -R <WIN>             Move the window to the current desktop and
                       activate it.
  -r <WIN> -t <DESK>   Move the window to the specified desktop.
  -r <WIN> -e <MVARG>  Resize and move the window around the desktop.
                       The format of the <MVARG> argument is described below.
  -r <WIN> -b <STARG>  Change the state of the window. Using this option it's
                       possible for example to make the window maximized,
                       minimized or fullscreen. The format of the <STARG>
                       argument and list of possible states is given below.
  -r <WIN> -N <STR>    Set the name (long title) of the window.
  -r <WIN> -I <STR>    Set the icon name (short title) of the window.
  -r <WIN> -T <STR>    Set both the name and the icon name of the window.
  -k (on|off)          Activate or deactivate window manager's
                       "showing the desktop" mode. Many window managers
                       do not implement this mode.
  -o <X>,<Y>           Change the viewport for the current desktop.
                       The X and Y values are separated with a comma.
                       They define the top left corner of the viewport.
                       The window manager may ignore the request.
  -n <NUM>             Change number of desktops.
                       The window manager may ignore the request.
  -g <W>,<H>           Change geometry (common size) of all desktops.
                       The window manager may ignore the request.
  -h                   Print help.

Options:
  -i                   Interpret <WIN> as a numerical window ID.
  -p                   Include PIDs in the window list. Very few
                       X applications support this feature.
  -G                   Include geometry in the window list.
  -x                   Include WM_CLASS in the window list or
                       interpret <WIN> as the WM_CLASS name.
  -u                   Override auto-detection and force UTF-8 mode.
  -F                   Modifies the behavior of the window title matching
                       algorithm. It will match only the full window title
                       instead of a substring, when this option is used.
                       Furthermore it makes the matching case sensitive.
  -v                   Be verbose. Useful for debugging.
  -w <WA>              Use a workaround. The option may appear multiple
                       times. List of available workarounds is given below.

Arguments:
  <WIN>                This argument specifies the window. By default it's
                       interpreted as a string. The string is matched
                       against the window titles and the first matching
                       window is used. The matching isn't case sensitive
                       and the string may appear in any position
                       of the title.

                       The -i option may be used to interpret the argument
                       as a numerical window ID represented as a decimal
                       number. If it starts with "0x", then
                       it will be interpreted as a hexadecimal number.

                       The -x option may be used to interpret the argument
                       as a string, which is matched against the window's
                       class name (WM_CLASS property). Th first matching
                       window is used. The matching isn't case sensitive
                       and the string may appear in any position
                       of the class name. So it's recommended to  always use
                       the -F option in conjunction with the -x option.

                       The special string ":SELECT:" (without the quotes)
                       may be used to instruct wmctrl to let you select the
                       window by clicking on it.

                       The special string ":ACTIVE:" (without the quotes)
                       may be used to instruct wmctrl to use the currently
                       active window for the action.

  <DESK>               A desktop number. Desktops are counted from zero.

  <MVARG>              Specifies a change to the position and size
                       of the window. The format of the argument is:

                       <G>,<X>,<Y>,<W>,<H>

                       <G>: Gravity specified as a number. The numbers are
                          defined in the EWMH specification. The value of
                          zero is particularly useful, it means "use the
                          default gravity of the window".
                       <X>,<Y>: Coordinates of new position of the window.
                       <W>,<H>: New width and height of the window.

                       The value of -1 may appear in place of
                       any of the <X>, <Y>, <W> and <H> properties
                       to left the property unchanged.

  <STARG>              Specifies a change to the state of the window
                       by the means of _NET_WM_STATE request.
                       This option allows two properties to be changed
                       simultaneously, specifically to allow both
                       horizontal and vertical maximization to be
                       altered together.

                       The format of the argument is:

                       (remove|add|toggle),<PROP1>[,<PROP2>]

                       The EWMH specification defines the
                       following properties:

                           modal, sticky, maximized_vert, maximized_horz,
                           shaded, skip_taskbar, skip_pager, hidden,
                           fullscreen, above, below

Workarounds:

  DESKTOP_TITLES_INVALID_UTF8      Print non-ASCII desktop titles correctly
                                   when using Window Maker.

The format of the window list:

  <window ID> <desktop ID> <client machine> <window title>

The format of the desktop list:

  <desktop ID> [-*] <geometry> <viewport> <workarea> <title>


Author, current maintainer: Tomas Styblo <tripie@cpan.org>
Released under the GNU General Public License.
Copyright (C) 2003

aless80
Level 2
Level 2
Posts: 77
Joined: Wed Nov 28, 2012 5:20 am

Re: Commands used by keyboard shortcuts Tile windows to side of the screen

Post by aless80 » Thu Oct 25, 2018 2:07 am

Yes I'm familiar with this command. I use it to bring a window forward and to my Desoto when I launch some applications I'm interested in.
"The default shortcuts interact directly with the window manager which I'm pretty sure you can't do directly from the command line without this utility."
do you mean that is some script that died not directly use wmctrl? It would be interesting to know more. Could you give me any pointer? Is there a file containing the commands run by those shortcuts?

gm10
Level 15
Level 15
Posts: 5958
Joined: Thu Jun 21, 2018 5:11 pm

Re: Commands used by keyboard shortcuts Tile windows to side of the screen

Post by gm10 » Thu Oct 25, 2018 2:11 am

The tiling support is provided by the window manager, it's not something that allows you to randomly position windows, there are only the 4 edges you can move windows to.

As smurphos said, wmctrl is the tool to use. It's not that complicated though. Create a custom keybind with this command to move the active window to the left edge and 300 pixels from the top:

Code: Select all

wmctrl -r :ACTIVE: -e 0,0,300,-1,-1
You can figure out the rest from there.

Post Reply

Return to “MATE”