diff options
author | Jason Cox <me@jasoncarloscox.com> | 2024-02-22 20:25:18 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-04-13 21:46:37 +0200 |
commit | f4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c (patch) | |
tree | 6ff89613c216acec4b4ded9d6a642f9d912a2bc7 /main.go | |
parent | 4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7 (diff) | |
download | aerc-f4cf6ca5c13fce8fe1f84f37cdafe62c1d2d8b0c.tar.gz |
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>
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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 |