Last active
October 4, 2021 18:49
-
-
Save hartmut-co-uk/0219be3959c26868c3183c4a08f2c0fb to your computer and use it in GitHub Desktop.
Script to Toggle Chrome Process-State (STOP|CONT)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2016 Hartmut Armbruster <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
### ~Toggles Google Chrome Process 'State' between Active|Stopped (SIGSTOP|SIGCONT) | |
if [ $(ps -o state $(pgrep -o Chrome) | sed -n 2,2p) = T ]; then | |
echo "PAUSED, continue" | |
kill -CONT $(pgrep -o Chrome); | |
else | |
echo "UP, suspend..." | |
kill -STOP $(pgrep -o Chrome); | |
fi | |
# Note: Using Mac OS 'Automator' it's easy to create a ToggleChrome.app | |
# Steps: | |
# 1. Start Automator, new document 'Application' | |
# 2. Add Action 'Run Shell Script' | |
# 3. Paste the content of this file | |
# 4. Save as Application ToggleChrome.app | |
# Very convenient to e.g. add to Mac OS Dock... =) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment