mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-28 04:46:42 -04:00
Fix building for many non-Linux platforms
This commit is contained in:
+5
-3
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
package core
|
package core
|
||||||
|
|
||||||
|
import "github.com/rwinkhart/go-boilerplate/back"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
EntryRoot = Home + "\\AppData\\Local\\libmutton\\entries" // Path to libmutton entry directory
|
EntryRoot = back.Home + "\\AppData\\Local\\libmutton\\entries" // Path to libmutton entry directory
|
||||||
ConfigDir = Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
|
ConfigDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
|
||||||
ConfigPath = ConfigDir + "\\libmutton.ini" // Path to libmutton configuration file
|
ConfigPath = ConfigDir + "\\libmutton.ini" // Path to libmutton configuration file
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"golang.design/x/clipboard"
|
"golang.design/x/clipboard"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ import (
|
|||||||
func clipClearProcess(assignedContents string) {
|
func clipClearProcess(assignedContents string) {
|
||||||
clearClipboard := func() {
|
clearClipboard := func() {
|
||||||
clipboard.Write(clipboard.FmtText, []byte(""))
|
clipboard.Write(clipboard.FmtText, []byte(""))
|
||||||
Exit(0)
|
back.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if assignedContents is empty, clear the clipboard immediately and unconditionally
|
// if assignedContents is empty, clear the clipboard immediately and unconditionally
|
||||||
|
|||||||
+5
-3
@@ -4,15 +4,17 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
)
|
)
|
||||||
|
|
||||||
// copyString copies a string to the clipboard.
|
// copyString copies a string to the clipboard.
|
||||||
func copyString(continuous bool, copySubject string) {
|
func copyString(continuous bool, copySubject string) {
|
||||||
cmd := exec.Command("pbcopy")
|
cmd := exec.Command("pbcopy")
|
||||||
writeToStdin(cmd, copySubject)
|
back.WriteToStdin(cmd, copySubject)
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
back.PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !continuous {
|
if !continuous {
|
||||||
@@ -23,6 +25,6 @@ func copyString(continuous bool, copySubject string) {
|
|||||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||||
func getClipCommands() (*exec.Cmd, *exec.Cmd) {
|
func getClipCommands() (*exec.Cmd, *exec.Cmd) {
|
||||||
cmdClear := exec.Command("pbcopy")
|
cmdClear := exec.Command("pbcopy")
|
||||||
writeToStdin(cmdClear, "")
|
back.WriteToStdin(cmdClear, "")
|
||||||
return exec.Command("pbpaste"), cmdClear
|
return exec.Command("pbpaste"), cmdClear
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -4,15 +4,17 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
)
|
)
|
||||||
|
|
||||||
// copyString copies a string to the clipboard.
|
// copyString copies a string to the clipboard.
|
||||||
func copyString(continuous bool, copySubject string) {
|
func copyString(continuous bool, copySubject string) {
|
||||||
cmd := exec.Command("termux-clipboard-set")
|
cmd := exec.Command("termux-clipboard-set")
|
||||||
writeToStdin(cmd, copySubject)
|
back.WriteToStdin(cmd, copySubject)
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
back.PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !continuous {
|
if !continuous {
|
||||||
@@ -23,6 +25,6 @@ func copyString(continuous bool, copySubject string) {
|
|||||||
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
// getClipCommands returns the commands for pasting and clearing the clipboard contents.
|
||||||
func getClipCommands() (*exec.Cmd, *exec.Cmd) {
|
func getClipCommands() (*exec.Cmd, *exec.Cmd) {
|
||||||
cmdClear := exec.Command("termux-clipboard-set")
|
cmdClear := exec.Command("termux-clipboard-set")
|
||||||
writeToStdin(cmdClear, "")
|
back.WriteToStdin(cmdClear, "")
|
||||||
return exec.Command("termux-clipboard-get"), cmdClear
|
return exec.Command("termux-clipboard-get"), cmdClear
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -6,6 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
)
|
)
|
||||||
|
|
||||||
// copyString copies a string to the clipboard.
|
// copyString copies a string to the clipboard.
|
||||||
@@ -13,7 +15,7 @@ func copyString(continuous bool, copySubject string) {
|
|||||||
cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''")))
|
cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''")))
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
back.PrintError("Failed to copy to clipboard: "+err.Error(), ErrorClipboard, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !continuous {
|
if !continuous {
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ package core
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LaunchClipClearProcess launches the timed clipboard clearing process.
|
// LaunchClipClearProcess launches the timed clipboard clearing process.
|
||||||
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
|
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
|
||||||
func LaunchClipClearProcess(copySubject string) {
|
func LaunchClipClearProcess(copySubject string) {
|
||||||
cmd := exec.Command(os.Args[0], "clipclear")
|
cmd := exec.Command(os.Args[0], "clipclear")
|
||||||
writeToStdin(cmd, copySubject)
|
back.WriteToStdin(cmd, copySubject)
|
||||||
cmd.Start()
|
cmd.Start()
|
||||||
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
|
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,9 +26,9 @@ func WalkEntryDir() ([]string, []string) {
|
|||||||
// check for errors encountered while walking directory
|
// check for errors encountered while walking directory
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
core.PrintError("The entry directory does not exist - Initialize libmutton to create it", core.ErrorOther, true)
|
back.PrintError("The entry directory does not exist - Initialize libmutton to create it", back.ErrorOther, true)
|
||||||
} else {
|
} else {
|
||||||
core.PrintError("An unexpected error occurred while generating the entry list: "+err.Error(), core.ErrorOther, true)
|
back.PrintError("An unexpected error occurred while generating the entry list: "+err.Error(), back.ErrorOther, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user