From 0e2205b3a72ad80d43cc6946db0615b981a0dddc Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 30 Apr 2018 13:08:10 +0100 Subject: [PATCH] Add click events to server blocks --- i3/blocks/apache | 21 +++++++++++++++++++++ i3/blocks/mysql | 21 +++++++++++++++++++++ i3/blocks/proftp | 21 +++++++++++++++++++++ i3/i3blocks.conf | 14 ++++++++++++-- 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/i3/blocks/apache b/i3/blocks/apache index f051bca5..3a5d93d4 100755 --- a/i3/blocks/apache +++ b/i3/blocks/apache @@ -5,6 +5,27 @@ STATUS=$($LAMPP status 2> /dev/null) APACHE=$(echo "$STATUS" | grep -i apache | grep -io not > /dev/null && echo "down" || echo "up") +function toggleApache(){ + if [ $APACHE = "up" ]; then + gksudo $LAMPP stopapache + else + gksudo $LAMPP startapache + fi +} + +function toggleAll(){ + if [ $APACHE = "up" ]; then + gksudo $LAMPP stop + else + gksudo $LAMPP start + fi +} + +case $BLOCK_BUTTON in + 1) toggleApache ;; + 3) toggleAll ;; +esac + if [ "$APACHE" = "up" ]; then COLOUR="#00FF00" else diff --git a/i3/blocks/mysql b/i3/blocks/mysql index a9eb31a6..4c5e0242 100755 --- a/i3/blocks/mysql +++ b/i3/blocks/mysql @@ -5,6 +5,27 @@ STATUS=$($LAMPP status 2> /dev/null) MYSQL=$(echo "$STATUS" | grep -i mysql | grep -io not > /dev/null && echo "down" || echo "up") +function toggleMysql(){ + if [ $MYSQL = "up" ]; then + gksudo $LAMPP stopmysql + else + gksudo $LAMPP startmysql + fi +} + +function toggleAll(){ + if [ $MYSQL = "up" ]; then + gksudo $LAMPP stop + else + gksudo $LAMPP start + fi +} + +case $BLOCK_BUTTON in + 1) toggleMysql ;; + 3) toggleAll ;; +esac + if [ "$MYSQL" = "up" ]; then COLOUR="#00FF00" else diff --git a/i3/blocks/proftp b/i3/blocks/proftp index 09840272..75489d93 100755 --- a/i3/blocks/proftp +++ b/i3/blocks/proftp @@ -5,6 +5,27 @@ STATUS=$($LAMPP status 2> /dev/null) PROFTP=$(echo "$STATUS" | grep -i proftp | grep -io not > /dev/null && echo "down" || echo "up") +function toggleProftp(){ + if [ $PROFTP = "up" ]; then + gksudo $LAMPP stopftp + else + gksudo $LAMPP startftp + fi +} + +function toggleAll(){ + if [ $PROFTP = "up" ]; then + gksudo $LAMPP stop + else + gksudo $LAMPP start + fi +} + +case $BLOCK_BUTTON in + 1) toggleProftp ;; + 3) toggleAll ;; +esac + if [ "$PROFTP" = "up" ]; then COLOUR="#00FF00" else diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index 565aea38..6b329f57 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -39,9 +39,19 @@ instance=CAPS interval=once signal=11 -[serverstatus] -command=~/.dotfiles/i3/blocks/server +[apachestatus] +command=~/.dotfiles/i3/blocks/apache interval=5 +separator=false + +[mysqlstatus] +command=~/.dotfiles/i3/blocks/mysql +interval=5 +#separator=false + +#[proftpstatus] +#command=~/.dotfiles/i3/blocks/proftp +#interval=5 # Volume indicator #