aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/util/dmenu.sh
blob: da61cae0a4c513d3dc4f925d78cfc2200050867b (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
# dmenu setup

case "$DMENU_SCHEME" in
    # wmii
    "wmii" )
        NB="#303030"
        NF="khaki"
        SB="#ccffaa"
        SF="#303030"
        ;;
    # Formfiller
    "formfiller" )
        NB="#0f0f0f"
        NF="#4e7093"
        SB="#003d7c"
        SF="#3a9bff"
        ;;
    # Bookmarks
    "bookmarks" )
        NB="#303030"
        NF="khaki"
        SB="#ccffaa"
        SF="#303030"
        ;;
    # History
    "history" )
        NB="#303030"
        NF="khaki"
        SB="#ccffaa"
        SF="#303030"
        ;;
    # Default
    * )
        NB="#303030"
        NF="khaki"
        SB="#ccffaa"
        SF="#303030"
        ;;
esac

DMENU_COLORS="-nb $NB -nf $NF -sb $SB -sf $SF"

# Default arguments
if [ -z "$DMENU_ARGS" ]; then
    DMENU_ARGS="-i"
fi

# Set the font if wanted
if [ -n "$DMENU_FONT" ]; then
    DMENU_ARGS="$DMENU_ARGS -fn $DMENU_FONT"
fi

# Set the prompt if wanted
if [ -n "$DMENU_PROMPT" ]; then
    DMENU_ARGS="$DMENU_ARGS -p $DMENU_PROMPT"
fi

# Detect the xmms patch
if dmenu --help 2>&1 | grep -q '\[-xs\]'; then
    DMENU_XMMS_ARGS="-xs"
    DMENU_HAS_XMMS=1

    if echo $DMENU_OPTIONS | grep -q -w 'xmms'; then
        DMENU_ARGS="$DMENU_ARGS $DMENU_XMMS_ARGS"
    fi
fi

# Detect the vertical patch
if dmenu --help 2>&1 | grep -q '\[-l <\?lines>\?\]'; then
    # Default to 10 lines
    if [ -z "$DMENU_LINES" ]; then
        DMENU_LINES=10
    fi

    DMENU_VERTICAL_ARGS="-l $DMENU_LINES"
    DMENU_HAS_VERTICAL=1

    # Detect the resize patch
    if dmenu --help 2>&1 | grep -q '\[-rs\]'; then
        DMENU_RESIZE_ARGS="-rs"
        DMENU_HAS_RESIZE=1
    fi

    if echo $DMENU_OPTIONS | grep -q -w 'vertical'; then
        DMENU_ARGS="$DMENU_ARGS $DMENU_VERTICAL_ARGS"

        if echo $DMENU_OPTIONS | grep -q -w 'resize'; then
            DMENU_ARGS="$DMENU_ARGS $DMENU_RESIZE_ARGS"
        fi
    fi
fi

# Detect placement patch
if dmenu --help 2>&1 | grep -q '\[-x <xoffset>\]'; then
    DMENU_PLACE_X="-x"
    DMENU_PLACE_Y="-y"
    DMENU_PLACE_WIDTH="-w"
    DMENU_PLACE_HEIGHT="-h"
    DMENU_HAS_PLACEMENT=1
fi

DMENU="dmenu $DMENU_ARGS $DMENU_COLORS"