aboutsummaryrefslogtreecommitdiff
path: root/bin/rofi
blob: cfa5a8fa19689dfa5deaac09343ada50be759f5e (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
#!/bin/sh

# GNOME on Wayland does not support the layer-shell protocol that rofi's
# native Wayland backend requires, so fall back to Xwayland there.

self_path=$(readlink -f "$0" 2>/dev/null || printf '%s\n' "$0")
rofi_bin=""

for candidate in /usr/bin/rofi /bin/rofi; do
    candidate_path=$(readlink -f "$candidate" 2>/dev/null || printf '%s\n' "$candidate")
    if [ -x "$candidate" ] && [ "$candidate_path" != "$self_path" ]; then
        rofi_bin="$candidate"
        break
    fi
done

if [ -z "$rofi_bin" ]; then
    printf '%s\n' "rofi: unable to find the system rofi binary" >&2
    exit 127
fi

if [ "${XDG_SESSION_TYPE:-}" = "wayland" ] && [ -n "${WAYLAND_DISPLAY:-}" ]; then
    case "${XDG_CURRENT_DESKTOP:-}:${DESKTOP_SESSION:-}" in
        *GNOME*:*|*:gnome|GNOME:*|gnome:*)
            set -- -x11 "$@"
            ;;
    esac
fi

exec "$rofi_bin" "$@"
nihil fit ex nihilo