initial commit
This commit is contained in:
commit
b1f72fe65f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*_test.go
|
30
get_monitors.go
Normal file
30
get_monitors.go
Normal file
@ -0,0 +1,30 @@
|
||||
package hypr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func GetMonitors() ([]*Monitor, error) {
|
||||
cmd := exec.Command("hyprctl", "-j", "monitors")
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
monitors := make([]*Monitor, 0, 5)
|
||||
if err := json.NewDecoder(stdout).Decode(&monitors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return monitors, nil
|
||||
}
|
31
monitor.go
Normal file
31
monitor.go
Normal file
@ -0,0 +1,31 @@
|
||||
package hypr
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Monitor struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Make string `json:"make"`
|
||||
Model string `json:"model"`
|
||||
Serial string `json:"serial"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
RefreshRate float64 `json:"refreshRate"`
|
||||
X int `json:"x"`
|
||||
Y int `json:"y"`
|
||||
ActiveWorkspace *Workspace `json:"activeWorkspace"`
|
||||
SpecialWorkspace *Workspace `json:"specialWorkspace"`
|
||||
Reserved [4]int `json:"reserved"`
|
||||
Scale float64 `json:"scale"`
|
||||
Transform int `json:"transform"`
|
||||
Focused bool `json:"focused"`
|
||||
DPMSStatus bool `json:"dpmsStatus"`
|
||||
VRR bool `json:"vrr"`
|
||||
ActivelyTearing bool `json:"activelyTearing"`
|
||||
}
|
||||
|
||||
func (m Monitor) String() string {
|
||||
data, _ := json.MarshalIndent(m, "", "\t")
|
||||
return string(data)
|
||||
}
|
19
workspace.go
Normal file
19
workspace.go
Normal file
@ -0,0 +1,19 @@
|
||||
package hypr
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Workspace struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Monitor string `json:"monitor"`
|
||||
MonitorID int `json:"monitorID"`
|
||||
Windows int `json:"windows"`
|
||||
HasFullscreen bool `json:"hasfullscreen"`
|
||||
LastWindow string `json:"lastwindow"`
|
||||
LastWindowTitle string `json:"lastwindowtitle"`
|
||||
}
|
||||
|
||||
func (w Workspace) String() string {
|
||||
data, _ := json.MarshalIndent(w, "", "\t")
|
||||
return string(data)
|
||||
}
|
Loading…
Reference in New Issue
Block a user