#!/usr/bin/env bash set -euo pipefail args=("$@") scope="system" if [[ "${args[0]:-}" == "--user" ]]; then scope="user" args=("${args[@]:1}") fi cmd="${args[0]:-}" case "$cmd" in status) ;; is-active) echo "inactive" >&2 exit 3 ;; is-enabled) unit="${args[1]:-}" unit_path="$HOME/.config/systemd/user/${unit}" if [ -f "$unit_path" ]; then echo "enabled" exit 0 fi echo "disabled" >&2 exit 1 ;; show) property="" for arg in "${args[@]:1}"; do case "$arg" in --property=*) property="${arg#--property=}" ;; esac done if [[ "$scope" == "system" && "$property" == "LoadState" ]]; then echo "not-found" exit 0 fi if [[ "$scope" == "system" && "$property" == "UnitPath" ]]; then echo "/etc/systemd/system /usr/lib/systemd/system" exit 0 fi printf "%s\n" \ "ActiveState=inactive" \ "SubState=dead" \ "MainPID=0" \ "ExecMainStatus=0" \ "ExecMainCode=0" ;; esac