Skip to content

Commit

Permalink
Merge pull request #221 from dkuku/master
Browse files Browse the repository at this point in the history
systemctl: display and toggle systemctl service status
  • Loading branch information
denisse-dev authored Oct 22, 2021
2 parents ad218f0 + 5505dec commit 5f64e3b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This repository contains a set of scripts (a.k.a. *blocklets*) for link:https://
| link:openvpn[] | Show openvpn status
| link:rofi-calendar[] | Current date/time and click for callendar using rofi
| link:shutdown_menu[] | Shutdown menu using rofi or zenity
| link:systemctl[] | Startup and Shutdown system services
| link:tahoe-lafs[] | Show status of your tahoe-lafs grid
| link:temperature[] | Show system temperatures using lm-sensors
| link:time[] | Show the current date/time and click to change timezones
Expand Down
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
31 changes: 31 additions & 0 deletions systemctl/systemctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/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 5f64e3b

Please sign in to comment.