mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-16 15:50:52 -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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
@ -22,9 +23,16 @@ func SetTermTitle(title string) {
|
|||||||
func CopyToClipboard(text string) {
|
func CopyToClipboard(text string) {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
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)).
|
fmt.Sprintf("echo -n '%s' | xclip -selection clipboard", text)).
|
||||||
Start()
|
Start()
|
||||||
|
case "wayland":
|
||||||
|
exec.Command("sh", "-c",
|
||||||
|
fmt.Sprintf("echo -n '%s' | wl-copy", text)).
|
||||||
|
Start()
|
||||||
|
}
|
||||||
case "darwin":
|
case "darwin":
|
||||||
exec.Command("sh", "-c",
|
exec.Command("sh", "-c",
|
||||||
fmt.Sprintf("echo -n '%s' | pbcopy", text)).
|
fmt.Sprintf("echo -n '%s' | pbcopy", text)).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user