| 1 | package App::ChromeUtils; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.010001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict 'subs', 'vars'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Log::ger; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | ▶ | use App::BrowserUtils (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 11 | 1 | our $DATE = '2023-10-28'; # DATE | |
| 12 | 1 | our $DIST = 'App-ChromeUtils'; # DIST | |
| 13 | 1 | our $VERSION = '0.012'; # VERSION | |
| 14 | |||
| 15 | 1 | our %SPEC; | |
| 16 | |||
| 17 | 1 | $SPEC{':package'} = { | |
| 18 | v => 1.1, | ||
| 19 | summary => 'Utilities related to Google Chrome browser', | ||
| 20 | }; | ||
| 21 | |||
| 22 | $SPEC{ps_chrome} = { | ||
| 23 | 1 | v => 1.1, | |
| 24 | summary => "List Chrome processes", | ||
| 25 | args => { | ||
| 26 | %App::BrowserUtils::args_common, | ||
| 27 | }, | ||
| 28 | }; | ||
| 29 | 0 | ▶ | sub ps_chrome { |
|
Subroutine
ps_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 30 | 0 | App::BrowserUtils::_do_browser('ps', 'chrome', @_); | |
| 31 | } | ||
| 32 | |||
| 33 | $SPEC{pause_chrome} = { | ||
| 34 | 1 | v => 1.1, | |
| 35 | summary => "Pause (kill -STOP) Chrome", | ||
| 36 | description => $App::BrowserUtils::desc_pause, | ||
| 37 | args => { | ||
| 38 | %App::BrowserUtils::args_common, | ||
| 39 | }, | ||
| 40 | }; | ||
| 41 | 0 | ▶ | sub pause_chrome { |
|
Subroutine
pause_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | 0 | App::BrowserUtils::_do_browser('pause', 'chrome', @_); | |
| 43 | } | ||
| 44 | |||
| 45 | $SPEC{unpause_chrome} = { | ||
| 46 | 1 | v => 1.1, | |
| 47 | summary => "Unpause (resume, continue, kill -CONT) Chrome", | ||
| 48 | args => { | ||
| 49 | %App::BrowserUtils::args_common, | ||
| 50 | }, | ||
| 51 | }; | ||
| 52 | 0 | ▶ | sub unpause_chrome { |
|
Subroutine
unpause_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 53 | 0 | App::BrowserUtils::_do_browser('unpause', 'chrome', @_); | |
| 54 | } | ||
| 55 | |||
| 56 | $SPEC{pause_and_unpause_chrome} = { | ||
| 57 | 1 | v => 1.1, | |
| 58 | summary => "Pause and unpause Chrome alternately", | ||
| 59 | description => $App::BrowserUtils::desc_pause_and_unpause, | ||
| 60 | args => { | ||
| 61 | %App::BrowserUtils::args_common, | ||
| 62 | %App::BrowserUtils::argopt_periods, | ||
| 63 | }, | ||
| 64 | }; | ||
| 65 | 0 | ▶ | sub pause_and_unpause_chrome { |
|
Subroutine
pause_and_unpause_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 66 | 0 | App::BrowserUtils::_do_browser('pause_and_unpause', 'chrome', @_); | |
| 67 | } | ||
| 68 | |||
| 69 | $SPEC{chrome_has_processes} = { | ||
| 70 | 1 | v => 1.1, | |
| 71 | summary => "Check whether Chrome has processes", | ||
| 72 | args => { | ||
| 73 | %App::BrowserUtils::args_common, | ||
| 74 | %App::BrowserUtils::argopt_quiet, | ||
| 75 | }, | ||
| 76 | }; | ||
| 77 | 0 | ▶ | sub chrome_has_processes { |
|
Subroutine
chrome_has_processes: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 78 | 0 | App::BrowserUtils::_do_browser('has_processes', 'chrome', @_); | |
| 79 | } | ||
| 80 | |||
| 81 | $SPEC{chrome_is_paused} = { | ||
| 82 | 1 | v => 1.1, | |
| 83 | summary => "Check whether Chrome is paused", | ||
| 84 | description => <<'_', | ||
| 85 | |||
| 86 | Chrome is defined as paused if *all* of its processes are in 'stop' state. | ||
| 87 | |||
| 88 | _ | ||
| 89 | args => { | ||
| 90 | %App::BrowserUtils::args_common, | ||
| 91 | %App::BrowserUtils::argopt_quiet, | ||
| 92 | }, | ||
| 93 | }; | ||
| 94 | 0 | ▶ | sub chrome_is_paused { |
|
Subroutine
chrome_is_paused: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | App::BrowserUtils::_do_browser('is_paused', 'chrome', @_); | |
| 96 | } | ||
| 97 | |||
| 98 | $SPEC{chrome_is_running} = { | ||
| 99 | 1 | v => 1.1, | |
| 100 | summary => "Check whether Chrome is running", | ||
| 101 | description => <<'_', | ||
| 102 | |||
| 103 | Chrome is defined as running if there are some Chrome processes that are *not* | ||
| 104 | in 'stop' state. In other words, if Chrome has been started but is currently | ||
| 105 | paused, we do not say that it's running. If you want to check if Chrome process | ||
| 106 | exists, you can use `ps_chrome`. | ||
| 107 | |||
| 108 | _ | ||
| 109 | args => { | ||
| 110 | %App::BrowserUtils::args_common, | ||
| 111 | %App::BrowserUtils::argopt_quiet, | ||
| 112 | }, | ||
| 113 | }; | ||
| 114 | 0 | ▶ | sub chrome_is_running { |
|
Subroutine
chrome_is_running: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 115 | 0 | App::BrowserUtils::_do_browser('is_running', 'chrome', @_); | |
| 116 | } | ||
| 117 | |||
| 118 | $SPEC{terminate_chrome} = { | ||
| 119 | 1 | v => 1.1, | |
| 120 | summary => "Terminate (kill -KILL) Chrome", | ||
| 121 | args => { | ||
| 122 | %App::BrowserUtils::args_common, | ||
| 123 | }, | ||
| 124 | }; | ||
| 125 | 0 | ▶ | sub terminate_chrome { |
|
Subroutine
terminate_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 126 | 0 | App::BrowserUtils::_do_browser('terminate', 'chrome', @_); | |
| 127 | } | ||
| 128 | |||
| 129 | $SPEC{restart_chrome} = { | ||
| 130 | 1 | v => 1.1, | |
| 131 | summary => "Restart chrome", | ||
| 132 | args => { | ||
| 133 | %App::BrowserUtils::argopt_chrome_cmd, | ||
| 134 | %App::BrowserUtils::argopt_quiet, | ||
| 135 | }, | ||
| 136 | features => { | ||
| 137 | dry_run => 1, | ||
| 138 | }, | ||
| 139 | }; | ||
| 140 | 0 | ▶ | sub restart_chrome { |
|
Subroutine
restart_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 141 | 0 | App::BrowserUtils::restart_browsers(@_, restart_chrome=>1); | |
| 142 | } | ||
| 143 | |||
| 144 | $SPEC{start_chrome} = { | ||
| 145 | 1 | v => 1.1, | |
| 146 | summary => "Start chrome if not already started", | ||
| 147 | args => { | ||
| 148 | %App::BrowserUtils::argopt_chrome_cmd, | ||
| 149 | %App::BrowserUtils::argopt_quiet, | ||
| 150 | }, | ||
| 151 | features => { | ||
| 152 | dry_run => 1, | ||
| 153 | }, | ||
| 154 | }; | ||
| 155 | 0 | ▶ | sub start_chrome { |
|
Subroutine
start_chrome: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 156 | 0 | App::BrowserUtils::start_browsers(@_, start_chrome=>1); | |
| 157 | } | ||
| 158 | |||
| 159 | 1 | 1; | |
| 160 | # ABSTRACT: Utilities related to Google Chrome browser | ||
| 161 | |||
| 162 | __END__ | ||