Closed carceneaux closed 1 year ago
Seems to be the same as https://github.com/vitorgalvao/alfred-workflows/issues/147. Ultimately, if the command is returning the wrong information even outside the workflow, there’s nothing I can do. If you do find the cause I can try working around it, but without being able to reproduce I don’t have options for a fix.
Perhaps something changed in Ventura to cause this behavior?
Nope, it still works for me. The update itself may have borked something, though. I’ve been affected by different issues which few other people have, and I’ve also seen the reverse online. As soon as I get the chance I’ll do a fresh install of macOS.
What's interesting from the previous thread you referenced is this command works fine:
It seems access to the file referenced in dndActive
is not available which leads to this behavior:
I got this working by leveraging the command you share in the other thread. I switched the filter type to zsh
and used the following code:
dnd=`/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'`
# DND enabled
if [ $dnd -eq 1 ]; then
cat << EOB
{
"rerun" : 0.5,
"items": [{
"title": "Turn it off",
"subtitle": "Allow notifications again",
"arg": "off",
"icon": { "path": "icon_alt.png" }
}]
}
EOB
exit
else
# DND disabled
givenTimeout=$1
# Any given value must start with a digit
if [ -z "$givenTimeout" ] || ! [[ "$givenTimeout" =~ ^[0-9] ]]; then
cat << EOB
{
"rerun" : 0.5,
"items": [{
"title": "Turn it on",
"subtitle": "Stop notifications from going through",
"arg": "on"
}]
}
EOB
exit
fi
# Calculate timeout
if [[ "$givenTimeout" =~ ^[0-9]+.h ]]; then
timeoutMinutes=$((`echo $givenTimeout | grep -o -E '[0-9]+'` * 60))
else
timeoutMinutes=`echo $givenTimeout | grep -o -E '[0-9]+'`
fi
# Calculate plurality
if [ $timeoutMinutes -gt 1 ]; then
plurality="minutes"
else
plurality="minute"
fi
cat << EOB
{
"rerun" : 0.5,
"items": [{
"title": "Turn it on",
"subtitle": "Stop notifications from going through for ${timeoutMinutes} ${plurality}",
"arg": ${timeoutMinutes}
}]
}
EOB
fi
@vitorgalvao Updated to MacOS 13.1 today and the issue persisted. While my code above works, I realize you might not want to replace yours.
If you replace your current dndActive
function with the below code, it resolves this issue.
function dndActive() {
app = Application.currentApplication()
app.includeStandardAdditions = true
const check = app.doShellScript("/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'")
if (check == 1) return true
return false
}
I’ve updated the workflow to now check status even with the shortcut. Hopefully this means macOS updates will no longer cause breaks. It now lives at a different repo.
Download it from the releases, it will be in the Gallery soon.
Setup info
Description of issue
Workflow never detects DND status as enabled. I ran the code to check DND status in the script editor outside of Alfred and it fails as well. As such, the
dndActive
function always returns empty which makes script filter believe DND is currently disabled.I double-checked that Alfred 5 has Full Disk access to my mac and I haven't seen issues with other workflows. Further detail...I upgraded to Ventura a couple weeks ago.
Perhaps something changed in Ventura to cause this behavior?
Debugger output