Add X11 daemon with tray status
This commit is contained in:
parent
3506770d09
commit
a7f50fed75
19 changed files with 1202 additions and 4 deletions
45
cmd/lelctl/main.go
Normal file
45
cmd/lelctl/main.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if flag.NArg() == 0 {
|
||||
fmt.Fprintln(os.Stderr, "usage: lelctl <status|stop|reload>")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cmd := strings.TrimSpace(flag.Arg(0))
|
||||
if cmd == "" {
|
||||
fmt.Fprintln(os.Stderr, "invalid command")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
|
||||
if runtimeDir == "" {
|
||||
runtimeDir = "/tmp"
|
||||
}
|
||||
sockPath := filepath.Join(runtimeDir, "lel", "ctl.sock")
|
||||
|
||||
conn, err := net.Dial("unix", sockPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "connect failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
_, _ = fmt.Fprintf(conn, "%s\n", cmd)
|
||||
|
||||
buf := make([]byte, 4096)
|
||||
n, _ := conn.Read(buf)
|
||||
if n > 0 {
|
||||
fmt.Print(string(buf[:n]))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue