]> git.sur5r.net Git - i3/i3/blobdiff - lib/AnyEvent/I3.pm
bump version
[i3/i3] / lib / AnyEvent / I3.pm
index a2951767683277e847257a86da7cfae30488706a..953de81e76cc1156db5bbf186c6f2df4ef51b535 100644 (file)
@@ -15,11 +15,11 @@ AnyEvent::I3 - communicate with the i3 window manager
 
 =cut
 
-our $VERSION = '0.03';
+our $VERSION = '0.05';
 
 =head1 VERSION
 
-Version 0.03
+Version 0.05
 
 =head1 SYNOPSIS
 
@@ -29,7 +29,7 @@ then subscribe to events or send messages and receive their replies.
 
     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";
@@ -94,7 +94,16 @@ the UNIX socket to connect to.
 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;
 }