-
Notifications
You must be signed in to change notification settings - Fork 420
Add feature to run shell scripts or send URL notifications on various events #4320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
By https://github.com/manishprivet (originally posted here: MonitorControl/MonitorControl#1752 (reply in thread)) Thanks for the quick reply, and for the project as well. It is a life changer!!! I checked the BetterDisplay shortly after commenting, and I was so glad I found it. However it reaches only 80% of my use-case, so I would like to make this feature request for BetterDisplay instead. I am currently using the CLI like this to display volume in Sketchybar (ref) elif command -v betterdisplaycli 2>&1 >/dev/null; then
if [ "$VOLUME" = "missing value" ]; then
ALTERNATE_VOLUME=$(betterdisplaycli get -feature=volume -value -displayWithMainStatus | bc)
MEGA=100
if [[ $ALTERNATE_VOLUME =~ "." ]]; then
VOLUME=$(bc -l <<<"${ALTERNATE_VOLUME}*${MEGA}" | bc)
VOLUME=$(echo "$VOLUME" | cut -d. -f1)
fi
MUTE=$(betterdisplaycli get -feature=mute -value -displayWithMainStatus)
if [ "$MUTE" = "on" ]; then
VOLUME="0"
fi
fi
fi However, I currently have to run the script as a cron job since I am not sure how to catch events from BetterDisplay and run a shell command after I change volume. For example, in aerospace, I have this to trigger an event inside sketchybar (ref) exec-on-workspace-change = ['/bin/bash', '-c',
'sketchybar --trigger aerospace_workspace_change'
] And I was hoping BetterDisplay/MonitorControl also had something like this. In the documentation I can find a way to catch the event in a Swift application. If there is a simpler alternative to that, I would appreciate that a lot. |
Oh, I see - so you need sketchybar to do something when you change the volume in BetterDisplay? Well, you can do it in a somewhat roundabout way - you can create an integration control for volume, use shell script as integration method, add your command to trigger sketchybar and also add a CLI command to directly adjust the DDC volume (by addressing the right VCP). By setting up integration controls for volume and mute, the app's volume slider, keyboard etc will use that instead of DDC volume (which you can as well turn that off under DDC Features). |
Thanks @waydabber for considering the request. Regarding
I guess this suggestion can work, I will try it tomorrow and let you know. But it still feels very hacky and brittle. I was hoping for a way to control these things via dotfiles, but maybe that is a too big of an ask 😅 If you can add a hook in app to trigger a shell script on volume change, that will simplify things a little bit though as you said. |
I don't think I'll implement dotfiles based configuration - things are a bit difficult to keep track now just as they are. The app solely uses macOS user defaults for configuration so one can reach (query and modify, export import) any settings that via terminal using (but maybe I misunderstand the request :)) |
I added the integration control like this And I turned of the However the command in Integration Control doesn't seem to be executing when I am changing volume with Media keys. For Example betterdisplaycli set -ddc -vcp=audioSpeakerVolume -value=30 This works fine in my terminal. However I hardcoded the |
Try to add a log output there (by attaching something like |
Thanks @waydabber for the help. Using absolute path fixed this. However I cannot find the correct vcp for the mute feature, can you help with that? As without a Also even if this is functional, changing volume rapidly doesn't register all instances of the command unfortunately like the native integration does 😞 If having a callback feature is possible, that will make things a lot smoother. |
The display might not support mute and getting mute state rarely works. The app by default actually sets both volume to 0 on mute and sends the mute command as well. The problem might be rate limiting/debouncing - I will add this as feature for integration controls (until that time you can do so in a script). Also, sometimes a single DDC send with volume might be ineffective, so you can simply try sending the DDC request twice. |
(Note: An other entirely different approach is to simply reuse the swift example about notifications and create a simple swift executable (daemon) that runs in the background and calls the appropriate script. I think ChatGPT can put one together super quick if you feed the example code.) |
I will try this sometime this weekend. Thank you for getting the functionality working for me as now I can update the volume in my status-bar real time 🎉 |
The app now sends distributed notifications on various control events - it would be nice if the app could also run scripts or call URLs.
The text was updated successfully, but these errors were encountered: