Created
March 13, 2019 00:44
-
-
Save dkuku/e744570b708b3ca2f3511d3477d35145 to your computer and use it in GitHub Desktop.
i3blocks - toggle services like docker or redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[docker] | |
command=$HOME/systemctl | |
interval=once | |
markup=pango | |
[redis] | |
command=$HOME/systemctl | |
interval=once | |
markup=pango | |
[postgresql] | |
command=$HOME/systemctl | |
interval=once | |
markup=pango |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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