Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
9a77a7bbc3 | |||
16d2e8e8fd | |||
713a6bd6be | |||
580b7d5a3a |
2
do.go
2
do.go
@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) Action(action Action) error {
|
func (c *Client) DoAction(action Action) error {
|
||||||
// print request and response to console:
|
// print request and response to console:
|
||||||
//
|
//
|
||||||
// io.Copy(os.Stdout, asJsonReader(action))
|
// io.Copy(os.Stdout, asJsonReader(action))
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module git.tordarus.net/niri-tools/niri
|
module git.tordarus.net/niri-tools/niri
|
||||||
|
|
||||||
go 1.24.4
|
go 1.25
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.tordarus.net/tordarus/channel v0.1.20
|
git.tordarus.net/tordarus/channel v0.1.20
|
||||||
|
@ -5,14 +5,15 @@ import "encoding/json"
|
|||||||
type WindowID int
|
type WindowID int
|
||||||
|
|
||||||
type Window struct {
|
type Window struct {
|
||||||
ID WindowID `json:"id"`
|
ID WindowID `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
AppID string `json:"app_id"`
|
AppID string `json:"app_id"`
|
||||||
PID int `json:"pid"`
|
PID int `json:"pid"`
|
||||||
WorkspaceID WorkspaceID `json:"workspace_id"`
|
WorkspaceID WorkspaceID `json:"workspace_id"`
|
||||||
Urgent bool `json:"is_urgent"`
|
Urgent bool `json:"is_urgent"`
|
||||||
Floating bool `json:"is_floating"`
|
Floating bool `json:"is_floating"`
|
||||||
Focused bool `json:"is_focused"`
|
Focused bool `json:"is_focused"`
|
||||||
|
Layout WindowLayout `json:"layout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Window) String() string {
|
func (m Window) String() string {
|
||||||
|
16
model_window_layout.go
Normal file
16
model_window_layout.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package niri
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
|
type WindowLayout struct {
|
||||||
|
PosInScrollingLayout Option[[2]int] `json:"pos_in_scrolling_layout"`
|
||||||
|
TileSize [2]float64 `json:"tile_size"`
|
||||||
|
WindowSize [2]int `json:"window_size"`
|
||||||
|
TilePosInWorkspaceView Option[[2]float64] `json:"tile_pos_in_workspace_view"`
|
||||||
|
WindowOffsetInTile [2]float64 `json:"window_offset_in_tile"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m WindowLayout) String() string {
|
||||||
|
data, _ := json.MarshalIndent(m, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
@ -7,7 +7,7 @@ type WorkspaceID int
|
|||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
ID WorkspaceID `json:"id"`
|
ID WorkspaceID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Output string `json:"output"`
|
Output OutputName `json:"output"`
|
||||||
Urgent bool `json:"is_urgent"`
|
Urgent bool `json:"is_urgent"`
|
||||||
Active bool `json:"is_active"`
|
Active bool `json:"is_active"`
|
||||||
Focused bool `json:"is_focused"`
|
Focused bool `json:"is_focused"`
|
||||||
|
4
utils.go
4
utils.go
@ -77,9 +77,11 @@ func readSocketGeneric[T any](ctx context.Context, socket string, body io.Reader
|
|||||||
defer close(out)
|
defer close(out)
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
|
dec := json.NewDecoder(r)
|
||||||
|
|
||||||
for ctx.Err() == nil {
|
for ctx.Err() == nil {
|
||||||
value := new(T)
|
value := new(T)
|
||||||
if err := json.NewDecoder(r).Decode(value); err != nil {
|
if err := dec.Decode(value); err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user