Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just reading »How to revert to GNOME Classic?«. Some answers say that you should press Alt+Win to get the Add to panel dialogue. However my keyboard has no Win. So I was asking myself how to start the Add to panel window. Usually the best way is to enter the program name into a terminal. In this case I can't figure out the name.

I tested it on another computer and couldn't find the name in the process list. Also xwininfo or similar programs shoed no name. So what is the best way to figure out the name of the program which opened a (X) window.

share|improve this question
up vote 4 down vote accepted

You can use xprop _NET_WM_PID to get the window's PID, then run ll /proc/<pid>/exe and look at where the link is to to figure out what the program's file name is.

The following is a little python script take from a program I'm working on:

#! /usr/bin/env python

import os, subprocess

# Function based on code from apport
def get_window_pid():
    xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (out, err) = xprop.communicate()
    if xprop.returncode == 0:
            return int(out.split()[-1])
        except ValueError:
            return -1
        return -1

def get_window_exe():
    pid = get_window_pid()

    if pid == -1:
        return ''

    return os.path.realpath('/proc/' + str(pid) + '/exe')

if __name__=='__main__':
    exe = get_window_exe()
    if exe == '':
        print 'Unable to identify window\'s executable' 
        print exe

Save this into a file and run by typing python <filename>.py. Click on the window and it will print the program's name.

share|improve this answer

Based on iBelieve's answer:

alias fxname='basename $(ll /proc/$(xprop _NET_WM_PID | awk "{print \$NF}")/exe | awk "{print \$NF}")'

The $NF in the awk commands must be escaped so it's not interpreted as a shell variable. As soon as you run it a reticle will appear for you to click on the desired window.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.