Skip to content

Commit

Permalink
Use I3SOCK environment variable for path in AnyEvent::I3 (#5987)
Browse files Browse the repository at this point in the history
Commit 3ae5f31 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>
  • Loading branch information
waterkip committed Apr 19, 2024
1 parent 91ce3bd commit 5834b7e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion AnyEvent-I3/lib/AnyEvent/I3.pm
Expand Up @@ -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 =~ /~/) {
Expand All @@ -165,6 +167,10 @@ sub new {
$path =~ s/~/$home/g;
}

if(!-S $path) {
die "$path is not a socket", $/;
}

bless { path => $path } => $class;
}

Expand Down

0 comments on commit 5834b7e

Please sign in to comment.