Skip to content

Instantly share code, notes, and snippets.

@Scott-Nx
Created March 24, 2025 13:17
Show Gist options
  • Select an option

  • Save Scott-Nx/c1a5663b173972438a19cfd1cbc22962 to your computer and use it in GitHub Desktop.

Select an option

Save Scott-Nx/c1a5663b173972438a19cfd1cbc22962 to your computer and use it in GitHub Desktop.
#!/bin/bash
SERVICE="avahi-daemon.service"
start_service() {
systemctl start $SERVICE
echo "$SERVICE started."
notify-send "Service Notification" "$SERVICE started."
}
stop_service() {
systemctl stop $SERVICE
echo "$SERVICE stopped."
notify-send "Service Notification" "$SERVICE stopped."
}
if systemctl is-active --quiet $SERVICE; then
stop_service
else
start_service
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment