aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/popup.sh
diff options
context:
space:
mode:
Diffstat (limited to '.config/herbstluftwm/popup.sh')
-rwxr-xr-x.config/herbstluftwm/popup.sh60
1 files changed, 60 insertions, 0 deletions
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 @@
1#!/bin/bash
2
3help () {
4 echo -e "Usage: popup.sh [OPTIONS]"
5 echo -e "Spawns a popup for a certain amount of time"
6 echo -e ""
7 echo -e "Options:"
8 echo -e " -m MESSAGE\t\tSpecifies message to be displayed"
9 echo -e " -t TIMEOUT\t\tAmount of time in seconds the popup is displayed"
10}
11
12add_alpha_channel(){
13 echo "$1" | \
14 sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/"
15}
16
17timeout=10
18message=""
19x=0
20y=0
21width=120
22height=90
23urgency="info"
24
25while getopts ":m:t:x:y:w:h:u:" opt; do
26 case $opt in
27 m) message=$OPTARG ;;
28 t) timeout=$OPTARG ;;
29 x) x=$OPTARG ;;
30 y) y=$OPTARG ;;
31 w) width=$OPTARG ;;
32 h) height=$OPTARG ;;
33 u) urgency=$OPTARG ;;
34 esac
35done
36
37if test ! $message; then
38 help
39else
40 light=$(add_alpha_channel $WM_LIGHT)
41 llight=$(add_alpha_channel $WM_LLIGHT)
42 accent=$(add_alpha_channel $WM_ACCENT)
43 ldark=$(add_alpha_channel $WM_LDARK)
44 dark=$(add_alpha_channel $WM_DARK)
45 font="-*-fixed-medium-*-*-*-$(echo "$height - 10" | bc)-*-*-*-*-*-*-*"
46 bar_opts="-f ${font} -B $dark -F $light -g ${width}x${height}+${x}+${y} -u 2"
47
48 t=$(date +%T)
49
50 if [ $urgency == "info" ]; then
51 prefix="Info:"
52 elif [ $urgency == "high" ]; then
53 prefix="!!WARNING:"
54 fi
55
56 {
57 echo "%{F$accent} $prefix %{F$light}$message %{F$llight}($t)%{F-}"
58 sleep $timeout
59 } | bar $bar_opts
60fi