Skip to content

Commit

Permalink
add additional sanity condition for isSupported method
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jul 16, 2024
1 parent 6ae79bb commit 2c0f834
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ public class FreedesktopAutoStartService implements AutoStartProvider {

private final Path autostartFile;
private final String content;
private final boolean hasExecValue;

public FreedesktopAutoStartService() {
var xdgConfigDirString = Objects.requireNonNullElse(System.getenv("XDG_CONFIG_HOME"), System.getProperty("user.home") + "/.config");
this.autostartFile = Path.of(xdgConfigDirString, "autostart", AUTOSTART_FILENAME);

var execValue = System.getProperty(CMD_PROPERTY);
if (execValue == null) {
LOG.debug("Property {} not set, using command path", CMD_PROPERTY);
LOG.debug("JVM property {} not set, using command path", CMD_PROPERTY);
execValue = ProcessHandle.current().info().command().orElse("");
}
this.hasExecValue = execValue.isBlank();
this.content = CONTENT_TEMPLATE.formatted(execValue, this.getClass().getName());
}

Expand Down Expand Up @@ -77,7 +79,7 @@ public synchronized boolean isEnabled() {
@CheckAvailability
public boolean isSupported() {
//TODO: might need to research which Desktop Environments support this
return Files.exists(autostartFile.getParent());
return hasExecValue && Files.exists(autostartFile.getParent());
}

}

0 comments on commit 2c0f834

Please sign in to comment.