From 209eaf960d8fb1b4bdad1ce90e7b75d67ede33bb Mon Sep 17 00:00:00 2001 From: Unrud Date: Tue, 31 Jul 2018 20:19:08 +0200 Subject: [PATCH] X11 plugin: check session type --- plugin_x11.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin_x11.go b/plugin_x11.go index 8031dad..6273f4f 100644 --- a/plugin_x11.go +++ b/plugin_x11.go @@ -28,6 +28,8 @@ package main import "C" import ( "errors" + "fmt" + "os" "sync" "time" "unsafe" @@ -41,6 +43,11 @@ type x11Plugin struct { } 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) if display == nil { return nil, UnsupportedPlatformError{