mirror of
https://codeberg.org/scip/swayipc.git
synced 2025-12-16 20:20:56 +01:00
implemented everything else and added more examples and docs
This commit is contained in:
39
_examples/send_tick/main.go
Normal file
39
_examples/send_tick/main.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
send a tick with an arbitrary payload, supply some argument to the
|
||||
command, which will then be attached to the tick. Use the events
|
||||
example to retrieve the tick (command out the Window event type to
|
||||
better see it)
|
||||
*/
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/tlinden/i3ipc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
payload := "send_tick.go"
|
||||
|
||||
if len(os.Args) > 1 {
|
||||
payload = os.Args[1]
|
||||
}
|
||||
|
||||
ipc := i3ipc.NewI3ipc()
|
||||
|
||||
err := ipc.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer ipc.Close()
|
||||
|
||||
err = ipc.SendTick(payload)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Sent tick with payload '%s'.\n", payload)
|
||||
}
|
||||
Reference in New Issue
Block a user