Coder Social home page Coder Social logo

Comments (4)

vitorgalvao avatar vitorgalvao commented on August 22, 2024

Seems to be the same as #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.

from alfred-workflows.

carceneaux avatar carceneaux commented on August 22, 2024

What's interesting from the previous thread you referenced is this command works fine:

CleanShot 2022-12-08 at 14 05 20

  • disabled DND
  • enabled DND
  • disabled DND

It seems access to the file referenced in dndActive is not available which leads to this behavior:

CleanShot 2022-12-08 at 14 11 20

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

from alfred-workflows.

carceneaux avatar carceneaux commented on August 22, 2024

@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
}

from alfred-workflows.

vitorgalvao avatar vitorgalvao commented on August 22, 2024

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.

from alfred-workflows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.