diff --git a/systemctl/Readme.md b/systemctl/Readme.md new file mode 100644 index 00000000..99dcb146 --- /dev/null +++ b/systemctl/Readme.md @@ -0,0 +1,28 @@ +# systemctl + +Show systemctl service status, allows to toggle status with left click. +Accepts the same service names as systemctl eg. "redis" or "docker". + +![](systemctl.png) + +# Config + +``` +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=docker + +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=redis + +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=postgresql +``` diff --git a/systemctl/i3blocks.conf b/systemctl/i3blocks.conf new file mode 100644 index 00000000..d6ce4100 --- /dev/null +++ b/systemctl/i3blocks.conf @@ -0,0 +1,17 @@ +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=docker + +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=redis + +[systemctl] +command=$SCRIPT_DIR/systemctl +interval=once +markup=pango +instance=postgresql diff --git a/systemctl/systemctl b/systemctl/systemctl new file mode 100755 index 00000000..c6de0192 --- /dev/null +++ b/systemctl/systemctl @@ -0,0 +1,32 @@ +#!/bin/bash + +# The service we want to check or toggle (according to systemctl) +SERVICE=$BLOCK_INSTANCE +# Colors to display +INACTIVE_COLOR=#888888 +ACTIVE_COLOR=#22BB22 +# Exact string to display +ACTIVE=''$SERVICE'' +INACTIVE=''$SERVICE'' + +if [ "`systemctl is-active $SERVICE`" != "active" ] +then + if [ $BLOCK_BUTTON == '1' ] + then + if systemctl start $SERVICE + then + echo $ACTIVE + fi + fi + echo $INACTIVE +else + if [ $BLOCK_BUTTON == '1' ] + then + if systemctl stop $SERVICE + then + echo $INACTIVE + fi + fi + echo $ACTIVE +fi + diff --git a/systemctl/systemctl.png b/systemctl/systemctl.png new file mode 100644 index 00000000..cabbd7d0 Binary files /dev/null and b/systemctl/systemctl.png differ