Results 1 to 5 of 5

Thread: Command for the Currently Active Window?

  1. #1
    Join Date
    Jan 2012
    Beans
    36

    Command for the Currently Active Window?

    Is there a command that returns the currently active window?

    I using ubuntu 11.10 and it seems that compiz is my window manager by default.

    Basically I want the terminal to return whatever string is in the menu bar at the top of my screen. Python code would also do the the trick.

  2. #2
    Join Date
    Nov 2009
    Location
    Los Angeles
    Beans
    393
    Distro
    Ubuntu

    Re: Command for the Currently Active Window?


  3. #3
    Join Date
    Jan 2012
    Beans
    36

    Re: Command for the Currently Active Window?

    Now I installed wmctrl. But what's the command that returns the name of the active window?

    The closest I can find is a string with all managed windows:

    aqil@Computer:~$ wmctrl -l
    0x02200004 0 Computer Desktop
    0x02600002 0 N/A DNDCollectionWindow
    0x02600003 0 N/A launcher
    0x02600004 0 N/A panel
    0x03200044 0 Computer wmctrl - A command line tool to interact with an EWMH/NetWM compatible X Window Manager. - Chromium
    0x02600005 0 N/A Dash
    0x0420008e 0 Computer Trigonometry.odt - LibreOffice Writer
    0x04800006 0 Computer aqil@Computer: ~
    That's great! But is there also any way to get the one and only window currently active? From the string above, there seems to be no telling which window was open when the command was executed.

    Thanks!

  4. #4
    Join Date
    Nov 2009
    Location
    Los Angeles
    Beans
    393
    Distro
    Ubuntu

    Re: Command for the Currently Active Window?

    For many options you can use the :ACTIVE: keyword to act on the topmost window:
    http://abhijeetmaharana.com/blog/2007/06/22/wmctrl/

    e.g.:
    wmctrl -r :ACTIVE: -b toggle,fullscreen

    That seems to work for me with what I've been doing with wmctrl, but according to this page in some cases a workaround may be required - the last post here describes a way of tricking wmctrl to obtain the ID of the topmost window if ":ACTIVE:" isn't doing what you need:
    http://stackoverflow.com/questions/4...ives-to-wmctrl

  5. #5
    Join Date
    Jan 2012
    Beans
    36

    Re: Command for the Currently Active Window?

    Well, this is more complicated than what I'm used to but it sure gives me something to work on. There seems to be no command to simply print the active window, but the workaround is working for me so I'll keep working on that. Thank You rg4w!

Tags for this Thread

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
  •