From 054fb593252161d73840877aac7408ec887c29c1 Mon Sep 17 00:00:00 2001 From: no-boot-device Date: Sat, 3 Jun 2017 06:56:43 -0500 Subject: [PATCH] Add auto-detection to ./attach-pid Now if you do not provide a PID, it will automagically find whatever game Steam is running. Nobody except for maybe 2 people are going to use this, but I thought it was nice. --- attach-pid | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/attach-pid b/attach-pid index 4e276ede..c91d6152 100755 --- a/attach-pid +++ b/attach-pid @@ -1,8 +1,9 @@ #!/usr/bin/env bash -proc=$1 - -echo Attaching to "$proc" +proc=${1:-$(ps $(pidof gameoverlayui) | tail -n1 | cut -d\- -f2 | cut -d\ -f2)} +if ! [[ $proc =~ ^[0-9]+$ ]]; then + echo "Couldn't find process! Are you sure a game is running?" >&2; exit 1 +fi if grep -q "$(realpath bin/libcathook.so)" /proc/"$proc"/maps; then echo already loaded