fix: update CURRENT_USER discovery

change method to use the loginwindow.plist instead of console
This commit is contained in:
Dan Brodjieski
2026-06-25 12:34:33 -04:00
parent a6f6b58495
commit 05e87c0da9
3 changed files with 3 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ discussion: |
The check and fix are for the currently logged in user. To get the currently logged in user, run the following.
[source,bash]
----
CURRENT_USER=$( /usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
CURRENT_USER=$( /usr/bin/defaults read /Library/Preferences/com.apple.loginwindow lastUserName )
----
====
references:

View File

@@ -70,7 +70,7 @@ fi
plb="/usr/libexec/PlistBuddy"
# get the currently logged in user and hostname
CURRENT_USER=$( /usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }')
CURRENT_USER=$( /usr/bin/defaults read /Library/Preferences/com.apple.loginwindow lastUserName )
CURR_USER_UID=$(/usr/bin/id -u $CURRENT_USER)
CURR_HOSTNAME=$(/usr/sbin/scutil --get HostName)

View File

@@ -67,7 +67,7 @@ fi
plb="/usr/libexec/PlistBuddy"
# get the currently logged in user
CURRENT_USER=$( /usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }')
CURRENT_USER=$( /usr/bin/defaults read /Library/Preferences/com.apple.loginwindow lastUserName )
CURR_USER_UID=$(/usr/bin/id -u $CURRENT_USER)
# get system architecture