42

ps ax shows all the running processes. I want to do something similar, but instead of the names of the actual processes, I want the window names listed instead. What Linux command will do this?

tony_sid
  • 14,001
  • 51
  • 139
  • 194

4 Answers4

57

wmctrl -l may be what you're looking for. The wmctrl program can also perform some simple actions on the windows like moving them around and setting their properties.

Cristian Ciupitu
  • 5,513
  • 2
  • 37
  • 47
Gilles 'SO- stop being evil'
  • 69,786
  • 21
  • 137
  • 178
24

xlsclients shows the running clients and xwininfo -root -children shows all children of the root window. That also includes some stuff your window manager or desktop renders.

Aaron Digulla
  • 6,925
  • 8
  • 45
  • 66
7

Here is the way to show names only:

wmctrl -l|awk '{$3=""; $2=""; $1=""; print $0}'

because wmctrl -l shows a bit extra info rather than just names required in the question:

like this:

0x020002c6  0 ruslan-Latitude-E6410 fromscratch
0x04600007  0 ruslan-Latitude-E6410 Psensor - Temperature Monitor
0x01600007  0 ruslan-Latitude-E6410 Top Expanded Edge Panel
0x01600017  0 ruslan-Latitude-E6410 Bottom Expanded Edge Panel
0x0200000a -1 ruslan-Latitude-E6410 Desktop
0x05a0000c  0 ruslan-Latitude-E6410 ruslan@ruslan-Latitude-E6410: /var/lib/apt
0x05600085  0 ruslan-Latitude-E6410 index.html (~/Dropbox/cpucraft.com/fromscratch) - gedit

and filtering it by awk we get only names of open windows:

   fromscratch
   Psensor - Temperature Monitor
   Top Expanded Edge Panel
   Bottom Expanded Edge Panel
   Desktop
   ruslan@ruslan-Latitude-E6410: /var/lib/apt
   index.html (~/Dropbox/cpucraft.com/fromscratch) - gedit
   ubuntu - Get a list of open windows in Linux - Super User - Mozilla Firefox
   [email protected] - FileZilla
Ruslan Gerasimov
  • 2,156
  • 1
  • 15
  • 12
4

If you want simply the titles and no other information (not even whitespace), you can use this:

wmctrl -l | grep -o "$HOSTNAME.*" | sed "s/$HOSTNAME //g"

Result:

linux - How to grep and replace - Stack Overflow - Pale Moon
How can I use a variable in sed? | Unix Linux Forums | Shell Programming and Scripting - Pale Moon
Delete everything after characters * or # or & in text file with GREP - Stack Overflow - Pale Moon
Video.mp4 - VLC Media Player
Smile4ever
  • 259
  • 2
  • 11