aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/sw/swallow/swallow.sh
blob: ac1858ea52f038eb695f8307f9a7163465545cbe (plain) (blame)
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
#!/usr/bin/env dash
# Based on: https://codeberg.org/nirodhvana/reservoir/src/commit/2fa8c14877799a03bb927f048c2907dbb418fd68/dot-local/bin/gobble

# Inspired by https://github.com/swindlesmccoop/not-just-dotfiles/blob/master/.local/bin/swallow

swallow_tag=$((1 << 9))
eat() {
    riverctl set-view-tags $swallow_tag
}

throwup() {
    riverctl set-focused-tags $swallow_tag &&
        riverctl send-to-previous-tags &&
        riverctl focus-previous-tags
}

if [ -z "$*" ]; then
    printf "ERROR: No arguments supplied\n"
elif ! command -v "$1" >/dev/null; then
    printf "ERROR: Command '%s' does not exist\n" "$1"
else
    eat && "$@"

    throwup
fi