Skip to content

Instantly share code, notes, and snippets.

@dkuku
Created March 13, 2019 00:44
Show Gist options
  • Save dkuku/e744570b708b3ca2f3511d3477d35145 to your computer and use it in GitHub Desktop.
Save dkuku/e744570b708b3ca2f3511d3477d35145 to your computer and use it in GitHub Desktop.
i3blocks - toggle services like docker or redis
[docker]
command=$HOME/systemctl
interval=once
markup=pango
[redis]
command=$HOME/systemctl
interval=once
markup=pango
[postgresql]
command=$HOME/systemctl
interval=once
markup=pango
#!/bin/bash
# The service we want to check (according to systemctl)
SERVICE=$BLOCK_NAME
if [ "`systemctl is-active $SERVICE`" != "active" ]
then
if [ $BLOCK_BUTTON == '1' ]
then
echo '<span foreground="#00FF00">'$SERVICE'</span>'
systemctl start $SERVICE
else
echo '<span foreground="#FF0000">'$SERVICE'</span>'
fi
else
if [ $BLOCK_BUTTON == '1' ]
then
echo '<span foreground="#FF0000">'$SERVICE'</span>'
systemctl stop $SERVICE
else
echo '<span foreground="#00FF00">'$SERVICE'</span>'
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment