Skip to content

Commit

Permalink
systemctl: display and toggle systemctl service status
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuku committed Mar 13, 2019
1 parent 21708ed commit 1ed467c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
28 changes: 28 additions & 0 deletions systemctl/Readme.md
Original file line number Diff line number Diff line change
@@ -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
```
17 changes: 17 additions & 0 deletions systemctl/i3blocks.conf
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions systemctl/systemctl
Original file line number Diff line number Diff line change
@@ -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='<span foreground="'$ACTIVE_COLOR'">'$SERVICE'</span>'
INACTIVE='<span foreground="'$INACTIVE_COLOR'"><s>'$SERVICE'</s></span>'

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

Binary file added systemctl/systemctl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1ed467c

Please sign in to comment.