Skip to content

Instantly share code, notes, and snippets.

@igorepst
Created September 28, 2024 17:54
Show Gist options
  • Save igorepst/fff009f6d1322bb0543e7185754ffa4a to your computer and use it in GitHub Desktop.
Save igorepst/fff009f6d1322bb0543e7185754ffa4a to your computer and use it in GitHub Desktop.
Run or raise for Hyprland
#!/usr/bin/env sh
selectOne() {
target=$(hyprctl clients -j | jq -rc '.[] | select((.class |test("'"${1}"'")))')
if [ -n "${target}" ]; then
target=$(echo "${target}" | jq -r '.address')
hyprctl dispatch "focuswindow address:${target}" >/dev/null
return 0
fi
return 1
}
processFirst() {
set -f; IFS='|'
#shellcheck disable=SC2086
set -- ${1}
for param in "$@"; do
if selectOne "${param}"; then
return 0;
fi
done
set +f; unset IFS
return 1
}
doWork() {
if processFirst "$1"; then
true
elif [ -n "${2}" ]; then
shift
"$@" &
else
"${1}" &
fi
}
doWork "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment