aboutsummaryrefslogtreecommitdiff
path: root/.config/bspwm/scripts/hide-window
blob: c350a0e5e73f92ec34a4ed878255c34eb3be1694 (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
#!/bin/bash

CMD=${1:-help}
shift

help() {
    echo "Available commands:"
    echo "  * unhide - select and unhide window"
}

unhide() {
    action=${1:-list}
    case $action in
        "list")
            selection=$(for id in "$(bspc query -N -n .hidden)"; do
                    title=$(xtitle "$id")
                    [[ -z "$title" ]] && title="<unnamed>"
                    echo "$id" "$title"
            done | rofi -dmenu -i -p "Hidden windows" | cut -f1 -d' ')

                [[ -z "$selection" ]] && exit 1

                bspc node "$selection" -g hidden=off
                ;;
        esac
    }

    case $CMD in
        "help")
            help
            ;;
        "unhide")
            unhide "$1"
            ;;
        *)
            help
            ;;
    esac