mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-28 19:35:41 +00:00
More flatpak rework
This commit is contained in:
@@ -140,7 +140,7 @@ public interface ExternalApplicationType extends PrefsValue {
|
||||
|
||||
try (ShellControl pc = LocalShell.getShell()) {
|
||||
args.add(0, "flatpak", "run", "\"" + getFlatpakId() + "\"");
|
||||
pc.executeSimpleCommand(args);
|
||||
pc.command(args).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.xpipe.app.core.AppSystemInfo;
|
||||
import io.xpipe.app.ext.PrefsChoiceValue;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
import io.xpipe.app.process.CommandSupport;
|
||||
import io.xpipe.app.process.ShellScript;
|
||||
import io.xpipe.app.terminal.TerminalLaunch;
|
||||
import io.xpipe.app.process.LocalShell;
|
||||
@@ -461,7 +462,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
|
||||
LinuxPathType LEAFPAD = new LinuxPathType("app.leafpad", "leafpad", "https://snapcraft.io/leafpad");
|
||||
|
||||
LinuxPathType MOUSEPAD = new LinuxPathType("app.mousepad", "mousepad", "https://docs.xfce.org/apps/mousepad/start");
|
||||
LinuxPathType MOUSEPAD = new LinuxType("app.mousepad", "mousepad", "https://docs.xfce.org/apps/mousepad/start", "org.xfce.mousepad");
|
||||
|
||||
LinuxPathType PLUMA = new LinuxPathType("app.pluma", "pluma", "https://github.com/mate-desktop/pluma");
|
||||
ExternalEditorType TEXT_EDIT =
|
||||
@@ -729,4 +730,32 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
||||
return OsType.ofLocal() == OsType.LINUX;
|
||||
}
|
||||
}
|
||||
|
||||
class LinuxType extends GenericPathType implements ExternalApplicationType.LinuxApplication {
|
||||
|
||||
private final String flatpakId;
|
||||
|
||||
public LinuxType(String id, String executable, String website, String flatpakId) {
|
||||
super(id, executable, true, website);
|
||||
this.flatpakId = flatpakId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(Path file) throws Exception {
|
||||
var exec = CommandSupport.isInLocalPath(getExecutable()) || getFlatpakId() == null ?
|
||||
CommandBuilder.of().addFile(getExecutable()) :
|
||||
CommandBuilder.of().add("flatpak", "run").addQuoted(getFlatpakId());
|
||||
var builder = CommandBuilder.of().add(exec).addFile(file.toString());
|
||||
if (detach()) {
|
||||
ExternalApplicationHelper.startAsync(builder);
|
||||
} else {
|
||||
LocalShell.getShell().executeSimpleCommand(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlatpakId() throws Exception {
|
||||
return flatpakId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,40 +131,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||
.addFile(configuration.getScriptFile());
|
||||
}
|
||||
};
|
||||
ExternalTerminalType FOOT = new SimplePathType("app.foot", "foot", true) {
|
||||
@Override
|
||||
public TerminalOpenFormat getOpenFormat() {
|
||||
return TerminalOpenFormat.NEW_WINDOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWebsite() {
|
||||
return "https://codeberg.org/dnkl/foot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecommended() {
|
||||
return AppPrefs.get().terminalMultiplexer().getValue() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useColoredTitle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEscapes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandBuilder toCommand(TerminalLaunchConfiguration configuration) {
|
||||
return CommandBuilder.of()
|
||||
.add("--title")
|
||||
.addQuoted(configuration.getColoredTitle())
|
||||
.addFile(configuration.getScriptFile());
|
||||
}
|
||||
};
|
||||
ExternalTerminalType FOOT = new FootTerminalType();
|
||||
ExternalTerminalType ELEMENTARY = new SimplePathType("app.elementaryTerminal", "io.elementary.terminal", true) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package io.xpipe.app.terminal;
|
||||
|
||||
import io.xpipe.app.core.AppCache;
|
||||
import io.xpipe.app.core.AppSystemInfo;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class FootTerminalType implements ExternalTerminalType, ExternalApplicationType.LinuxApplication {
|
||||
|
||||
@Override
|
||||
public TerminalOpenFormat getOpenFormat() {
|
||||
return TerminalOpenFormat.NEW_WINDOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWebsite() {
|
||||
return "https://codeberg.org/dnkl/foot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecommended() {
|
||||
return AppPrefs.get().terminalMultiplexer().getValue() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useColoredTitle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsEscapes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(TerminalLaunchConfiguration configuration) throws Exception {
|
||||
var toExecute = CommandBuilder.of()
|
||||
.add("--title")
|
||||
.addQuoted(configuration.getColoredTitle())
|
||||
.addFile(configuration.getScriptFile());
|
||||
launch(toExecute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlatpakId() throws Exception {
|
||||
return "page.codeberg.dnkl.foot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExecutable() {
|
||||
return "foot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean detach() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "app.foot";
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,13 @@ package io.xpipe.app.terminal;
|
||||
import io.xpipe.app.core.AppCache;
|
||||
import io.xpipe.app.core.AppSystemInfo;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.ExternalApplicationType;
|
||||
import io.xpipe.app.process.CommandBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class KonsoleTerminalType extends ExternalTerminalType.SimplePathType {
|
||||
|
||||
public KonsoleTerminalType() {
|
||||
super("app.konsole", "konsole", true);
|
||||
}
|
||||
public class KonsoleTerminalType implements ExternalTerminalType, ExternalApplicationType.LinuxApplication {
|
||||
|
||||
@Override
|
||||
public TerminalOpenFormat getOpenFormat() {
|
||||
@@ -38,18 +35,14 @@ public class KonsoleTerminalType extends ExternalTerminalType.SimplePathType {
|
||||
@Override
|
||||
public void launch(TerminalLaunchConfiguration configuration) throws Exception {
|
||||
configureSingleInstanceMode();
|
||||
super.launch(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandBuilder toCommand(TerminalLaunchConfiguration configuration) {
|
||||
// Note for later: When debugging konsole launches, it will always open as a child process of
|
||||
// IntelliJ/XPipe even though we try to detach it.
|
||||
// This is not the case for production where it works as expected
|
||||
return CommandBuilder.of()
|
||||
var toExecute = CommandBuilder.of()
|
||||
.addIf(configuration.isPreferTabs(), "--new-tab")
|
||||
.add("-e")
|
||||
.addFile(configuration.getScriptFile());
|
||||
launch(toExecute);
|
||||
}
|
||||
|
||||
private synchronized void configureSingleInstanceMode() {
|
||||
@@ -79,4 +72,24 @@ public class KonsoleTerminalType extends ExternalTerminalType.SimplePathType {
|
||||
ErrorEventFactory.fromThrowable(e).handle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlatpakId() throws Exception {
|
||||
return "org.kde.konsole";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExecutable() {
|
||||
return "konsole";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean detach() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "app.konsole";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user