X11 plugin: check session type

This commit is contained in:
Unrud 2018-07-31 20:19:08 +02:00
parent e877947824
commit 209eaf960d

View file

@ -28,6 +28,8 @@ package main
import "C" import "C"
import ( import (
"errors" "errors"
"fmt"
"os"
"sync" "sync"
"time" "time"
"unsafe" "unsafe"
@ -41,6 +43,11 @@ type x11Plugin struct {
} }
func InitX11Plugin() (Plugin, error) { func InitX11Plugin() (Plugin, error) {
sessionType := os.Getenv("XDG_SESSION_TYPE")
if sessionType != "" && sessionType != "x11" {
return nil, UnsupportedPlatformError{errors.New(fmt.Sprintf(
"unsupported session type '%v'", sessionType))}
}
display := C.XOpenDisplay(nil) display := C.XOpenDisplay(nil)
if display == nil { if display == nil {
return nil, UnsupportedPlatformError{ return nil, UnsupportedPlatformError{