dotfiles/packages/scripts/open-url/open-url
Christopher Mühl 786af32daf
Publish my config
This is the result of ~100 commits to my NixOS config. Since I haven't
always used `agenix-rekey`, this is another initial commit so that none
of the secrets in my git history are leaked
2025-07-30 23:36:39 +02:00

21 lines
623 B
Bash
Executable file

#!/usr/bin/env bash
# Go up the parent chain of this process to determine if the link was clicked on
# in Slack. If so, open the `Work` profile on firefox.
parent=$PPID
while [ "$parent" -ne 1 ]; do
cmd=$(ps -o comm= -p "$parent")
if [[ "$cmd" == "slack" ]]; then
firefox -P 'Work' "$@"
exit 0
fi
parent=$(ps -o ppid= -p "$parent" | tail -n 1 | awk '{print $1}')
done
if [[ $1 == "https://github.com/hausgold"* ]]; then
# Also use the `Work` profile for hausgold Github links
firefox -P 'Work' "$@"
else
# Otherwise just use the default profile of Firefox directly
firefox "$@"
fi