aboutsummaryrefslogtreecommitdiffstats
path: root/config/herbstluftwm/popup.sh
blob: eda37f583b13cd967c73b5134854957de48c8595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/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"
    echo -e "  -u LEVEL\t\tUrgency level (info or high)"
}

dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$dir/theme.sh"

timeout=10
message=""
urgency="info"

while getopts ":m:t:x:y:w:h:u:" opt; do
    case $opt in
        m) message=$OPTARG ;;
        t) timeout=$OPTARG ;;
        u) urgency=$OPTARG ;;
    esac
done

if test ! $message; then
    help
else

    bar_opts="-f $font,$font_sec -B $acolor_bg -F $acolor_fg -g ${popup_width}x${height}+${popup_x}+${popup_y} -u 2"

    t=$(date +%T)

    if [ $urgency == "info" ]; then
        prefix="Info:"
    elif [ $urgency == "high" ]; then
        prefix="!!WARNING:"
    fi

    {
        echo "%{F$acolor_accent} $prefix %{F$acolor_fg}$message %{F$acolor_fg}($t)%{F-}"
        sleep $timeout
    } | bar $bar_opts
fi