renovate the code, update to go 1.26 and satisfy linter (#3)

This commit is contained in:
T. von Dein
2026-08-22 17:59:59 +02:00
parent 9cd6e4a6b9
commit 6d9763a0a9
77 changed files with 681 additions and 227 deletions

88
_examples/Makefile Normal file
View File

@@ -0,0 +1,88 @@
examples: example-current_workspace example-events example-find_focused_window example-get_bars example-get_config example-get_inputs example-get_marks example-get_outputs example-get_seats example-get_tree example-get_version example-get_workspaces example-run_command example-run_global_command
clean: clean-example-current_workspace clean-example-events clean-example-find_focused_window clean-example-get_bars clean-example-get_config clean-example-get_inputs clean-example-get_marks clean-example-get_outputs clean-example-get_seats clean-example-get_tree clean-example-get_version clean-example-get_workspaces clean-example-run_command clean-example-run_global_command
example-current_workspace:
make -C current_workspace
example-events:
make -C events
example-find_focused_window:
make -C find_focused_window
example-get_bars:
make -C get_bars
example-get_config:
make -C get_config
example-get_inputs:
make -C get_inputs
example-get_marks:
make -C get_marks
example-get_outputs:
make -C get_outputs
example-get_seats:
make -C get_seats
example-get_tree:
make -C get_tree
example-get_version:
make -C get_version
example-get_workspaces:
make -C get_workspaces
example-run_command:
make -C run_command
example-run_global_command:
make -C run_global_command
clean-example-current_workspace:
make -C current_workspace clean
clean-example-events:
make -C events clean
clean-example-find_focused_window:
make -C find_focused_window clean
clean-example-get_bars:
make -C get_bars clean
clean-example-get_config:
make -C get_config clean
clean-example-get_inputs:
make -C get_inputs clean
clean-example-get_marks:
make -C get_marks clean
clean-example-get_outputs:
make -C get_outputs clean
clean-example-get_seats:
make -C get_seats clean
clean-example-get_tree:
make -C get_tree clean
clean-example-get_version:
make -C get_version clean
clean-example-get_workspaces:
make -C get_workspaces clean
clean-example-run_command:
make -C run_command clean
clean-example-run_global_command:
make -C run_global_command clean

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f current_workspace

View File

@@ -0,0 +1,9 @@
module current_workspace
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"log"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f events

9
_examples/events/go.mod Normal file
View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

2
_examples/events/go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -9,8 +9,8 @@ import (
"fmt"
"log"
"codeberg.org/scip/swayipc/v2"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
)
// Event callback function, needs to implement each subscribed events,
@@ -18,11 +18,11 @@ import (
func ProcessTick(event *swayipc.RawResponse) error {
var err error
switch event.PayloadType {
case swayipc.EV_Tick:
case swayipc.EvTick:
ev := &swayipc.EventTick{}
err = json.Unmarshal(event.Payload, &ev)
repr.Println(ev)
case swayipc.EV_Window:
case swayipc.EvWindow:
ev := &swayipc.EventWindow{}
err = json.Unmarshal(event.Payload, &ev)
repr.Println(ev)

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f find_focused_window

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"log"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {
@@ -25,6 +25,6 @@ func main() {
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)
focused.Name, focused.ID, focused.Geometry.Width, focused.Geometry.Height)
}
}

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_bars

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -9,7 +9,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_config

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"fmt"
"log"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_inputs

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_marks

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_outputs

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_seats

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_tree

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -4,7 +4,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_version

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f get_workspaces

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -8,7 +8,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f run_command

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -9,8 +9,8 @@ package main
import (
"log"
"codeberg.org/scip/swayipc/v2"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
)
func main() {
@@ -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)

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f run_global_command

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -9,7 +9,7 @@ import (
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {

View File

@@ -0,0 +1,5 @@
all:
go build .
clean:
rm -f send_tick

View File

@@ -0,0 +1,9 @@
module send_tick
go 1.26
require github.com/alecthomas/repr v0.5.4 // indirect
replace codeberg.org/scip/swayipc/v2 => ../..
require codeberg.org/scip/swayipc/v2 v2.1.0

View File

@@ -0,0 +1,2 @@
github.com/alecthomas/repr v0.5.4 h1:OVP7JEcuzU9CCDsT6STCr3rg17oQfWILtPWd2EG0uN4=
github.com/alecthomas/repr v0.5.4/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

View File

@@ -12,7 +12,7 @@ import (
"log"
"os"
"codeberg.org/scip/swayipc/v1"
"codeberg.org/scip/swayipc/v2"
)
func main() {