nixos-config/users/home-manager/foo-dogsquared/config/bin/toggle-process
Gabriel Arazas 3a022a374a Restructure the modules
I think this is better for separating modules explicitly. This is also
considered as there are similar objects between modules (e.g., NixOS
and home-manager modules and users).

Revert users module to old position
2021-12-06 17:03:39 +08:00

30 lines
488 B
Bash
Executable File

#!/usr/bin/env sh
# Dependencies:
# * echo
# * kill
# * pgrep from procps-ng 3.3.15
help_usage="Close if the program is already running.
Otherwise, open the specified program.
Useful for programs that should have one instance running
at a time.
Note that it uses pgrep for searching the existance of
the program.
Usage: $0 <BINARY_NAME>
"
if [[ $# -lt 1 ]]; then
echo "$help_usage"
exit 0
fi
kill $(pgrep $1) 2>/dev/null
if [[ $? != 0 ]]; then
$1 2>/dev/null
fi