#!/bin/bash
##################################################################
#                                                                #
#  Use this stop script to kill all scifi conkies.               #
#                                                                #
#  Do not change filenames or window titles of the conkies!      #
#  Always use the .conky extention!                              #
#  the scripts depend heavy on them!                             #
#                                                                #
#  Scripted by Koentje   (remon@cobrasoft.nl)                    #
#                                                                #
#  PLEASE DO NOT EDIT THIS SCRIPT !!!                            #
#                                                 version: 1.0   #
##################################################################

# Get real path to working folder
  scrpath=$(readlink -f $0)
  workdir=$(dirname $scrpath)
  cd "$workdir"

# Get all *.conky files into array
  while read -r files
  do
      conkies+=("${files##*/}")
  done< <(find "$workdir" -maxdepth 1 -type f -name "*.conky" | sort)

# Number of conkies
  for index in ${!conkies[@]}; do
      nr_conkies=$(echo "$index")
  done

# Kill all conkies
  x=0
  for conky in "${conkies[@]}"
  do
        while read -r loaded
        do
             if [ "$conky" = "$loaded" ]; then
              l=${#conky}
              space=$((40-l))
              printf "* $conky"; printf "\e[31m %"$space"s \e[m\n" "killed!"
              pkill -f "$conky"
              x=1
             fi
        done< <(pgrep -a "conky" | grep 'scifi' | awk -F'-c ' '{print $NF}')
  done
  if [ "$x" = "0" ]; then echo -e "\n\e[32mNothing to kill.. \e[m\n"; fi
