=cut
-our $VERSION = '0.03';
+our $VERSION = '0.05';
=head1 VERSION
-Version 0.03
+Version 0.05
=head1 SYNOPSIS
use AnyEvent::I3 qw(:all);
- my $i3 = i3("/tmp/i3-ipc.sock");
+ my $i3 = i3("~/.i3/ipc.sock");
$i3->connect->recv or die "Error connecting";
say "Connected to i3";
sub new {
my ($class, $path) = @_;
- $path ||= '/tmp/i3-ipc.sock';
+ $path ||= '~/.i3/ipc.sock';
+
+ # Check if we need to resolve ~
+ if ($path =~ /~/) {
+ # We use getpwuid() instead of $ENV{HOME} because the latter is tainted
+ # and thus produces warnings when running tests with perl -T
+ my $home = (getpwuid($<))[7];
+ die "Could not get home directory" unless $home and -d $home;
+ $path =~ s/~/$home/g;
+ }
bless { path => $path } => $class;
}