How can I list open windows on the command line?

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
bitrat
Posts: 99
Joined: 2023-07-20 09:41
Has thanked: 5 times

How can I list open windows on the command line?

#1 Post by bitrat »

Hi,

I'd like to list all open windows/tabs of an application, along with some details like title and open files.

For example, I'd like to list all folders currently open in Thunar.

I can do something like wiw for atril with:
pstree -al | grep atril | grep '\.pdf$'
 |   |-atril /home/user/Desktop/out/all.pdf

Or (with room for improvement!):
$ lsof -u user | grep -i atril | grep '/home/user' | grep '\.pdf$'
lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing
      Output information may be incomplete.
atril     1302119 user   16r      REG               8,19     74847    5809542 /home/user/Desktop/out/all.pdf

This is for something like a session manager. Does the existing session manager have a cli?

I don't mind using a different method for different apps, just looking for ideas really. If any tool comes to mind that might be useful, please mention it.

Related: is there a way to show the full path of the current folder in Thunar's title bar? Mine only shows the folder name. (Alternatively, can I get the Location Bar contents?)

PS: I'm using xfce with lightdm and Xorg.
Last edited by bitrat on 2024-05-24 21:25, edited 1 time in total.

lindi
Debian Developer
Debian Developer
Posts: 482
Joined: 2022-07-12 14:10
Has thanked: 2 times
Been thanked: 91 times

Re: How can I list open windows on the command line?

#2 Post by lindi »

Are you using gnome with wayland or something different?

bitrat
Posts: 99
Joined: 2023-07-20 09:41
Has thanked: 5 times

Re: How can I list open windows on the command line?

#3 Post by bitrat »

lindi wrote: 2024-05-24 21:14 Are you using gnome with wayland or something different?
Oh, sorry, I should have said! I'm using xfce with lightdm and Xorg.

User avatar
sunrat
Administrator
Administrator
Posts: 6747
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 122 times
Been thanked: 541 times

Re: How can I list open windows on the command line?

#4 Post by sunrat »

@bitrat use code tags for terminal commands please, not preformatted text.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

CwF
Global Moderator
Global Moderator
Posts: 2795
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 47 times
Been thanked: 217 times

Re: How can I list open windows on the command line?

#5 Post by CwF »

bitrat wrote: 2024-05-24 18:43 I'd like to list all open windows/tabs of an application
Take a look at

Code: Select all

$  man xwininfo

bitrat
Posts: 99
Joined: 2023-07-20 09:41
Has thanked: 5 times

Re: How can I list open windows on the command line?

#6 Post by bitrat »

Thanks! I did have a look at xwininfo, and it's probably as close as I'll get with any existing utility. :)

I'm thinking something like 'strings' that would just recurse through child windows and spit out whatever text elements it found...

Post Reply