swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

Script doesn't work #242

Closed DUOLabs333 closed 2 years ago

DUOLabs333 commented 2 years ago

I'm trying to have a script that locks my screen when I close it (but not turn it off). The script, lockscreen.1s.sh works in bash, but not in SwiftBar

#!/opt/local/bin/bash

while true
do
    if [[ $(ioreg -r -k AppleClamshellState | grep '"AppleClamshellState"' | cut -f2 -d"=") = ' Yes' ]]; then
        ./lockscreen
        sleep 1
    fi
done
melonamin commented 2 years ago

I'm not sure what you're trying to achieve...

The main use for SwiftBar is to show something in the menu bar(like weather) or create a custom menu of things, both can be updated on a schedule. In this case you have a deamon style script, SwiftBar can't help you with that, use launchd

xilopaint commented 2 years ago

I'm not sure what you're trying to achieve...

The main use for SwiftBar is to show something in the menu bar(like weather) or create a custom menu of things, both can be updated on a schedule. In this case you have a deamon style script, SwiftBar can't help you with that, use launchd

Wouldn't it be possible for a streaming plugin to do the job?

melonamin commented 2 years ago

You probably can hack around something, in the end SwiftBar "just launches scripts", but I don't endorse it, it doesn't make sense.

More than that, as soon as the system prepares to sleep SwiftBar kills all running plugins and restart them on wake up.