t/166-assign: check for i3-nagbar in the process hierarchy instead of sleep(1)
This commit is contained in:
parent
7e05a0700a
commit
06a9820b5f
@ -192,6 +192,22 @@ sleep 0.25;
|
|||||||
# ticket #501
|
# ticket #501
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
|
# Walks /proc to figure out whether a child process of $i3pid with the name
|
||||||
|
# 'i3-nagbar' exists.
|
||||||
|
sub i3nagbar_running {
|
||||||
|
my ($i3pid) = @_;
|
||||||
|
|
||||||
|
my @procfiles = grep { m,^/proc/[0-9]+$, } </proc/*>;
|
||||||
|
for my $path (@procfiles) {
|
||||||
|
open(my $fh, '<', "$path/stat") or next;
|
||||||
|
my $line = <$fh>;
|
||||||
|
close($fh);
|
||||||
|
my ($comm, $ppid) = ($line =~ /^[0-9]+ \(([^)]+)\) . ([0-9]+)/);
|
||||||
|
return 1 if $ppid == $i3pid && $comm eq 'i3-nagbar';
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$config = <<EOT;
|
$config = <<EOT;
|
||||||
# i3 config file (v4)
|
# i3 config file (v4)
|
||||||
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||||
@ -200,9 +216,11 @@ EOT
|
|||||||
|
|
||||||
$pid = launch_with_config($config);
|
$pid = launch_with_config($config);
|
||||||
|
|
||||||
# TODO: replace this with checking the process hierarchy
|
# Ensure that i3-nagbar is running. It should be started pretty quickly, so we
|
||||||
# XXX: give i3-nagbar some time to start up
|
# busy-loop with a short delay.
|
||||||
sleep 1;
|
while (!i3nagbar_running($pid)) {
|
||||||
|
sleep 0.05;
|
||||||
|
}
|
||||||
|
|
||||||
$tmp = fresh_workspace;
|
$tmp = fresh_workspace;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user