diff options
| author | Reto Brunner <reto@labrat.space> | 2019-09-29 12:08:59 +0200 | 
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2019-09-29 12:36:35 -0400 | 
| commit | f15811a737ee8d93f22ceff620df145c2d252b15 (patch) | |
| tree | 7f5329e27cd73236c6688bfd2dd3cebe403c67b0 | |
| parent | 70c16fc34609893eadabd9a31adb4396931552a5 (diff) | |
Open mailto links in a new aerc instance if needed.
Aerc tries to open mailto:// links via the socket of the already running aerc
instance.
If no socket exists this silently errored out.
This commit starts up a new aerc instance if it can't connect to the socket
(which I think is the most common error) and if not sets up a new aerc instance
and retries to open the compositor.
This fixes https://todo.sr.ht/~sircmpwn/aerc2/295 by implementing the desired
behaviour.
| -rw-r--r-- | aerc.go | 19 | 
1 files changed, 17 insertions, 2 deletions
| @@ -105,13 +105,26 @@ func main() {  			return  		}  	} +	initDone := make(chan struct{})  	args := os.Args[optind:]  	if len(args) > 1 {  		usage()  		return  	} else if len(args) == 1 { -		lib.ConnectAndExec(args[0]) -		return +		arg := args[0] +		err := lib.ConnectAndExec(arg) +		if err == nil { +			return // other aerc instance takes over +		} +		fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err) +		// continue with setting up a new aerc instance and retry after init +		go func(msg string) { +			<-initDone +			err := lib.ConnectAndExec(msg) +			if err != nil { +				fmt.Fprintf(os.Stderr, "Failed to communicate to aerc: %v", err) +			} +		}(arg)  	}  	var ( @@ -163,6 +176,8 @@ func main() {  		as.OnMailto = aerc.Mailto  	} +	close(initDone) +  	for !ui.ShouldExit() {  		for aerc.Tick() {  			// Continue updating our internal state | 
