aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWesley Schwengle <wesleys@opperschaap.net>2024-04-19 13:12:11 -0400
committerGitHub <noreply@github.com>2024-04-19 19:12:11 +0200
commit5834b7e8242c5279712452b632d6ec2e9741760b (patch)
tree86556f5340f2c446d3743462c6a675dafc28b7d5
parent91ce3bdbd544497c4b6bb805e7a852b00b60d4a5 (diff)
downloadi3-5834b7e8242c5279712452b632d6ec2e9741760b.tar.gz
i3-5834b7e8242c5279712452b632d6ec2e9741760b.zip
Use I3SOCK environment variable for path in AnyEvent::I3 (#5987)
Commit 3ae5f31d0 introduced the I3SOCK environment variable. This prevents us from having to call `i3 --get-socketpath'. In case the variable doesn't exist, fall back to the old ways. Signed-off-by: Wesley Schwengle <wesleys@opperschaap.net>
-rw-r--r--AnyEvent-I3/lib/AnyEvent/I3.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/AnyEvent-I3/lib/AnyEvent/I3.pm b/AnyEvent-I3/lib/AnyEvent/I3.pm
index c7735c51..2d749d9e 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;
}