File: dqtile-cmd

package info (click to toggle)
qtile 0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,004 kB
  • sloc: python: 49,959; ansic: 4,371; xml: 324; sh: 260; makefile: 218
file content (62 lines) | stat: -rwxr-xr-x 1,583 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

usage() {
    echo "$(tput bold)dqtile-cmd$(tput sgr0)

    A Rofi/dmenu interface to qtile cmd-obj. Accepts all arguments of qtile cmd-obj (see below).

    "

    qtile cmd-obj -h | sed "s/qtile cmd-obj/dqtile-cmd/"


    echo "
    If both rofi and dmenu are present rofi will be selected as default, to change this us --force-dmenu as the first argument.
    "
    exit
}

case $1 in
    -h|--help) usage ;;
    --force-dmenu) FORCE_DMENU=1; shift;;
esac

action=$(qtile cmd-obj $@)

# Path to menu application
if [[ -n $(command -v rofi) ]]  && [[ -z "$FORCE_DMENU" ]]; then
    menu="$(command -v rofi) -dmenu -columns 1"
    global_mesg="Alt-1 	Prompt for args and show function help (if -f is present)
..   	Go back to menu.
C-u  	Clear input
Esc  	Exit"
    action=$(echo -e "$action" | $menu -mesg "$global_mesg") # For rofi
elif [[ -n $(command -v dmenu) ]]; then

    menu="cut -f 1 |  sed -e 's/ *$//g' | $(command -v dmenu)"
    action=$(echo -e "$action" | eval $menu) # For dmenu
else
    echo >&2 "Rofi or dmenu not found"
    exit
fi

action_info=$? # get the return code from rofi

action=$(echo "$action"| cut -f 1 |  sed -e 's/ *$//g')

# if kb-mod-1 key was pressed in rofi
if [ "$action_info" -eq "10" ]; then
    # only run when -f is present (then -i makes sense)
    if [[ $action == *"-f"* ]]; then
        info=$(qtile cmd-obj $action -i)
        action=$($menu -mesg "$global_mesg
<b>Help</b>
$info" -filter "$action -a ")
    fi;
fi;

case $action in
    "") ;; # exit
    ..)$0;; # Go back to main menu
    *) $0 "$action" ;;
esac