diff --git a/AnyEvent-I3/lib/AnyEvent/I3.pm b/AnyEvent-I3/lib/AnyEvent/I3.pm index c7735c51c..2d749d9e5 100644 --- a/AnyEvent-I3/lib/AnyEvent/I3.pm +++ b/AnyEvent-I3/lib/AnyEvent/I3.pm @@ -156,7 +156,9 @@ instance on the current DISPLAY which is almost always what you want. sub new { my ($class, $path) = @_; - $path = _call_i3('--get-socketpath') unless $path; + # We have I3SOCK now + $path ||= $ENV{I3SOCK}; + $path ||= _call_i3('--get-socketpath'); # Check if we need to resolve ~ if ($path =~ /~/) { @@ -165,6 +167,10 @@ sub new { $path =~ s/~/$home/g; } + if(!-S $path) { + die "$path is not a socket", $/; + } + bless { path => $path } => $class; }