Skip to content

Commit

Permalink
Merge pull request #32 from nwg-piotr/hyprdir
Browse files Browse the repository at this point in the history
Get ready for Hyprland 0.40
  • Loading branch information
nwg-piotr committed May 4, 2024
2 parents b86ece1 + f539fee commit 08f399f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.20
require (
github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f
github.com/gotk3/gotk3 v0.6.2
github.com/gotk3/gotk3 v0.6.3
github.com/sirupsen/logrus v1.9.3
)

require golang.org/x/sys v0.11.0 // indirect
require golang.org/x/sys v0.19.0 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/dlasky/gotk3-layershell v0.0.0-20230802002603-b0c42cd8474f/go.mod h1:
github.com/gotk3/gotk3 v0.6.1/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gotk3/gotk3 v0.6.2 h1:sx/PjaKfKULJPTPq8p2kn2ZbcNFxpOJqi4VLzMbEOO8=
github.com/gotk3/gotk3 v0.6.2/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gotk3/gotk3 v0.6.3 h1:+Ke4WkM1TQUNOlM2TZH6szqknqo+zNbX3BZWVXjSHYw=
github.com/gotk3/gotk3 v0.6.3/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand All @@ -21,6 +23,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JC
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion hypr.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type client struct {
}

func hyprctl(cmd string) ([]byte, error) {
socketFile := fmt.Sprintf("/tmp/hypr/%s/.socket.sock", his)
socketFile := fmt.Sprintf("%s/%s/.socket.sock", hyprDir, his)
conn, err := net.Dial("unix", socketFile)
if err != nil {
return nil, err
Expand Down
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/gotk3/gotk3/gtk"
)

const version = "0.1.7"
const version = "0.1.8"

type WindowState int

Expand All @@ -47,6 +47,7 @@ var (
windowStateChannel chan WindowState = make(chan WindowState, 1)
detectorEnteredAt int64
his string // $HYPRLAND_INSTANCE_SIGNATURE
hyprDir string // $XDG_RUNTIME_DIR/hypr since hyprland>0.39.1, earlier /tmp/hypr
monitors []monitor
clients []client
activeClient *client
Expand Down Expand Up @@ -330,6 +331,13 @@ func main() {
}
log.Debugf("HYPRLAND_INSTANCE_SIGNATURE: '%s'", his)

if os.Getenv("XDG_RUNTIME_DIR") != "" && pathExists(filepath.Join(os.Getenv("XDG_RUNTIME_DIR"), "hypr")) {
hyprDir = filepath.Join(os.Getenv("XDG_RUNTIME_DIR"), "hypr")
} else {
hyprDir = "/tmp/hypr"
}
log.Debugf("hyprDir: '%s'", hyprDir)

if *autohide {
log.Info("Starting in autohiDe mode")
}
Expand Down Expand Up @@ -611,7 +619,7 @@ func main() {
}()

addr := &net.UnixAddr{
Name: fmt.Sprintf("/tmp/hypr/%s/.socket2.sock", his),
Name: fmt.Sprintf("%s/%s/.socket2.sock", hyprDir, his),
Net: "unix",
}

Expand Down
9 changes: 9 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,15 @@ func searchDesktopDirs(badAppID string) string {
b4Separator = strings.Split(badAppID, " ")[0]
for _, d := range appDirs {
items, _ := os.ReadDir(d)
log.Info(">>>", items)

// first look for exact 'class.desktop' file, see #31
for _, item := range items {
if strings.ToUpper(item.Name()) == strings.ToUpper(fmt.Sprintf("%s.desktop", badAppID)) {
return filepath.Join(d, item.Name())
}
}

for _, item := range items {
if strings.Contains(strings.ToUpper(item.Name()), strings.ToUpper(b4Separator)) {
return filepath.Join(d, item.Name())
Expand Down

0 comments on commit 08f399f

Please sign in to comment.