Skip to content

Instantly share code, notes, and snippets.

@colorenz
Created October 23, 2022 10:57
Show Gist options
  • Save colorenz/381bcd4d5c98da84c4383489e6717b88 to your computer and use it in GitHub Desktop.
Save colorenz/381bcd4d5c98da84c4383489e6717b88 to your computer and use it in GitHub Desktop.
Extenstion Attribute to check if a User Desktop or Documents Folder are KFM Folders
#!/bin/zsh
### Version Beta 0.2
### Created by Colorenz
### Extenstion Attribute to check if KFM Status
### KFM Values
### 0 = Off
### 512 = Desktop Backed Up
### 1024 = Documents Backed Up
### 1536 = Desktop and Documents Backed Up.
#Get Current logined User
CurrentUser=$(scutil <<<"show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }')
#Get Current User Home
KFMFolderStatus=$(/usr/libexec/PlistBuddy -c "print :AccountInfo_Business1:KfmSilentAttemptedFolders" /Users/${CurrentUser}/Library/Group\ Containers/UBF8T346G9.OneDriveStandaloneSuite/Library/Preferences/UBF8T346G9.OneDriveStandaloneSuite.plist)
#Check if KFM Status
case "$KFMFolderStatus" in
"0") /bin/echo "<result>KFM not activated</result>"
;;
"512") /bin/echo "<result>Desktop is activated</result>"
;;
"1024") /bin/echo "<result>Documents is activated</result>"
;;
"1536") /bin/echo "<result>Desktop and Documents is activated</result>"
;;
esac
@marcelpogorzelski
Copy link

marcelpogorzelski commented Dec 14, 2022

Maybe have a file exist check for the plist or a dump errors in PlistBuddy. Extenstion Attribute can run at loginwindow which will give an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment