mirror of
https://codeberg.org/scip/swayipc.git
synced 2025-12-17 12:31:05 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7079004e63 | |||
| d64c1ddcc0 | |||
| e516aeab72 | |||
| 3102978317 | |||
| af9eaaf8ae | |||
| ce6d836234 | |||
| 9f08aefcff | |||
| ef2912d034 | |||
| 837443deb4 |
15
README.md
15
README.md
@@ -3,7 +3,14 @@
|
|||||||

|

|
||||||
[](https://godoc.org/github.com/tlinden/swayipc)
|
[](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/),
|
Package swayipc can be used to control [sway](https://swaywm.org/),
|
||||||
[swayfx](https://github.com/WillPower3309/swayfx) and possibly
|
[swayfx](https://github.com/WillPower3309/swayfx) and possibly
|
||||||
@@ -68,7 +75,11 @@ 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.
|
which is using this module.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func main() {
|
|||||||
|
|
||||||
// finally execute the given commands on it, you can use any run
|
// finally execute the given commands on it, you can use any run
|
||||||
// command, see sway(5)
|
// 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 {
|
if err != nil {
|
||||||
repr.Println(responses)
|
repr.Println(responses)
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
16
bar.go
16
bar.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
17
command.go
17
command.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
38
doc.go
38
doc.go
@@ -15,43 +15,5 @@ work with sway and swayfx, but may also work with i3wm, although I
|
|||||||
haven't tested it on i3wm.
|
haven't tested it on i3wm.
|
||||||
|
|
||||||
The module uses the i3-IPC proctocol as outlined in sway-ipc(7).
|
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
|
package swayipc
|
||||||
|
|||||||
17
event.go
17
event.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
16
input.go
16
input.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
17
net.go
17
net.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
16
node.go
16
node.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
16
output.go
16
output.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
16
seat.go
16
seat.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
19
swayipc.go
19
swayipc.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -22,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "v0.2.0"
|
VERSION = "v0.3.0"
|
||||||
|
|
||||||
IPC_HEADER_SIZE = 14
|
IPC_HEADER_SIZE = 14
|
||||||
IPC_MAGIC = "i3-ipc"
|
IPC_MAGIC = "i3-ipc"
|
||||||
|
|||||||
16
version.go
16
version.go
@@ -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
|
package swayipc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user