Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Sometimes I face some problems in display and mostly I do want to know which files or processes are using the DISPLAY environment variable.

So how to list all processes that having DISPLAY set?

share|improve this question

1 Answer 1

After many searches and tries I came up to this command:

for file in /proc/[0-9]*; do grep -ao 'DISPLAY=[^[:cntrl:]]*' $file/environ 2>/dev/null && grep -ao '(.*)' $file/stat; done | sed 'N;s/\n/\t/'

A sample of the output is:

DISPLAY=:0  (unity-files-dae)
DISPLAY=:0  (unity-music-dae)
DISPLAY=:0  (unity-lens-vide)
DISPLAY=:0  (zeitgeist-daemo)
DISPLAY=:0  (zeitgeist-fts)
DISPLAY=:0  (zeitgeist-datah)
DISPLAY=:0  (cat)
DISPLAY=:0  (unity-scope-vid)
DISPLAY=:0  (unity-musicstor)
DISPLAY=:0  (dconf-service)
DISPLAY=:0  (gdu-notificatio)
DISPLAY=:0  (telepathy-indic)
DISPLAY=:0  (mission-control)
DISPLAY=:0  (goa-daemon)
DISPLAY=:0  (VBoxXPCOMIPCD)
share|improve this answer
1  
Nice solution. Could you please add some explanation for what happens behind the scene? Also, the output is cropt, what can I do to get full process names? –  Danatela Mar 11 at 8:57
1  
This command search recursively in the the /proc directory. grep for the DISPLAY in each file. Those files are in really the processes running so every file containing the word DISPLAY means that this process is using it. You can't get the full process name since the names in the output are the file names founded ion /proc so simply you can't know more than the offered. –  Ask Mar 11 at 9:04
    
PLease, edit your answer instead and just inform the user that you have updated your post. –  Braiam Mar 11 at 12:43

Your Answer

 
discard

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.