main: set xterm title

Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2021-11-02 10:40:08 +01:00
parent bc48628839
commit 138977b2ce
1 changed files with 19 additions and 0 deletions

19
aerc.go
View File

@ -8,6 +8,7 @@ import (
"os" "os"
"runtime/debug" "runtime/debug"
"sort" "sort"
"strings"
"time" "time"
"git.sr.ht/~sircmpwn/getopt" "git.sr.ht/~sircmpwn/getopt"
@ -94,6 +95,20 @@ func usage() {
log.Fatal("Usage: aerc [-v] [mailto:...]") log.Fatal("Usage: aerc [-v] [mailto:...]")
} }
var termsWithStatusLine = []string{"xterm", "tmux", "screen"}
func setWindowTitle() {
term := strings.ToLower(os.Getenv("TERM"))
for _, t := range termsWithStatusLine {
if strings.Contains(term, t) {
// TODO: avoid hard coding the list of terminals that
// have status line support.
os.Stderr.Write([]byte("\x1b]0;aerc\a"))
return
}
}
}
func main() { func main() {
opts, optind, err := getopt.Getopts(os.Args, "v") opts, optind, err := getopt.Getopts(os.Args, "v")
if err != nil { if err != nil {
@ -190,6 +205,10 @@ func main() {
close(initDone) close(initDone)
if isatty.IsTerminal(os.Stderr.Fd()) {
setWindowTitle()
}
for !ui.ShouldExit() { for !ui.ShouldExit() {
for aerc.Tick() { for aerc.Tick() {
// Continue updating our internal state // Continue updating our internal state