This commit is contained in:
Daniel 2023-01-15 10:43:50 -05:00
commit f5be64a16b
5 changed files with 62 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/swarp

2
Makefile Normal file
View file

@ -0,0 +1,2 @@
all:
go build -o swarp swarp.go

10
go.mod Normal file
View file

@ -0,0 +1,10 @@
module github.com/amigan/swarp
go 1.17
require go.i3wm.org/i3/v4 v4.18.0
require (
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 // indirect
github.com/BurntSushi/xgbutil v0.0.0-20160919175755-f7c97cef3b4e // indirect
)

12
go.sum Normal file
View file

@ -0,0 +1,12 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/BurntSushi/xgbutil v0.0.0-20160919175755-f7c97cef3b4e h1:4ZrkT/RzpnROylmoQL57iVUL57wGKTR5O6KpVnbm2tA=
github.com/BurntSushi/xgbutil v0.0.0-20160919175755-f7c97cef3b4e/go.mod h1:uw9h2sd4WWHOPdJ13MQpwK5qYWKYDumDqxWWIknEQ+k=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
go.i3wm.org/i3/v4 v4.18.0 h1:yV9SCpYeyTqEuele2bw7rLmEfrGCRlid9enTqLjPuG0=
go.i3wm.org/i3/v4 v4.18.0/go.mod h1:FN6trxp2TXmfzQVa6JSKq5IJx/XUJsnPFKAz15cBWtw=
golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc h1:ZMCWScCvS2fUVFw8LOpxyUUW5qiviqr4Dg5NdjLeiLU=
golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

37
swarp.go Normal file
View file

@ -0,0 +1,37 @@
package main
import (
"log"
"go.i3wm.org/i3/v4"
)
func runOrLog(cmd string) []i3.CommandResult {
res, err := i3.RunCommand(cmd)
if err != nil {
log.Fatal(err)
}
return res
}
func main() {
outputs, err := i3.GetOutputs()
if err != nil {
log.Fatal(err)
}
activeWorkspaces := make([]string, 0, 2)
for _, o := range outputs {
if o.Active {
activeWorkspaces = append(activeWorkspaces, o.CurrentWorkspace)
}
}
runOrLog("workspace " + activeWorkspaces[0])
runOrLog("move workspace to output right")
runOrLog("workspace " + activeWorkspaces[1])
runOrLog("move workspace to output right")
}