Skip to content

Commit

Permalink
don't bail out of get_linux_apps if one desktop file fails (#1229)
Browse files Browse the repository at this point in the history
I have experienced this with a desktop file that contains
`Terminal=false` twice for some reason

---------

Co-authored-by: Jeff Knaus <knaus.jeff@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 15, 2023
1 parent 9acb6c9 commit 6f2d285
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions core/app_switcher/app_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,28 @@ def get_linux_apps():
if os.path.isdir(base):
for entry in os.scandir(base):
if entry.name.endswith(".desktop"):
config = configparser.ConfigParser(interpolation=None)
config.read(entry.path)
# only parse shortcuts that are not hidden
if config.has_option("Desktop Entry", "NoDisplay") == False:
name_key = config["Desktop Entry"]["Name"]
exec_key = config["Desktop Entry"]["Exec"]
# remove extra quotes from exec
if exec_key[0] == '"' and exec_key[-1] == '"':
exec_key = re.sub('"', "", exec_key)
# remove field codes and add full path if necessary
if exec_key[0] == "/":
items[name_key] = re.sub(args_pattern, "", exec_key)
else:
items[name_key] = "/usr/bin/" + re.sub(
args_pattern, "", exec_key
)
try:
config = configparser.ConfigParser(interpolation=None)
config.read(entry.path)
# only parse shortcuts that are not hidden
if config.has_option("Desktop Entry", "NoDisplay") == False:
name_key = config["Desktop Entry"]["Name"]
exec_key = config["Desktop Entry"]["Exec"]
# remove extra quotes from exec
if exec_key[0] == '"' and exec_key[-1] == '"':
exec_key = re.sub('"', "", exec_key)
# remove field codes and add full path if necessary
if exec_key[0] == "/":
items[name_key] = re.sub(args_pattern, "", exec_key)
else:
items[name_key] = "/usr/bin/" + re.sub(
args_pattern, "", exec_key
)
except:
print(
"get_linux_apps: skipped parsing application file ",
entry.name,
)
return items


Expand Down

0 comments on commit 6f2d285

Please sign in to comment.