nix-files/hosts/common/programs/rofi/rofi-run-command
Colin c50a4d1d71 static-nix-shell: fix mkBash scripts to actually be invokable from the CLI
they need the `bash` package! how did this work before?
2024-06-15 07:42:04 +00:00

24 lines
683 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p sane-open
# use:
# rofi-run-command <handler>.desktop [cmd [args ...]]
# if a non-empty desktop file is provided, we'll just launch that.
# else, if the cmd is `xdg-open`, then we'll treat `args` as a URI and forward that to xdg-open.
# nothing else is as-yet supported.
desktop="$1"
shift
binary="$1"
shift
binArgs=("$@")
if [ "$desktop" != .desktop ]; then
exec sane-open --auto-keyboard --application "$desktop"
elif [ "$binary" = "xdg-open" ]; then
exec sane-open --auto-keyboard --file "${binArgs[@]}"
fi
printf "no .desktop file, and unexpected binary; not invoking: %s %s\n" "$binary" "${binArgs[*]}" >&2
exit 1