parent
cfd6fdadd7
commit
71909226e1
1
Makefile
1
Makefile
|
@ -6,6 +6,7 @@ BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
build:
|
build:
|
||||||
GO111MODULE=off go build \
|
GO111MODULE=off go build \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
./xstartplacement
|
||||||
|
|
||||||
verbose:
|
verbose:
|
||||||
GO111MODULE=off go build -v -x \
|
GO111MODULE=off go build -v -x \
|
||||||
|
|
65
stuff.go
65
stuff.go
|
@ -3,12 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"reflect"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/BurntSushi/xgb"
|
"github.com/BurntSushi/xgb"
|
||||||
"github.com/BurntSushi/xgb/xproto"
|
"github.com/BurntSushi/xgb/xproto"
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -19,6 +17,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
/*
|
||||||
// Start the terminal (replace with your app)
|
// Start the terminal (replace with your app)
|
||||||
go func() {
|
go func() {
|
||||||
if err := exec.Command("mate-terminal", "--title", "Workspace1-Terminal").Start(); err != nil {
|
if err := exec.Command("mate-terminal", "--title", "Workspace1-Terminal").Start(); err != nil {
|
||||||
|
@ -28,6 +27,7 @@ func main() {
|
||||||
|
|
||||||
// Wait for the window to appear
|
// Wait for the window to appear
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
*/
|
||||||
|
|
||||||
// Get the root window
|
// Get the root window
|
||||||
setup := xproto.Setup(conn)
|
setup := xproto.Setup(conn)
|
||||||
|
@ -43,14 +43,67 @@ func main() {
|
||||||
// Find the window with the specified title
|
// Find the window with the specified title
|
||||||
var target xproto.Window
|
var target xproto.Window
|
||||||
for _, child := range reply.Children {
|
for _, child := range reply.Children {
|
||||||
nameReply, err := xproto.GetProperty(conn, false, child,
|
// fmt.Printf("child: %+v\n", child)
|
||||||
xproto.AtomWmName, xproto.AtomString, 0, (1<<32)-1).Reply()
|
/*
|
||||||
|
// Get the atom for _NET_WM_NAME
|
||||||
|
atomReply, err := xproto.InternAtom(conn, true, uint16(len("_NET_WM_NAME")), "_NET_WM_NAME").Reply()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to intern atom _NET_WM_NAME: %v", err)
|
||||||
|
}
|
||||||
|
netWmNameAtom := atomReply.Atom // Correct field to use
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Get the property for _NET_WM_NAME
|
||||||
|
nameReply, err := xproto.GetProperty(conn, false, child, netWmNameAtom, xproto.AtomString, 0, (1<<32)-1).Reply()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to get property _NET_WM_NAME: %v", err)
|
||||||
|
} else if len(nameReply.Value) > 0 {
|
||||||
|
fmt.Printf("Window name: %s\n", string(nameReply.Value))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Get the atom for _NET_WM_NAME
|
||||||
|
atomReply, err := xproto.InternAtom(conn, true, uint16(len("_NET_WM_NAME")), "_NET_WM_NAME").Reply()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to intern atom _NET_WM_NAME: %v", err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("found atomic name: %s\n", string(atomReply.Value))
|
||||||
|
}
|
||||||
|
netWmNameAtom := atomReply.Atom
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Get the property for _NET_WM_NAME
|
||||||
|
nameReply, err := xproto.GetProperty(conn, false, child, netWmNameAtom, xproto.AtomString, 0, (1<<32)-1).Reply()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to get property _NET_WM_NAME: %v", err)
|
||||||
|
} else if len(nameReply.Value) > 0 {
|
||||||
|
fmt.Printf("Window name: %s\n", string(nameReply.Value))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
var test xproto.Drawable
|
||||||
|
geomReply, err := xproto.GetGeometry(conn, test).Reply()
|
||||||
|
if err != nil {
|
||||||
|
// fmt.Printf("err: %+v\n", err)
|
||||||
|
// fmt.Printf("child geomReply: %+v\n", geomReply)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("child geomReply: %+v\n", geomReply)
|
||||||
|
}
|
||||||
|
|
||||||
|
nameReply, err := xproto.GetProperty(conn, false, child, xproto.AtomWmName, xproto.AtomString, 0, (1<<32)-1).Reply()
|
||||||
|
if err != nil {
|
||||||
|
// fmt.Printf("child err: %+v\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("child %+v nameReply: %+v %s\n", reflect.TypeOf(child), nameReply, string(nameReply.Value))
|
||||||
|
}
|
||||||
if err != nil || len(nameReply.Value) == 0 {
|
if err != nil || len(nameReply.Value) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := string(nameReply.Value)
|
name := string(nameReply.Value)
|
||||||
log.Info("found name:", name)
|
|
||||||
if name == "Workspace1-Terminal" {
|
if name == "Workspace1-Terminal" {
|
||||||
target = child
|
target = child
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue