0

How can I list all .desktop files in usr/share/applications using 'ls /usr/share/applications' command and make it a list variable in python3.7?

like

list1 = replayof('command')
print1 = list(list1)
print(print1)

1 Answer 1

0

It's not trivial to understand your question, and it's probably the wrong stackexchange for this, because it's more python than Ubuntu.

That being said, I believe the code you are looking for is

import os
print(os.listdir('/usr/share/applications'))

Unless your question is really about how to list all files that end in .desktop? Then it would be

ls /usr/share/applications/*.desktop.

For more on this, you may want to look into wildcards and globbing.

I'll leave the list part as an exercise to the reader.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .