Skip to content

Commit

Permalink
feat(maclaunch): add simple runs as user feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hazcod authored Dec 27, 2019
1 parent 204bfc8 commit e3bec2a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions maclaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ function isSystem {
[[ $1 == /System/* ]]
}

function getScriptUser {
local scriptPath="$1"

if echo "$scriptPath" | grep -q "LaunchAgent"; then
whoami
return
fi

if ! grep -q '<key>UserName</key>' "$scriptPath"; then
echo "root"
return
fi

echo "custom"
}

function listItems {
itemDirectories=("${startup_dirs[@]}")

Expand Down Expand Up @@ -127,8 +143,16 @@ function listItems {
startup_type=" (core)"
fi

runAsUser="$(getScriptUser "$f")"
if [ "$runAsUser" = "root" ]; then
runAsUser="${RED}root${NC}"
elif [ "$runAsUser" = "custom" ]; then
runAsUser="${YELLOW}custom${NC}"
fi

echo -e "${BOLD}> ${startup_name}${NC}${startup_type}"
echo " Type : ${type}"
echo -e " User : ${runAsUser}"
echo -e " Launch: ${load_str}${NC}"
echo " File : $f"

Expand Down

0 comments on commit e3bec2a

Please sign in to comment.