Skip to content

Conversation

@L1cardo
Copy link
Contributor

@L1cardo L1cardo commented Nov 4, 2019


name: Pull request
about: Create a pull request to contribute in making Pock amazing!
title: add single volume toggle and single brightness toggle button
labels: add single volume toggle and single brightness toggle button
assignees: ''


Describe the Pull request

  1. add single volume toggle and single brightness toggle button.
  2. volume toggle button's icon can changes depends on current system volume.
  3. add screensaver button Add 'Start Screensaver' as option in Control Center Widget #256
  4. fix Time Format TextField Changes to Default When Pock Restarts #273

Screenshots
1
demo

Pull request type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Tested?
Yes

Test Configuration:

  • Hardware: [MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports)]
  • macOS Version: [10.15.1]
  • Xcode version: [11.2]

Checklist
Use this list to keep track of your progress:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 4, 2019

volume icon stays sync with the system icon
demo

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 5, 2019

add system-like mute icon

unmuted:
image

muted:
image

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 5, 2019

add high resolution icons

before:
image

after:
image

@L1cardo L1cardo changed the title add single volume toggle and single brightness toggle button add a few buttons Nov 5, 2019
@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 5, 2019

add screensaver button

Demo Here

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 5, 2019

@pigigaldi
When system is muted, NSSound.isMuted returns false. When the system is unmuted, it returns true.
I think it returns last value and is not writable.
I don’t know how to detect if the system is muted or unmuted, so that I don’t know which icon the volume button should display.
Do you have any idea?

@andreashanft
Copy link

@L1cardo I think your pull request is a great addition and I would like to help. If I understand you correctly, you have no reliable way of how to figure out if the system is muted or not?

You could use this code snippet that uses CoreAudio to achieve this:

import CoreAudio

    var isAudioMuted: Bool {
         var defaultHardwareAddress = AudioObjectPropertyAddress(
            mSelector: AudioObjectPropertySelector(kAudioHardwarePropertyDefaultOutputDevice),
            mScope: AudioObjectPropertyScope(kAudioObjectPropertyScopeGlobal),
            mElement: AudioObjectPropertyElement(kAudioObjectPropertyElementMaster))

         var defaultAudioHardwareID: AudioDeviceID = 0
         var defaultHardwarePropertySize = UInt32(MemoryLayout<uint32>.size)
        
        _ = AudioObjectGetPropertyData(
            AudioObjectID(kAudioObjectSystemObject),
            &defaultHardwareAddress, 0 , nil,
            &defaultHardwarePropertySize,
            &defaultAudioHardwareID)
        
         // kAudioDevicePropertyMute: A UInt32 where a value of 1 means that mute is enabled making that element inaudible.
         var muteStatusAddress = AudioObjectPropertyAddress(
            mSelector: AudioObjectPropertySelector(kAudioDevicePropertyMute),
            mScope: AudioObjectPropertyScope(kAudioObjectPropertyScopeOutput),
            mElement: AudioObjectPropertyElement(kAudioObjectPropertyElementMaster))
        
        var isMuted: uint32 = 0
        var muteStatusPropertySize = UInt32(MemoryLayout<uint32>.size)

         _ = AudioObjectGetPropertyData(
            defaultAudioHardwareID,
            &muteStatusAddress, 0, nil,
            &muteStatusPropertySize,
            &isMuted)

         print("Mute Status: \((isMuted == 1) ? "muted" : "unmuted")")
        
        return isMuted == 1
    }

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 12, 2019

@andreashanft Hi! Thanks for your help, I will give it a shot this weekend. But now I should probably working on my exam 😭

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 14, 2019

@andreashanft I tested the code that you offer, but it was still the same problem.
What I mean is that , NSSound.isMuted does not response immediately , it always returns last status of isMutued, which is when system is muted, NSSound.isMuted returns false and when system is unmuted, it returns true.
So the mute image that is on the touchbar is based on the last status of isMutued, and always not correct .

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 14, 2019

change screensaver button icon to the system-like icon
image

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 15, 2019

change lock screen icon to the system-like icon
123123

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 24, 2019

@pigigaldi
When system is muted, NSSound.isMuted returns false. When the system is unmuted, it returns true.
I think it returns last value and is not writable.
I don’t know how to detect if the system is muted or unmuted, so that I don’t know which icon the volume button should display.
Do you have any idea?

I think I have fixed it

@L1cardo
Copy link
Contributor Author

L1cardo commented Nov 24, 2019

icons of volume mute item and volume toggle item now sync with system volume settings

2019-11-24 22-34-58 2019-11-24 22_39_37

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 7, 2019

add "Do not Disturb" button. You can check it out here

one remaining little issue:

  • If you manually turn on "Do Not Disturb" from notification center, Do Not Disturb button of Pock won't work. I don't know why.
  • But if you manually turn off "Do Not Disturb" from notification center, it doesn't matter, Pock will work nice as usual.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 9, 2019

add missing localizations
But I have a question:
Can we have system folders names localized that are shown on Dock ?

触控栏快照2019-12-09下午6 09 27

@pigigaldi pigigaldi closed this in 79ebb8a Dec 14, 2019
@pigigaldi pigigaldi merged commit df70043 into pock:master Dec 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time Format TextField Changes to Default When Pock Restarts

3 participants