Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Bash command for Maximizing and Unmaximizing windows in gnome?

  1. #1
    Join Date
    Apr 2009
    Location
    Illinois
    Beans
    5
    Distro
    Ubuntu 8.04 Hardy Heron

    Bash command for Maximizing and Unmaximizing windows in gnome?

    Hello,

    Does anyone know the bash command to Maximize and Unmaximize windows in the gnome desktop environment?

    I want to designate my upper right corner of my touchpad to Maximize and Unmaximize windows. I found the synaptics driver command to activate the upper right corner of the touchpad. I am hoping that I can somehow tie an event to the RTCornerButton button option in the xorg.conf file.

    According to what I found on the internet that command has 12 possible options, the first three just emulate a left, right, or middle button cliks. The remainder of the options don't do anything that is obvious to me. I am hoping I can designate the 4th option in the RTCornerButton to bash a command to maximize or unmaximize a window.

    Thanks in advance for any kind of help,

    Carlos

  2. #2
    Join Date
    Oct 2007
    Beans
    94

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    I would be bolder and ask this question for X in general..

    I've been fiddling around with

    xdotool
    xprop
    wmctrl

    but no luck! I need this feature badly, because else maximus makes windows unusable, when I switch it off.

    When trying xdotool, windows will receive alt+F5, but just interpret it as keys.. Window commands are ignored. Xprop returns

    Code:
    xprop -id 0x200007
    X Error of failed request:  BadWindow (invalid Window parameter)
      Major opcode of failed request:  21 (X_ListProperties)
      Resource id in failed request:  0x200007
      Serial number of failed request:  11
      Current serial number in output stream:  11
    for any window. And wmctrl seems to be lacking such features.

    I know it can be acessed via the window class for GNOME http://library.gnome.org/devel/gtk/u...GtkWindow.html http://www.pygtk.org/docs/pygtk/class-gtkwindow.html. BUt there ought to be some command line way to do it.
    Last edited by crazy ivan; February 12th, 2011 at 10:46 PM.

  3. #3
    Join Date
    Apr 2005
    Location
    Finland/UK
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    wmctrl is the tool you are looking for...

    http://linux.die.net/man/1/wmctrl

  4. #4
    Join Date
    Nov 2010
    Location
    Berlin, Germany
    Beans
    4,534
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    Specifically he will mean a command like this:
    Code:
    wmctrl -i -r 0x200007 -b toggle,maximized_vert,maximized_horz
    Of course you would have to determine the id before, I recommend "xwininfo" for that:
    Code:
    winid=`xwininfo -name NAME |grep 'Window id:' |cut -d" " -f4`
    wmctrl -i -a "$winid"
    Or use its name instead with wmctrl, but that only works correct if there is no other window which also contains the string in its name, wmctrl doesn't even handle the case.

    I had to do the upper workaround for MPlayer and mplayerTV.

  5. #5
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    To toggle the focused window maximized/unmaximized...
    Code:
    wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
    ...and I find the best way to use it is with easystroke mouse gestures
    because performing the gesture on a window brings it into focus.
    Attached Images Attached Images
    Last edited by stinkeye; February 13th, 2011 at 10:21 AM.

  6. #6
    Join Date
    Oct 2007
    Beans
    94

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    Thanks guys, that's pretty cool stuff, even though the search function is better implemented in xdotool. Thanks for the cut code.

    I used "wmctrl -k" to show the desktop in another script, never thought to go further. Anyhow, my problems with maximus have been somewhat sorted out since I found the gconf entries

    "/apps/maximus/undecorate" to work with it on dual screens and

    "/apps/metacity/window_keybindings/toggle_fullscreen" and

    "/apps/metacity/window_keybindings/toggle_maximized"

    to repair the "damage" it has done to some apps (guess calling these shortcuts amounts to calling wmctrl).

    Bound "toggle_maximzed" to "<Super>F5" and "toggle_fullscreen" to "<Super>F11" now, and thus rescued mozilla thunderbird and Openoffice out of unintended fullscreen created by maximus.

  7. #7
    Join Date
    Oct 2007
    Beans
    94

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    Thanks again Krytarik and stinkeye. With these commands, I managed to write a little script that shows the time in a notification box, disabling the fullscreen of mypaint which usually runs as a notepad on my tablet's screen blocking the notifications:

    Code:
    #!/bin/sh
    date_time="`date | cut -d' ' -f1,2,3,4`"
    wmctrl -r MyPaint -b remove,fullscreen
    notify-send "$date_time"
    sleep 5
    wmctrl -r MyPaint -b add,fullscreen
    Not quite perefect, since it does not hide the menu, as it does when I press F11. Don't think wmctrl can acess this property though..

    Also I added "wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz" and "wmctrl -r :ACTIVE: -b toggle,fullscreen" to easystroke gestures
    Last edited by crazy ivan; March 12th, 2011 at 05:24 PM.

  8. #8
    Join Date
    Nov 2010
    Location
    Berlin, Germany
    Beans
    4,534
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    You could also simply pass the option "-u critical" to notify-send to show the notification even while in fullscreen.
    Code:
    notify-send -u critical "`date | cut -d' ' -f1,2,3,4`"

  9. #9
    Join Date
    Oct 2007
    Beans
    94

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    thx! works even better..

  10. #10
    Join Date
    Oct 2007
    Beans
    94

    Re: Bash command for Maximizing and Unmaximizing windows in gnome?

    And thanks for the
    Code:
     winid=`xwininfo -name NAME |grep 'Window id:' |cut -d" " -f4`
    line. I ran into
    Code:
     wmctrl -r -c NAME
    not shutting down the programs at all **.

    Now I use
    Code:
    winid=`xwininfo -name NAME |grep 'Window id:' |cut -d" " -f4`
    wmctrl -i -c "$winid"
    for most programs..
    For some I had to try harder and got the line (with the modification "wminfo -root -tree" it is somewhat similar to "ps aux" for WIDs instead of PIDs)
    Code:
    xwininfo -root -tree 2>/dev/null | grep NAME | awk '{print $1}'
    from chewearn http://blog.chewearn.com/2010/01/18/...n-bash-script/. Now I can also make gedit, eclipse, inkscape and referencer ask me if I want to save before quitting trough the command line:

    Code:
    $app=" gedit"
    wmctrl -i -c `xwininfo -root -tree 2>/dev/null | grep "$app" | awk '{print $1}'`
    Note the odd " gedit" string to distinguish it from the parent processes.

    ** By the way, can one get any output from that wmctrl.. I mean they have "-v Provide verbose output. This is really useful when debugging wmctrl itself." which does nothing. Its somehow unsatisfying that it does not show any response to wrong input...
    Last edited by crazy ivan; March 18th, 2011 at 07:32 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •