Skip to content

Commit

Permalink
Rename app launcher variables
Browse files Browse the repository at this point in the history
  • Loading branch information
friday committed Jan 14, 2022
1 parent 44735d8 commit 713a3cb
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions ulauncher/api/shared/action/LaunchAppAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,38 @@ def keep_app_open(self):
def run(self):
app = read_desktop_file(self.filename)
app_id = Path(self.filename).with_suffix('').stem
exec = app.get_string('Exec')
if not exec:
app_exec = app.get_string('Exec')
if not app_exec:
logger.error("No command to run %s", self.filename)
else:
# strip field codes %f, %F, %u, %U, etc
sanitized_exec = re.sub(r'\%[uUfFdDnNickvm]', '', exec).rstrip()
stripped_app_exec = re.sub(r'\%[uUfFdDnNickvm]', '', app_exec).rstrip()
terminal_exec = shlex.split(settings.get_property('terminal-command'))
if app.get_boolean('Terminal'):
if terminal_exec:
logger.info('Will run command in preferred terminal (%s)', terminal_exec)
sanitized_exec = terminal_exec + [sanitized_exec]
exec = terminal_exec + [stripped_app_exec]
else:
sanitized_exec = ['gtk-launch', app_id]
exec = ['gtk-launch', app_id]
else:
sanitized_exec = shlex.split(sanitized_exec)
exec = shlex.split(stripped_app_exec)
if runs_in_systemd and not app.get_boolean('X-Ulauncher-Inherit-Scope'):
logger.warning("Will attempt to launch the app using systemd-run with --scope argument")
logger.warning("This prevents the apps from terminating if Ulauncher crashes or is restarted.")
logger.warning("On some systems with outdated systemd or incorrect permissions this doesn't work.")
logger.warning("If this happens to you, don't run Ulauncher from systemd.")
sanitized_exec = [
'systemd-run',
'--user',
'--scope',
] + sanitized_exec
exec = ['systemd-run', '--user', '--scope'] + exec

env = dict(os.environ.items())
# Make sure GDK apps aren't forced to use x11 on wayland due to ulauncher's need to run
# under X11 for proper centering.
env.pop("GDK_BACKEND", None)

try:
logger.info('Run application %s (%s) Exec %s', app.get_name(), self.filename, exec)
logger.info('Run application %s (%s) Exec %s', app.get_name(), self.filename, app_exec)
envp = ["{}={}".format(k, v) for k, v in env.items()]
GLib.spawn_async(
argv=sanitized_exec,
argv=exec,
envp=envp,
flags=GLib.SpawnFlags.SEARCH_PATH_FROM_ENVP | GLib.SpawnFlags.SEARCH_PATH,
# setsid is really only needed if systemd-run is missing, but doesn't hurt to have.
Expand Down

0 comments on commit 713a3cb

Please sign in to comment.