mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-30 22:06:32 -04:00
Handle error for failing to read clipboard contents on all platforms
This commit is contained in:
@@ -40,12 +40,16 @@ func clipClear(oldContents string) {
|
|||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
|
|
||||||
cmd := exec.Command("pbpaste")
|
cmd := exec.Command("pbpaste")
|
||||||
newContents, _ := cmd.Output()
|
newContents, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(AnsiError + "Failed to read clipboard contents: " + err.Error() + AnsiReset)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
||||||
cmd = exec.Command("pbcopy")
|
cmd = exec.Command("pbcopy")
|
||||||
writeToStdin(cmd, "")
|
writeToStdin(cmd, "")
|
||||||
err := cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -38,12 +38,16 @@ func clipClear(oldContents string) {
|
|||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
|
|
||||||
cmd := exec.Command("termux-clipboard-get")
|
cmd := exec.Command("termux-clipboard-get")
|
||||||
newContents, _ := cmd.Output()
|
newContents, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(AnsiError + "Failed to read clipboard contents: " + err.Error() + AnsiReset)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
||||||
cmd = exec.Command("termux-clipboard-set")
|
cmd = exec.Command("termux-clipboard-set")
|
||||||
writeToStdin(cmd, "")
|
writeToStdin(cmd, "")
|
||||||
err := cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -37,11 +37,15 @@ func clipClear(oldContents string) {
|
|||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
|
|
||||||
cmd := exec.Command("powershell.exe", "-c", "Get-Clipboard")
|
cmd := exec.Command("powershell.exe", "-c", "Get-Clipboard")
|
||||||
newContents, _ := cmd.Output()
|
newContents, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(AnsiError + "Failed to read clipboard contents: " + err.Error() + AnsiReset)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
if oldContents == strings.TrimRight(string(newContents), "\r\n") {
|
||||||
cmd = exec.Command("powershell.exe", "-c", "Set-Clipboard")
|
cmd = exec.Command("powershell.exe", "-c", "Set-Clipboard")
|
||||||
err := cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
fmt.Println(AnsiError + "Failed to clear clipboard: " + err.Error() + AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user