aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-22 20:25:18 -0500
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:46:37 +0200
commitf4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c (patch)
tree6ff89613c216acec4b4ded9d6a642f9d912a2bc7
parent4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7 (diff)
downloadaerc-f4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c.tar.gz
aerc-f4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c.zip
ipc: add --no-ipc flag to completely disable IPC
Running aerc mailto:... and aerc mbox:... can be confusing; if there's another aerc instance already open, the action will be performed in the other instance, which may not be visible. Add a --no-ipc flag that runs these actions, and aerc-internal commands (i.e., aerc :<command>), in the new aerc instance instead. Also, if --no-ipc is passed, don't listen on a socket for IPC calls from other aerc instances. Changelog-added: Add `--no-ipc` flag to run `aerc mailto:...`, `aerc mbox:...`, and `aerc :<command...>` within the current aerc instance and prevent listening for IPC calls from other aerc instances. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--doc/aerc.1.scd19
-rw-r--r--main.go20
2 files changed, 30 insertions, 9 deletions
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 3f52fbac..5511e79e 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -36,11 +36,20 @@ from your terminal.
Instead of using _$XDG_CONFIG_HOME/aerc/binds.conf_ use the file at the
specified path for configuring binds.
+*--no-ipc*
+ Run commands (*mailto:*_..._, *:*_<command...>_, *mbox:*_<file>_) directly
+ in this instance rather than over IPC in an existing aerc instance. Also
+ disable creation of an IPC server for subsequent aerc instances to
+ communicate with this one.
+
*mailto:*_address[,address][?query[&query]]_
Open the composer with the address(es) in the To field. These
addresses must not be percent encoded.
- If aerc is already running, the composer is started in this instance,
- otherwise aerc will be started.
+
+ If aerc is already running (and *--no-ipc* is not passed), the composer is
+ started in that instance; otherwise a new instance is started with the
+ composer.
+
The following (optional) query parameters are supported:
[[ *Query*
@@ -75,9 +84,15 @@ from your terminal.
directly on aerc's command line. This latter form can be helpful for
commands that don't interpret quotes in their arguments.
+ If aerc is already running (and *--no-ipc* is not passed), the command is
+ run in that instance; otherwise a new instance is started with the command.
+
*mbox:*_<file>_
Open the specified mbox file as a virtual temporary account.
+ If aerc is already running (and *--no-ipc* is not passed), the file is
+ opened in that instance; otherwise a new instance is started with the file.
+
# RUNTIME COMMANDS
To execute a command, press *:* to bring up the command interface. Commands may
diff --git a/main.go b/main.go
index cc65dc44..9558382b 100644
--- a/main.go
+++ b/main.go
@@ -102,6 +102,7 @@ type Opts struct {
ConfAerc string `opt:"--aerc-conf"`
ConfAccounts string `opt:"--accounts-conf"`
ConfBinds string `opt:"--binds-conf"`
+ NoIPC bool `opt:"--no-ipc"`
Command []string `opt:"..." required:"false" metavar:"mailto:<address> | mbox:<file> | :<command...>"`
}
@@ -121,6 +122,8 @@ Options:
--aerc-conf Path to configuration file to be used instead of the default.
--accounts-conf Path to configuration file to be used instead of the default.
--binds-conf Path to configuration file to be used instead of the default.
+ --no-ipc Run any commands in this aerc instance, and don't create a
+ socket for other aerc instances to communicate with this one.
mailto:<address> Open the composer with the address(es) in the To field.
If aerc is already running, the composer is started in
this instance, otherwise aerc will be started.
@@ -159,7 +162,7 @@ func main() {
die("%s", err)
}
- if len(opts.Command) > 0 {
+ if len(opts.Command) > 0 && !opts.NoIPC {
response, err := ipc.ConnectAndExec(opts.Command)
if err == nil {
if response.Error != "" {
@@ -202,11 +205,13 @@ func main() {
startup, startupDone := context.WithCancel(context.Background())
- as, err := ipc.StartServer(app.IPCHandler(), startup)
- if err != nil {
- log.Warnf("Failed to start Unix server: %v", err)
- } else {
- defer as.Close()
+ if !opts.NoIPC {
+ as, err := ipc.StartServer(app.IPCHandler(), startup)
+ if err != nil {
+ log.Warnf("Failed to start Unix server: %v", err)
+ } else {
+ defer as.Close()
+ }
}
// set the aerc version so that we can use it in the template funcs
@@ -218,7 +223,8 @@ func main() {
return
}
// Retry execution. Since IPC has already failed, we know no
- // other aerc instance is running; run the command directly.
+ // other aerc instance is running (or IPC was explicitly
+ // disabled); run the command directly.
err := app.Command(opts.Command)
if err != nil {
// no other aerc instance is running, so let