#!/usr/bin/env sh # nixos-config - My current NixOS configuration # # Copyright (C) 2025 Benedikt Peetz # SPDX-License-Identifier: GPL-3.0-or-later # # This file is part of my nixos-config. # # You should have received a copy of the License along with this program. # If not, see . use_user=false service="" while [ "$#" -ne 0 ]; do case "$1" in "--user") use_user=true ;; *) if [ -n "$service" ]; then echo "Service was already specified as: '$service'" exit 2 else service="$1" fi ;; esac shift 1 done user_str="" if [ "$use_user" = "true" ]; then user_str="--user" fi service_status="$(systemctl $user_str show "$service" | grep ActiveState | sed 's/ActiveState=//')" if [ "$service_status" = "inactive" ]; then systemctl $user_str start "$service" else systemctl $user_str stop "$service" fi # vim: ft=sh