From d9d9c28ed02611bdb2e37039fb62a19fc39815ad Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Sun, 5 Oct 2014 21:41:33 +0200 Subject: Added notifications --- .config/herbstluftwm/popup.sh | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 .config/herbstluftwm/popup.sh (limited to '.config/herbstluftwm/popup.sh') diff --git a/.config/herbstluftwm/popup.sh b/.config/herbstluftwm/popup.sh new file mode 100755 index 0000000..41c5e9c --- /dev/null +++ b/.config/herbstluftwm/popup.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +help () { + echo -e "Usage: popup.sh [OPTIONS]" + echo -e "Spawns a popup for a certain amount of time" + echo -e "" + echo -e "Options:" + echo -e " -m MESSAGE\t\tSpecifies message to be displayed" + echo -e " -t TIMEOUT\t\tAmount of time in seconds the popup is displayed" +} + +add_alpha_channel(){ + echo "$1" | \ + sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" +} + +timeout=10 +message="" +x=0 +y=0 +width=120 +height=90 +urgency="info" + +while getopts ":m:t:x:y:w:h:u:" opt; do + case $opt in + m) message=$OPTARG ;; + t) timeout=$OPTARG ;; + x) x=$OPTARG ;; + y) y=$OPTARG ;; + w) width=$OPTARG ;; + h) height=$OPTARG ;; + u) urgency=$OPTARG ;; + esac +done + +if test ! $message; then + help +else + light=$(add_alpha_channel $WM_LIGHT) + llight=$(add_alpha_channel $WM_LLIGHT) + accent=$(add_alpha_channel $WM_ACCENT) + ldark=$(add_alpha_channel $WM_LDARK) + dark=$(add_alpha_channel $WM_DARK) + font="-*-fixed-medium-*-*-*-$(echo "$height - 10" | bc)-*-*-*-*-*-*-*" + bar_opts="-f ${font} -B $dark -F $light -g ${width}x${height}+${x}+${y} -u 2" + + t=$(date +%T) + + if [ $urgency == "info" ]; then + prefix="Info:" + elif [ $urgency == "high" ]; then + prefix="!!WARNING:" + fi + + { + echo "%{F$accent} $prefix %{F$light}$message %{F$llight}($t)%{F-}" + sleep $timeout + } | bar $bar_opts +fi -- cgit v1.2.3