Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 5552  / 2 Years ago, thu, august 18, 2022, 10:51:56

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.


More From » xorg

 Answers
6

Running xprop _NET_WM_PID from a terminal will put X into a special mode where you can click on a window to get that window's PID in the terminal.


Then run ls -l /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:
try:
return int(out.split()[-1])
except ValueError:
return -1
else:
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'
else:
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.


[#34021] Friday, August 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
unsmmoth

Total Points: 72
Total Questions: 113
Total Answers: 95

Location: Thailand
Member since Tue, Oct 6, 2020
4 Years ago
;