Add X11 daemon with tray status
This commit is contained in:
parent
3506770d09
commit
a7f50fed75
19 changed files with 1202 additions and 4 deletions
26
internal/clip/clipboard.go
Normal file
26
internal/clip/clipboard.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package clip
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func WriteClipboard(ctx context.Context, text string) error {
|
||||
if strings.TrimSpace(text) == "" {
|
||||
return errors.New("empty transcript")
|
||||
}
|
||||
|
||||
args := []string{"-selection", "clipboard", "-in", "-quiet", "-loops", "1"}
|
||||
cmd := exec.CommandContext(ctx, "xclip", args...)
|
||||
cmd.Stdin = strings.NewReader(text)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if len(out) > 0 {
|
||||
return errors.New(strings.TrimSpace(string(out)))
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue