App-FirefoxUtils
view release on metacpan or search on metacpan
lib/App/FirefoxUtils.pm view on Meta::CPAN
$SPEC{unpause_firefox} = {
v => 1.1,
summary => "Unpause (resume, continue, kill -CONT) Firefox",
args => {
%App::BrowserUtils::args_common,
},
};
sub unpause_firefox {
App::BrowserUtils::_do_browser('unpause', 'firefox', @_);
}
$SPEC{pause_and_unpause_firefox} = {
v => 1.1,
summary => "Pause and unpause Firefox alternately",
description => $App::BrowserUtils::desc_pause_and_unpause,
args => {
%App::BrowserUtils::args_common,
%App::BrowserUtils::argopt_periods,
},
};
sub pause_and_unpause_firefox {
App::BrowserUtils::_do_browser('pause_and_unpause', 'firefox', @_);
}
$SPEC{firefox_has_processes} = {
v => 1.1,
summary => "Check whether Firefox has processes",
args => {
%App::BrowserUtils::args_common,
%App::BrowserUtils::argopt_quiet,
},
};
sub firefox_has_processes {
App::BrowserUtils::_do_browser('has_processes', 'firefox', @_);
}
$SPEC{firefox_is_paused} = {
v => 1.1,
summary => "Check whether Firefox is paused",
description => <<'_',
Firefox is defined as paused if *all* of its processes are in 'stop' state.
_
args => {
%App::BrowserUtils::args_common,
%App::BrowserUtils::argopt_quiet,
},
};
sub firefox_is_paused {
App::BrowserUtils::_do_browser('is_paused', 'firefox', @_);
}
$SPEC{firefox_is_running} = {
v => 1.1,
summary => "Check whether Firefox is running",
description => <<'_',
Firefox is defined as running if there are some Firefox processes that are *not*
in 'stop' state. In other words, if Firefox has been started but is currently
paused, we do not say that it's running. If you want to check if Firefox process
exists, you can use `ps_firefox`.
_
args => {
%App::BrowserUtils::args_common,
%App::BrowserUtils::argopt_quiet,
},
};
sub firefox_is_running {
App::BrowserUtils::_do_browser('is_running', 'firefox', @_);
}
$SPEC{terminate_firefox} = {
v => 1.1,
summary => "Terminate Firefox (by default with -KILL signal)",
args => {
%App::BrowserUtils::args_common,
%App::BrowserUtils::argopt_signal,
},
};
sub terminate_firefox {
App::BrowserUtils::_do_browser('terminate', 'firefox', @_);
}
$SPEC{restart_firefox} = {
v => 1.1,
summary => "Restart firefox",
args => {
%App::BrowserUtils::argopt_firefox_cmd,
%App::BrowserUtils::argopt_quiet,
},
features => {
dry_run => 1,
},
};
sub restart_firefox {
App::BrowserUtils::restart_browsers(@_, restart_firefox=>1);
}
$SPEC{start_firefox} = {
v => 1.1,
summary => "Start firefox if not already started",
args => {
%App::BrowserUtils::argopt_firefox_cmd,
%App::BrowserUtils::argopt_quiet,
},
features => {
dry_run => 1,
},
};
sub start_firefox {
App::BrowserUtils::start_browsers(@_, start_firefox=>1);
}
$SPEC{open_firefox_tabs} = {
v => 1.1,
summary => 'Open a list of Firefox tabs, with options',
description => <<'MARKDOWN',
This utility is best used via Perl or curried after you supply the list of
lib/App/FirefoxUtils.pm view on Meta::CPAN
used to determine which processes are the browser processes.
=item * B<exec_pat> => I<re_from_str>
Filter processes using regex against their exec.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<fname_pat> => I<re_from_str>
Filter processes using regex against their fname.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<pid_pat> => I<re_from_str>
Filter processes using regex against their pid.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<quiet> => I<true>
(No description)
=item * B<users> => I<array[unix::uid::exists]>
Kill browser processes that belong to certain user(s) only.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.
Return value: (any)
=head2 firefox_is_running
Usage:
firefox_is_running(%args) -> [$status_code, $reason, $payload, \%result_meta]
Check whether Firefox is running.
Firefox is defined as running if there are some Firefox processes that are I<not>
in 'stop' state. In other words, if Firefox has been started but is currently
paused, we do not say that it's running. If you want to check if Firefox process
exists, you can use C<ps_firefox>.
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
=over 4
=item * B<cmndline_pat> => I<re_from_str>
Filter processes using regex against their cmndline.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<exec_pat> => I<re_from_str>
Filter processes using regex against their exec.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<fname_pat> => I<re_from_str>
Filter processes using regex against their fname.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<pid_pat> => I<re_from_str>
Filter processes using regex against their pid.
If one of the C<*-pat> options are specified, then instead of the default
heuristic rules to find the browser processes, these C<*-pat> options are solely
used to determine which processes are the browser processes.
=item * B<quiet> => I<true>
(No description)
=item * B<users> => I<array[unix::uid::exists]>
Kill browser processes that belong to certain user(s) only.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.
( run in 0.863 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )