9 Commits

13 changed files with 16 additions and 207 deletions

View File

@@ -3,7 +3,14 @@
![GitHub License](https://img.shields.io/github/license/tlinden/swayipc)
[![GoDoc](https://godoc.org/github.com/tlinden/swayipc?status.svg)](https://godoc.org/github.com/tlinden/swayipc)
# swayipc - go bindings to control sway (and possibly i3)
> [!CAUTION]
> This software is now being maintained on [Codeberg](https://codeberg.org/scip/swaycycle/).
>
> You may still use the `github.com/tlinden/swayipc` module, but this
> version here is no longer being maintained. To use the current version,
> import `codeberg.org/scip/swayipc/v1`.
# swayipc - go bindings to control sway and swayfx
Package swayipc can be used to control [sway](https://swaywm.org/),
[swayfx](https://github.com/WillPower3309/swayfx) and possibly
@@ -66,9 +73,13 @@ func main() {
}
```
Also take a look into the **_examples** folder for more examples.
Also take a look into the **_examples** folder for more examples.
You may take a look at the [tool swaycycle](https://github.com/tlinden/swaycycle)
For a more comprehensive and practical example look at the
[descratch](https://github.com/TLINDEN/sway-descratch) program which
you can use to selectively retrieve a window from the scratchpad.
You may also take a look at the [tool swaycycle](https://github.com/tlinden/swaycycle)
which is using this module.
## Installation

View File

@@ -37,7 +37,7 @@ func main() {
// finally execute the given commands on it, you can use any run
// command, see sway(5)
responses, err := ipc.RunContainerCommand(focused.Id, "floating toggle, border toggle")
responses, err := ipc.RunContainerCommand(focused.Id, "floating toggle", "border toggle")
if err != nil {
repr.Println(responses)
log.Fatal(err)

16
bar.go
View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

View File

@@ -1,20 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

38
doc.go
View File

@@ -15,43 +15,5 @@ work with sway and swayfx, but may also work with i3wm, although I
haven't tested it on i3wm.
The module uses the i3-IPC proctocol as outlined in sway-ipc(7).
Example usage:
In this example we retrieve the current focused window:
package main
import (
"fmt"
"log"
"github.com/tlinden/swayipc"
)
func main() {
ipc := swayipc.NewSwayIPC()
err := ipc.Connect()
if err != nil {
log.Fatal(err)
}
defer ipc.Close()
tree, err := ipc.GetTree()
if err != nil {
log.Fatal(err)
}
focused := tree.FindFocused()
if focused != nil {
fmt.Printf("focused node: %s\n id: %d\n Geometry: %dx%d\n",
focused.Name, focused.Id, focused.Geometry.Width,
focused.Geometry.Height)
}
}
Also take a look into the **_examples** folder for more examples.
*/
package swayipc

View File

@@ -1,20 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

17
net.go
View File

@@ -1,20 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

16
node.go
View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

16
seat.go
View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (

View File

@@ -1,20 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (
@@ -22,7 +5,7 @@ import (
)
const (
VERSION = "v0.2.0"
VERSION = "v0.3.0"
IPC_HEADER_SIZE = 14
IPC_MAGIC = "i3-ipc"

View File

@@ -1,19 +1,3 @@
/*
Copyright © 2025 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swayipc
import (