Results 1 to 10 of 30

Thread: Detecting maximized window(s) is this possible?

Hybrid View

  1. #1
    Join Date
    Jun 2010
    Beans
    699

    Detecting maximized window(s) is this possible?

    Is there a way i could detect maximized window(s) in Ubuntu (Gnome 3) and do that reliable? And if it is is there a way i could run a script that would do one thing when it would detect maximized window(s) and another when there would be no maximized window(s)?

    Thanks!

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

    Re: Detecting maximized window(s) is this possible?

    Have a look at wmctrl.
    eg on my res of 1680x1050 in unity, maximized windows show "1630 x 1026" dimension.
    Code:
    glen@Oneiric:~$ wmctrl -lpG
    0x01600004  0 30241  0    0    1680 1050 Oneiric Desktop
    0x02c00002  0 0      -1780 -1150 1680 1050     N/A DNDCollectionWindow
    0x02c00003  0 0      0    24   50   1026     N/A launcher
    0x02c00004  0 0      0    0    1680 24       N/A panel
    0x01000004  0 30227  1362 0    48   24   Oneiric compiz
    0x03c00002  0 0      65   440  410  610  Oneiric conkygmail
    0x03e00002  0 0      489  39   602  302  Oneiric sbreeze
    0x04000002  0 0      1108 38   564  429  Oneiric myconky
    0x04600002  0 0      1337 69   104  17   Oneiric Conky (Oneiric)
    0x0480000d  0 31079  1200 598  300  300  Oneiric MacSlow's Cairo-Clock
    0x0440001d  0 31338  50   24   1630 1026 Oneiric Ubuntu Forums - Reply to Topic - Opera
    0x04e00006  0 17273  112  302  1212 686  Oneiric glen@Oneiric: ~
    0x0160037a  0 30241  50   24   1630 1026 Oneiric Home
    
    glen@Oneiric:~$ wmctrl -lpG | grep "1630 1026"
    0x0440001d  0 31338  50   24   1630 1026 Oneiric Ubuntu Forums - Reply to Topic - Opera
    0x0160037a  0 30241  50   24   1630 1026 Oneiric Home
    Grep can be used with a count option
    eg
    Code:
    glen@Oneiric:~$ wmctrl -lpG | grep -c "1630 1026"
    2

    Code:
    #!/bin/bash
    
    MAXIMIZED=$(wmctrl -lpG | grep -c "1630 1026")
    
    if [ "$MAXIMIZED" == "0" ]; then
    	notify-send "None Maximized"
    else
    	notify-send "$MAXIMIZED Maximized"
    
    fi
    Only seems to work when run in terminal though???
    Last edited by stinkeye; March 5th, 2012 at 06:39 PM.

  3. #3
    Join Date
    Jun 2010
    Beans
    699

    Re: Detecting maximized window(s) is this possible?

    I tried it and it works. Fantastic! Now could this be done.

    If output of command:

    Code:
    wmctrl -lpG | grep -c "x y"
    Returns 0 it reads:

    Code:
    gconftool-2 --get "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode"
    If output is not 0 then:

    Code:
    gconftool-2 --type int --set "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode" 0
    If output of command:

    Code:
    wmctrl -lpG | grep -c "x y"
    Is not 0 then it reads:

    Code:
    gconftool-2 --get "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode"
    If output is not 1 then:

    Code:
    gconftool-2 --type int --set "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode" 1
    I found it here:

    http://askubuntu.com/questions/41241...r-hide-setting

    And last but not least this should always run in the background and monitor behavior automatically and act accordingly. What would be the best way to do this? It's complex i know but i hope somebody knows the answer and solution and i hope it can be done and that it will work well too! Any suggestion?
    Last edited by EgoGratis; March 5th, 2012 at 06:39 PM.

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

    Re: Detecting maximized window(s) is this possible?

    I'm just an amateur "learn by mistakes" scripter so I'll leave it up to someone who will do it properly.
    Probably just need a while true; do loop to run in background.

  5. #5
    Join Date
    Jun 2010
    Beans
    699

    Re: Detecting maximized window(s) is this possible?

    I'm just an amateur "learn by mistakes" scripter
    That solved important piece of the puzzle! Thanks!

  6. #6
    Join Date
    Jun 2010
    Beans
    699

    Re: Detecting maximized window(s) is this possible?

    Based on your valuable input i managed to do this:

    Code:
    #!/bin/bash
    # Install wmctrl before using: sudo apt-get install wmctrl
    
    while true; do
    sleep 2 # Set delay
    
    SHOW_LAUNCHER=$(wmctrl -lpG | grep -c "x y") # Use wmctrl -lpG and find max value when Launcher is in neverhide mode
    HIDE_LAUNCHER=$(wmctrl -lpG | grep -c "x y") # Use wmctrl -lpG and find max value when Launcher is in autohide mode
    
    if [ $SHOW_LAUNCHER -eq 0 -a $HIDE_LAUNCHER -eq 0 ]
    then
        CURRENT=$(gconftool-2 --get "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode")
        if [ $CURRENT -ne 0 ]
        then
            gconftool-2 --type int --set "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode" 0
        fi
    else
        CURRENT=$(gconftool-2 --get "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode")
        if [ $CURRENT -ne 1 ]
        then
            gconftool-2 --type int --set "/apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode" 1
        fi
    fi
    done
    It works in Unity 3D on single screen/workspace and yes it "imitates" Dodge Windows in Ubuntu 12.04. For more advanced functionality more skillful programmer should probably use window manager to detect maximized widows (_NET_WM_STATE, ATOM[])

    http://standards.freedesktop.org/wm-...-spec-1.3.html

    And then show/hide launcher. And Launcher should be shown on screens/workspaces that have no maximized window(s)... But that is beyond the scope of this topic.

    Thanks!

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
  •