Compare commits

..

4 Commits

4 changed files with 17 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -95,7 +95,7 @@ func setup(client *streamdeck.Client) {
return err
}
return setFeedbackIfNeeded(ctx, client, newSettings)
return setFeedback(ctx, client, newSettings)
})
action.RegisterHandler(streamdeck.WillDisappear, func(ctx context.Context, client *streamdeck.Client, event streamdeck.Event) error {
@ -119,17 +119,14 @@ func setup(client *streamdeck.Client) {
ctx := context.Background()
ctx = sdcontext.WithContext(ctx, ctxStr)
setFeedbackIfNeeded(ctx, client, newSettings)
setFeedback(ctx, client, newSettings)
}
_currentSettings = newSettings
}
}()
}
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
return nil
}
func setFeedback(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
payload := FeedbackPayload{}
@ -151,10 +148,19 @@ func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSett
payload.Icon = ValueWithOpacity[any]{nil, opacity}
_currentSettings = newSettings
return client.SetFeedback(ctx, payload)
}
func setFeedbackIfNeeded(ctx context.Context, client *streamdeck.Client, newSettings *volume.VolumeSettings) error {
if _currentSettings.OutputVolume == newSettings.OutputVolume && _currentSettings.OutputMuted == newSettings.OutputMuted {
return nil
}
_currentSettings = newSettings
return setFeedback(ctx, client, newSettings)
}
type FeedbackPayload struct {
Value ValueWithOpacity[string] `json:"value"`
Indicator ValueWithOpacity[int] `json:"indicator"`

View File

@ -49,9 +49,6 @@ type VolumeSettings struct {
}
func GetVolumeSettings() (*VolumeSettings, error) {
//osascript -e "get volume settings"
//output volume:81, input volume:50, alert volume:100, output muted:false
device, result := GetDefaultOutputDevice()
if result != AudioHardwareNoError {
@ -210,3 +207,6 @@ const (
//script := "set volume output muted (not output muted of (get volume settings))"
//return exec.Command("osascript", "-e", "set volume output muted (not output muted of (get volume settings))").Run()
//osascript -e "get volume settings"
//output volume:81, input volume:50, alert volume:100, output muted:false