scratchpad count for sway
Signed-off-by: Michael <michael.lindman@gmail.com>
This commit is contained in:
parent
b45c77be1c
commit
4ea3244e48
44
scratchpad.go
Normal file
44
scratchpad.go
Normal file
@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var tree Tree
|
||||
cmd, err := exec.Command("swaymsg", "-t", "get_tree").Output()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
if err := json.Unmarshal(cmd, &tree); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
for _, n := range tree.Nodes {
|
||||
if n.Name == "__i3" {
|
||||
for _, nodes := range n.Nodes {
|
||||
if nodes.Name == "__i3_scratch" {
|
||||
fmt.Println(len(nodes.FloatingNodes))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tree Sway tree
|
||||
type Tree struct {
|
||||
Nodes []struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Nodes []struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
FloatingNodes []struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"floating_nodes"`
|
||||
} `json:"nodes"`
|
||||
} `json:"nodes"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user