# Use Mouse+Mod1 to drag floating windows to their wanted position
floating_modifier Mod1
-# temporary path during development
-ipc-socket /tmp/nestedcons
-
# Open empty container
bindsym Mod1+Shift+Return open
use X11::XCB qw(:all);
use List::Util qw(first);
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
#####################################################################
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
fresh_workspace;
cmd 'split h';
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
#####################################################################
# verify that there is no dock window yet
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
cmd 'split h';
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
use i3test;
use List::MoreUtils qw(all);
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
####################
# Request workspaces
use List::MoreUtils qw(all none);
use List::Util qw(first);
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
####################
# Request tree
#
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
use List::Util qw(first);
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
#
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
#
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
#
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
# We move the pointer out of our way to avoid a bug where the focus will
# be set to the window under the cursor
#
use i3test;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $x = X11::XCB::Connection->new;
use_ok('X11::XCB::Window');
}
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
use_ok('X11::XCB::Window');
}
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
use_ok('X11::XCB::Window');
}
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
use_ok('X11::XCB::Window');
}
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $x = X11::XCB::Connection->new;
sub check_order {
use_ok('X11::XCB::Window');
}
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $x = X11::XCB::Connection->new;
sub check_order {
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
subtest 'Window without WM_TAKE_FOCUS', sub {
use i3test;
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
my $window = open_standard_window($x);
}
my $x = X11::XCB::Connection->new;
-my $i3 = i3("/tmp/nestedcons");
+my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
# start a window and see that it does not get assigned with an empty config
#####################################################################
+my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
+
my ($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
close($fh);
diag("Starting i3");
my $process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
my $tmp = fresh_workspace;
($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
say $fh q|assign "special" → targetws|;
close($fh);
$process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
$tmp = fresh_workspace;
$process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
# initialize the target workspace, then go to a fresh one
($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
say $fh q|assign "special" → ~|;
close($fh);
$process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
$tmp = fresh_workspace;
# other and no split containers are created
#####################################################################
+my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
+
my ($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
close($fh);
diag("Starting i3");
my $process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
my $tmp = fresh_workspace;
($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
say $fh "workspace_layout stacked";
close($fh);
$process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
$tmp = fresh_workspace;
# assuming we are run by complete-run.pl
my $i3_path = abs_path("../i3");
+my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
#####################################################################
# 1: test the wrapping behaviour without force_focus_wrapping
my ($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
close($fh);
diag("Starting i3");
my $process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
my $tmp = fresh_workspace;
($fh, $tmpfile) = tempfile();
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
-say $fh "ipc-socket /tmp/nestedcons";
+say $fh "ipc-socket $socketpath";
say $fh "force_focus_wrapping true";
close($fh);
$process = Proc::Background->new($i3cmd);
sleep 1;
+# force update of the cached socket path in lib/i3test
+get_socket_path(0);
+
diag("pid = " . $process->pid);
$tmp = fresh_workspace;
use v5.10;
use Exporter ();
-our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully workspace_exists focused_ws);
+our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully workspace_exists focused_ws get_socket_path);
my $tester = Test::Builder->new();
+my $_cached_socket_path = undef;
BEGIN {
my $window_count = 0;
}
sub get_workspace_names {
- my $i3 = i3("/tmp/nestedcons");
+ my $i3 = i3(get_socket_path());
my $tree = $i3->get_tree->recv;
my @outputs = @{$tree->{nodes}};
my @cons;
sub get_ws {
my ($name) = @_;
- my $i3 = i3("/tmp/nestedcons");
+ my $i3 = i3(get_socket_path());
my $tree = $i3->get_tree->recv;
my @outputs = @{$tree->{nodes}};
sub get_dock_clients {
my $which = shift;
- my $tree = i3("/tmp/nestedcons")->get_tree->recv;
+ my $tree = i3(get_socket_path())->get_tree->recv;
my @outputs = @{$tree->{nodes}};
# Children of all dockareas
my @docked;
}
sub cmd {
- i3("/tmp/nestedcons")->command(@_)->recv
+ i3(get_socket_path())->command(@_)->recv
}
sub workspace_exists {
}
sub focused_ws {
- my $i3 = i3("/tmp/nestedcons");
+ my $i3 = i3(get_socket_path());
my $tree = $i3->get_tree->recv;
my @outputs = @{$tree->{nodes}};
my @cons;
}
sub does_i3_live {
- my $tree = i3('/tmp/nestedcons')->get_tree->recv;
+ my $tree = i3(get_socket_path())->get_tree->recv;
my @nodes = @{$tree->{nodes}};
my $ok = (@nodes > 0);
$tester->ok($ok, 'i3 still lives');
# Tries to exit i3 gracefully (with the 'exit' cmd) or kills the PID if that fails
sub exit_gracefully {
my ($pid, $socketpath) = @_;
- $socketpath ||= '/tmp/nestedcons';
+ $socketpath ||= get_socket_path();
my $exited = 0;
try {
}
}
+# Gets the socket path from the I3_SOCKET_PATH atom stored on the X11 root window
+sub get_socket_path {
+ my ($cache) = @_;
+ $cache ||= 1;
+
+ if ($cache && defined($_cached_socket_path)) {
+ return $_cached_socket_path;
+ }
+
+ my $x = X11::XCB::Connection->new;
+ my $atom = $x->atom(name => 'I3_SOCKET_PATH');
+ my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
+ my $reply = $x->get_property_reply($cookie->{sequence});
+ my $socketpath = $reply->{value};
+ $_cached_socket_path = $socketpath;
+ return $socketpath;
+}
+
1