mirror of
https://github.com/taigrr/wtf
synced 2026-03-22 19:22:18 -07:00
Expose the widget dimensions to commands in cmdrunner
This commit is contained in:
@@ -3,6 +3,7 @@ package cmdrunner
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -108,6 +109,7 @@ func (widget *Widget) execute() {
|
||||
// Setup the command to run
|
||||
cmd := exec.Command(widget.settings.cmd, widget.settings.args...)
|
||||
cmd.Stdout = widget
|
||||
cmd.Env = widget.environment()
|
||||
|
||||
// Run the command and wait for it to exit in another Go-routine
|
||||
go func() {
|
||||
@@ -134,3 +136,13 @@ func (widget *Widget) drainLines(n int) {
|
||||
widget.buffer.ReadBytes('\n')
|
||||
}
|
||||
}
|
||||
|
||||
func (widget *Widget) environment() []string {
|
||||
envs := os.Environ()
|
||||
envs = append(
|
||||
envs,
|
||||
fmt.Sprintf("WTF_WIDGET_WIDTH=%d", widget.settings.width),
|
||||
fmt.Sprintf("WTF_WIDGET_HEIGHT=%d", widget.settings.height),
|
||||
)
|
||||
return envs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user