Skip to content

Commit

Permalink
sysutil: non-Linux OS support (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsiegert committed Mar 22, 2023
1 parent 78ded57 commit 78df8c8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sysutil/clipboard/clipboard.go
Expand Up @@ -198,7 +198,7 @@ func (c *Clipboard) ReadTo(w io.Writer) error {

// Available check
func (c *Clipboard) Available() bool {
return c.writeable && c.readable
return c.writeable && c.readable && available()
}

// Writeable check
Expand Down
2 changes: 2 additions & 0 deletions sysutil/clipboard/util_darwin.go
Expand Up @@ -11,3 +11,5 @@ func GetWriterBin() string {
func GetReaderBin() string {
return ReaderOnMac
}

func available() bool { return true }
7 changes: 7 additions & 0 deletions sysutil/clipboard/util_unix.go
Expand Up @@ -2,6 +2,8 @@

package clipboard

import "os"

// GetWriterBin program name
func GetWriterBin() string {
return WriterOnLin
Expand All @@ -11,3 +13,8 @@ func GetWriterBin() string {
func GetReaderBin() string {
return ReaderOnLin
}

func available() bool {
// X clipboard is unavailable when not under X.
return os.Getenv("DISPLAY") != ""
}
2 changes: 2 additions & 0 deletions sysutil/clipboard/util_windows.go
Expand Up @@ -11,3 +11,5 @@ func GetWriterBin() string {
func GetReaderBin() string {
return ReaderOnWin
}

func available() bool { return true }
2 changes: 2 additions & 0 deletions sysutil/sysutil_linux.go → sysutil/sysutil_unix.go
@@ -1,3 +1,5 @@
//go:build !windows && !darwin

package sysutil

import (
Expand Down

0 comments on commit 78df8c8

Please sign in to comment.