import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
+import org.asamk.signal.DbusConfig;
import org.asamk.signal.OutputType;
import org.asamk.signal.ReceiveMessageHandler;
import org.asamk.signal.Shutdown;
subparser.addArgument("--dbus-system", "--system")
.action(Arguments.storeTrue())
.help("Expose a DBus interface on the system bus.");
+ subparser.addArgument("--bus-name")
+ .setDefault(DbusConfig.getBusname())
+ .help("Specify the D-Bus bus name to connect to.");
subparser.addArgument("--socket")
.nargs("?")
.type(File.class)
final var isDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
if (isDbusSystem) {
- daemonHandler.runDbus(true);
+ final var busName = ns.getString("bus-name");
+ daemonHandler.runDbus(true, busName);
}
final var isDbusSession = Boolean.TRUE.equals(ns.getBoolean("dbus"));
- if (isDbusSession || (
- !isDbusSystem
- && socketFile == null
- && tcpAddress == null
- && httpAddress == null
- && inheritedChannel == null
- )) {
+ if (isDbusSession) {
+ final var busName = ns.getString("bus-name");
+ daemonHandler.runDbus(false, busName);
+ }
+
+ if (!isDbusSystem
+ && !isDbusSession
+ && socketFile == null
+ && tcpAddress == null
+ && httpAddress == null
+ && inheritedChannel == null) {
logger.warn(
- "Running daemon command without explicit mode is deprecated. Use --dbus to use the dbus interface.");
- daemonHandler.runDbus(false);
+ "Running daemon command without explicit mode is deprecated. Use 'daemon --dbus' to use the dbus interface.");
+ daemonHandler.runDbus(false, DbusConfig.getBusname());
}
}
public abstract void runSocket(ServerSocketChannel serverChannel) throws CommandException;
- public abstract void runDbus(boolean isDbusSystem) throws CommandException;
+ public abstract void runDbus(boolean isDbusSystem, final String busname) throws CommandException;
public abstract void runHttp(InetSocketAddress address) throws CommandException;
}
@Override
- public void runDbus(final boolean isDbusSystem) throws CommandException {
- runDbus(new DbusHandler(isDbusSystem, m, receiveMode != ReceiveMode.ON_START));
+ public void runDbus(final boolean isDbusSystem, final String busname) throws CommandException {
+ runDbus(new DbusHandler(isDbusSystem, busname, m, receiveMode != ReceiveMode.ON_START));
}
@Override
}
@Override
- public void runDbus(final boolean isDbusSystem) throws CommandException {
- runDbus(new DbusHandler(isDbusSystem, c, receiveMode != ReceiveMode.ON_START));
+ public void runDbus(final boolean isDbusSystem, final String busname) throws CommandException {
+ runDbus(new DbusHandler(isDbusSystem, busname, c, receiveMode != ReceiveMode.ON_START));
}
@Override