Skip to content

Commit

Permalink
bugfix: Mic mute doesn't sync with led some time.
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzturc committed May 8, 2020
1 parent e431a23 commit c53ccc2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ThinkpadAssistant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.2.2;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = de.mszturc.ThinkpadAssistant;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -583,7 +583,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.2.2;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = de.mszturc.ThinkpadAssistant;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>AutoLaunchHelper.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
<integer>6</integer>
</dict>
<key>ThinkpadAssistant.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
<integer>5</integer>
</dict>
</dict>
</dict>
Expand Down
18 changes: 18 additions & 0 deletions ThinkpadAssistant/MuteMicManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ final class MuteMicManager {

private static let shared = MuteMicManager()

static func activateMicrophone(){
shared.activateMicrophone()
}

static func deactivateMicrophone(){
shared.deactivateMicrophone()
}

static func toggleMute() {
shared.toogleMute()
}
Expand Down Expand Up @@ -66,6 +74,16 @@ final class MuteMicManager {
setMute(!isMuted())
}

func activateMicrophone(){
assert(isMuteSettable())
setMute(false)
}

func deactivateMicrophone(){
assert(isMuteSettable())
setMute(true)
}

private func isMuteSettable() -> Bool {
var isSettable: DarwinBoolean = false
AudioObjectIsPropertySettable(currentInputDeviceID, &mutePropertyAddress, &isSettable).handleError()
Expand Down
16 changes: 16 additions & 0 deletions ThinkpadAssistant/ShortcutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ final class ShortcutManager {
static let systemPrefsShortcut = MASShortcut(keyCode: kVK_F18, modifierFlags: [])
static let launchpadShortcut = MASShortcut(keyCode: kVK_F19, modifierFlags: [])
static let micMuteShortcut = MASShortcut(keyCode: kVK_F20, modifierFlags: [])
static let micMuteShortcutActivate = MASShortcut(keyCode: kVK_F20, modifierFlags: [.control])
static let micMuteShortcutDeactivate = MASShortcut(keyCode: kVK_F20, modifierFlags: [.command])

static func register() {
MASShortcutMonitor.shared()?.register(systemPrefsShortcut, withAction: {
Expand All @@ -36,6 +38,20 @@ final class ShortcutManager {
}
})

MASShortcutMonitor.shared()?.register(micMuteShortcutActivate, withAction: {
if(MuteMicManager.isMuted() == true){
HUD.showImage(Icons.unmute, status: NSLocalizedString("Microphone\nunmuted", comment: ""))
MuteMicManager.activateMicrophone()
}
})

MASShortcutMonitor.shared()?.register(micMuteShortcutDeactivate, withAction: {
if(MuteMicManager.isMuted() == false){
HUD.showImage(Icons.mute, status: NSLocalizedString("Microphone\nmuted", comment: ""))
MuteMicManager.deactivateMicrophone()
}
})

MASShortcutMonitor.shared()?.register(disableWlanShortcut, withAction: {
if(WifiManager.isPowered() == nil){
return
Expand Down

0 comments on commit c53ccc2

Please sign in to comment.