2
0

2 Коммитууд eff16582d8 ... d16df76afc

Эзэн SHA1 Мессеж Огноо
  blackwine d16df76afc becoming a party pig 3 долоо хоног өмнө
  blackwine eff16582d8 becoming a party pig 3 долоо хоног өмнө
5 өөрчлөгдсөн 75 нэмэгдсэн , 23 устгасан
  1. 2 2
      Makefile
  2. 71 0
      at-osc/main.go
  3. 0 8
      bar.go
  4. 1 12
      media.go
  5. 1 1
      ovly.go

+ 2 - 2
Makefile

@@ -23,6 +23,6 @@ build/$(service).%: $(wildcard **.go)
 	$(dir_guard)
 	GOOS=$(word 1, $(subst _, ,$*)) GOARCH=$(word 2, $(subst _, ,$*)) go build -o $@ .
 
-build/osc@.%: $(wildcard msg/**.go)
+build/@osc.%: $(wildcard at-osc/**.go)
 	$(dir_guard)
-	GOOS=$(word 1, $(subst _, ,$*)) GOARCH=$(word 2, $(subst _, ,$*)) go build -o $@ ./msg
+	GOOS=$(word 1, $(subst _, ,$*)) GOARCH=$(word 2, $(subst _, ,$*)) go build -o $@ ./at-osc

+ 71 - 0
at-osc/main.go

@@ -0,0 +1,71 @@
+// @osc: the OSC client 
+
+package main
+
+import (
+	"log"
+	"os"
+	"strconv"
+	"github.com/hypebeast/go-osc/osc"
+)
+
+func main() {
+	// Check if we have all the required argumets to send the OSC message
+	if len(os.Args) < 2 {
+		log.New(os.Stderr, "", 0).Fatal("Usage: ", os.Args[0], " /osc/address [message...]")
+	}
+
+	host := os.Getenv("athost")
+	if host == "" {
+		host = "localhost"
+	}
+	atport := os.Getenv("atport")
+	port, err := strconv.Atoi(atport)
+	if err != nil {
+		port = 9137
+	}
+
+	client := osc.NewClient(host, port)
+	msg := osc.NewMessage(os.Args[1])
+
+	have_string := false
+	have_blob := false
+	for _, arg := range os.Args[2:] {
+		if have_string {
+			msg.Append(arg)
+			have_string = false
+			//log.Println("Parsed string:", arg)
+		} else if arg == "-s" {
+			have_string = true
+		} else if have_blob {
+			content, err := os.ReadFile(arg)
+			if err != nil {
+                		log.Print(err)
+        		}
+			msg.Append(content)
+			have_blob = false
+			//log.Println("Parsed blob...")
+		} else if arg == "-b" {
+			have_blob = true
+		} else if arg == "true" {
+			msg.Append(true)
+			//log.Println("Parsed bool:", true)
+		} else if arg == "false" {
+			msg.Append(false)
+			//log.Println("Parsed bool:", false)
+		} else if i, err := strconv.Atoi(arg); err == nil {
+			msg.Append(int32(i))
+			//log.Println("Parsed int:", i)
+		} else if f, err := strconv.ParseFloat(arg, 64); err == nil {
+			msg.Append(float32(f))
+			//log.Println("Parsed float:", f)
+		} else {
+			msg.Append(arg)
+			//log.Println("Parsed string:", arg)
+		}
+	}
+
+	if err := client.Send(msg); err != nil {
+		log.Fatal(err)
+	}
+}

+ 0 - 8
bar.go

@@ -2,9 +2,6 @@ package main
 
 import (
 	"fmt"
-	"log"
-	"os"
-	"os/exec"
 	"time"
 
 	// bar
@@ -68,11 +65,6 @@ func NewScreenBar(title string) *ScreenBar {
 		}
 	}()
 
-	// Check if we are in the terminal
-	if term.IsTerminal(0) {
-		bar.columns, _, _ = term.GetSize(0)
-	}
-
 	return bar
 }
 

+ 1 - 12
media.go

@@ -33,32 +33,21 @@ func run(name string, args ...string) *exec.Cmd {
 	//}
 
 	//println("got path")
+	//log.Println("got path:", path, args)
 	cmd := exec.Command(name, args...)
 	if err := cmd.Run(); err != nil {
 		log.Print(err)
-		//log.Print(path, args)
 		return nil
 	}
-	//println("got cmd running")
 	return cmd
 }
 
 // Run executable
 func (player *Media) run(name string, args ...string) {
-	// Find executable
-	//path, err := exec.LookPath(name)
-	//if err != nil {
-	//	log.Printf("can't find '%s'\n", name)
-	//	return nil
-	//}
-
-	//println("got path")
 	player.cmd = exec.Command(name, args...)
 	if err := player.cmd.Run(); err != nil {
 		log.Print(err)
-		//log.Print(path, args)
 	}
-	//println("got cmd running")
 }
 
 // Play media file via mpv, osc message sets the file path

+ 1 - 1
ovly.go

@@ -62,7 +62,7 @@ func main() {
 		}
 	}()
 
-	// Wait for signal
+	// Run until signals
 	ch := make(chan os.Signal, 1)
 	signal.Notify(
 		ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT,