mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-16 07:40:44 -07:00
feat: Added X11/Wayland detection for copy command (#10)
This commit is contained in:
parent
25b20b9f14
commit
8f2b3167d6
10
utils.go
10
utils.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
@ -22,9 +23,16 @@ func SetTermTitle(title string) {
|
||||
func CopyToClipboard(text string) {
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
exec.Command("sh", "-c",
|
||||
switch os.Getenv("XDG_SESSION_TYPE") {
|
||||
case "x11":
|
||||
exec.Command("sh", "-c",
|
||||
fmt.Sprintf("echo -n '%s' | xclip -selection clipboard", text)).
|
||||
Start()
|
||||
case "wayland":
|
||||
exec.Command("sh", "-c",
|
||||
fmt.Sprintf("echo -n '%s' | wl-copy", text)).
|
||||
Start()
|
||||
}
|
||||
case "darwin":
|
||||
exec.Command("sh", "-c",
|
||||
fmt.Sprintf("echo -n '%s' | pbcopy", text)).
|
||||
|
Loading…
x
Reference in New Issue
Block a user