Created
February 28, 2023 11:37
-
-
Save justrhysism/8fc3c131a3656a868014c61376a40c3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Fix Wallpaper | |
import "@johnlindquist/kit"; | |
/** | |
* Ensure you have a ~/Library/Desktop/Wallpaper.jpg file ready to go. | |
* | |
* The script requires sudo access, and assumes you have TouchID connected | |
* to `sudo` by prepending: | |
* ``` | |
* auth sufficient pam_tid.so | |
* ``` | |
* to the `/etc/pam.d/sudo` file. | |
* | |
* So your file should look like: | |
* ``` | |
* # sudo: auth account password session | |
* auth sufficient pam_tid.so # <-- Add this line to top | |
* auth sufficient pam_smartcard.so | |
* auth required pam_opendirectory.so | |
* account required pam_permit.so | |
* password required pam_deny.so | |
* session required pam_permit.so | |
* ``` | |
* | |
* Notes: | |
* - This will be reset each time macOS is updated. | |
* - If you have using DisplayLink, TouchID will not work, but macOS | |
* will prompt you for your password. | |
*/ | |
const SETTING_VOLUME_NAME = "Wallpaper"; | |
const SETTING_TARGET_PATH = "/Library/Desktop"; | |
try { | |
await $`diskutil info ${SETTING_VOLUME_NAME} | grep "Volume Name"`; | |
// Use `exec` for processes that require sudo access. | |
await exec( | |
`sudo diskutil umount ${SETTING_VOLUME_NAME}; sudo diskutil mount readOnly -mountPoint ${SETTING_TARGET_PATH} ${SETTING_VOLUME_NAME}` | |
); | |
await $`killall Dock`; | |
} catch (e) { | |
await div( | |
`<div class="p-4 text-red-700"><strong>Error:</strong> ${e._stderr}</div>` | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment