-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (47 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Wrapper around f+ or f- intended to be invoked from a tool like skhd
Usage of font:
-op string
font operation to execute: inc, dec (default "inc")
*/
package main
import (
"flag"
"fmt"
"os"
"os/exec"
"strings"
"github.com/dnjp/nyne"
)
var op = flag.String("op", "inc", "font operation to execute: inc, dec")
func main() {
flag.Parse()
os.Unsetenv("winid") // do not trust the execution environment
winid, err := nyne.FocusedWinID(nyne.FocusedWinAddr())
if err != nil {
panic(err)
}
wins, err := nyne.Windows()
if err != nil {
panic(err)
}
w, ok := wins[winid]
if !ok {
panic(fmt.Errorf("could not find window with id %d", winid))
}
var cmd string
if strings.ToLower(*op) == "dec" {
cmd = "f-"
} else {
cmd = "f+"
}
font := exec.Command(cmd)
font.Env = os.Environ()
font.Env = append(font.Env, fmt.Sprintf("winid=%d", winid))
font.Env = append(font.Env, fmt.Sprintf("%%=%s", w.File))
font.Env = append(font.Env, fmt.Sprintf("samfile=%s", w.File))
err = font.Run()
if err != nil {
panic(err)
}
}