Skip to content

Commit

Permalink
Merge pull request #11 from satrik/version1_5
Browse files Browse the repository at this point in the history
Version 1.5
  • Loading branch information
satrik authored Feb 19, 2024
2 parents f4a8309 + 963eb90 commit ed72ac0
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 136 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## toggleMute

### note
I don't use a MacBook with Touch Bar anymore. So if there are any issues with the Touch Bar, I can't help/debug by myself

### functions
- Single tab/click on the Touch Bar or the Menubar icon will toggle between mute and unmute.
- Right click on the Menubar icon will show the setting for the default unmute volume.
Expand All @@ -8,8 +11,10 @@
- click on the little gear symbol will show the option to set a global _Keyboard Shortcut_, the option for _Autostart_ and a _Quit_ button

### install
- download and unpack the toggleMute.zip
- move the _toggleMute.app_ file to the Applications directory
- download or clone the repo
- unpack the toggleMute.zip and move toggleMute.app into the Applications folder
- execute (just double click) the toggleMuteDisableQuarantine.command
- if this does not work, you have to execute `xattr -cr /Applications/toggleMute.app` in a terminal
- start the App the first time via right click > open and "Trust me" :wink:
- the Touch Bar button is only visible in the "control strip" and can't be moved to any other place

Expand Down
Binary file modified img/app_prev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/menubar_prev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified toggleMute.zip
Binary file not shown.
44 changes: 10 additions & 34 deletions toggleMute/toggleMute.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -14,7 +14,6 @@
449F397C23172ADC008A0DBD /* Controllers.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 449F397B23172ADC008A0DBD /* Controllers.storyboard */; };
449F398323173003008A0DBD /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449F398223173003008A0DBD /* Preferences.swift */; };
449F398D23173610008A0DBD /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 449F398C23173610008A0DBD /* SettingsController.swift */; };
449F39932317375C008A0DBD /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 449F39952317375C008A0DBD /* Localizable.strings */; };
44D551E02390830E0065505A /* SharedFileList.m in Sources */ = {isa = PBXBuildFile; fileRef = 44D551DE2390830E0065505A /* SharedFileList.m */; };
44EB8BD923AC2ABD005A4A0B /* TouchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44EB8BD723AC2ABD005A4A0B /* TouchBarController.swift */; };
44EB8BDD23AC350D005A4A0B /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44EB8BDB23AC350D005A4A0B /* SettingsViewController.swift */; };
Expand Down Expand Up @@ -44,8 +43,6 @@
449F397B23172ADC008A0DBD /* Controllers.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Controllers.storyboard; sourceTree = "<group>"; };
449F398223173003008A0DBD /* Preferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
449F398C23173610008A0DBD /* SettingsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
449F39942317375C008A0DBD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
449F39962317375D008A0DBD /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
44D551DD2390830E0065505A /* SettingsController-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SettingsController-Bridging-Header.h"; sourceTree = "<group>"; };
44D551DE2390830E0065505A /* SharedFileList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedFileList.m; sourceTree = "<group>"; };
44D551DF2390830E0065505A /* SharedFileList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedFileList.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -109,7 +106,6 @@
isa = PBXGroup;
children = (
44D551DC239082090065505A /* Storyboard */,
449F399023173742008A0DBD /* Localizable */,
449F398023172AEE008A0DBD /* Assets */,
449F39702317247C008A0DBD /* Info.plist */,
449F39712317247C008A0DBD /* SettingsController.entitlements */,
Expand All @@ -125,14 +121,6 @@
path = Assets;
sourceTree = "<group>";
};
449F399023173742008A0DBD /* Localizable */ = {
isa = PBXGroup;
children = (
449F39952317375C008A0DBD /* Localizable.strings */,
);
path = Localizable;
sourceTree = "<group>";
};
44D551D923907B7F0065505A /* Support */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -211,6 +199,7 @@
en,
fr,
Base,
de,
);
mainGroup = 449F395D2317247B008A0DBD;
packageReferences = (
Expand All @@ -232,7 +221,6 @@
buildActionMask = 2147483647;
files = (
449F396C2317247C008A0DBD /* Assets.xcassets in Resources */,
449F39932317375C008A0DBD /* Localizable.strings in Resources */,
449F397C23172ADC008A0DBD /* Controllers.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -277,18 +265,6 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
449F39952317375C008A0DBD /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
449F39942317375C008A0DBD /* en */,
449F39962317375D008A0DBD /* fr */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
449F39722317247C008A0DBD /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -418,7 +394,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = MFTS39V3F9;
ENABLE_HARDENED_RUNTIME = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -430,7 +406,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
OTHER_LDFLAGS = (
"-framework",
DFRFoundation,
Expand All @@ -452,7 +428,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = MFTS39V3F9;
ENABLE_HARDENED_RUNTIME = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -464,7 +440,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 1.4;
MARKETING_VERSION = 1.5;
OTHER_LDFLAGS = (
"-framework",
DFRFoundation,
Expand Down Expand Up @@ -504,16 +480,16 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/KeyboardShortcuts";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.4.0;
kind = exactVersion;
version = 1.17.0;
};
};
BD391AE7263C3F5600848049 /* XCRemoteSwiftPackageReference "LaunchAtLogin" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.1.0;
kind = exactVersion;
version = 5.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"object": {
"pins": [
{
"package": "KeyboardShortcuts",
"repositoryURL": "https://github.com/sindresorhus/KeyboardShortcuts",
"state": {
"branch": null,
"revision": "9bc72c441c713362a137ecbb4104920655a9aa5e",
"version": "1.4.0"
}
},
{
"package": "LaunchAtLogin",
"repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin",
"state": {
"branch": null,
"revision": "6b16bcdf7d45a9d76a768a5c4912dde925cf0e95",
"version": "4.1.0"
}
"pins" : [
{
"identity" : "keyboardshortcuts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/KeyboardShortcuts",
"state" : {
"revision" : "ac12762853126cf2e7ad63a6a58e1c9f58c6a0ee",
"version" : "1.17.0"
}
]
},
"version": 1
},
{
"identity" : "launchatlogin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/LaunchAtLogin",
"state" : {
"revision" : "7ad6331f9c38953eb1ce8737758e18f7607e984a",
"version" : "5.0.0"
}
}
],
"version" : 2
}
Binary file not shown.
27 changes: 21 additions & 6 deletions toggleMute/toggleMute/Bootstrap/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Author: Sascha Petrik

import Cocoa
import LaunchAtLogin
import KeyboardShortcuts

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
private lazy var preferences = Preferences()
private lazy var settingsController = SettingsController()
private lazy var mainController = MainController()
Expand All @@ -19,10 +20,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let imageUnmute = NSImage(named: NSImage.touchBarAudioInputTemplateName)
let imageMute = NSImage(named: NSImage.touchBarAudioInputMuteTemplateName)


func applicationDidFinishLaunching(_ aNotification: Notification) {

LaunchAtLogin.migrateIfNeeded()

refreshTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(runTimedCode), userInfo: nil, repeats: true)

if let button = self.statusItem.button {
button.image = imageUnmute
button.image = touchBarController.imageUnmute?.tint(color: .selectedMenuItemTextColor)
button.imageScaling = .scaleProportionallyDown
button.target = self
button.action = #selector(statusBarButtonClicked)
Expand All @@ -38,9 +44,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
defaults.set(false, forKey: "updateAvailable")
defaults.set(true, forKey: "firstStart")


let getlocalVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
let stringLocalVersion = getlocalVersion! as NSString
defaults.set(stringLocalVersion, forKey: "stringLocalVersion")
let localVersion = stringLocalVersion.doubleValue

let url = URL(string: "https://raw.githubusercontent.com/satrik/toggleMute/main/toggleMute/toggleMute.xcodeproj/project.pbxproj")!
Expand All @@ -54,14 +60,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let secondIndex = ";"
let stringVersion = getString.slice(from: firstIndex, to: secondIndex)
let githubVersion = Double(stringVersion!)!

if githubVersion > localVersion {
self.defaults.set(true, forKey: "updateAvailable")
}

}

task.resume()

}


@objc func runTimedCode(){

mainController.getCurrentVolume()
Expand All @@ -74,6 +84,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

}


@objc func statusBarButtonClicked(sender: NSStatusBarButton) {

let event = NSApp.currentEvent!
Expand All @@ -89,9 +100,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}


@objc private func showMainController() {


guard let button = statusItem.button else {
fatalError("Couldn't find status item button.")
}
Expand All @@ -114,10 +125,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {

}


func isKeyPresentInUserDefaults(key: String) -> Bool {

return UserDefaults.standard.object(forKey: key) != nil

}


func dialogOKCancel(question: String, text: String) -> Bool {

let alert = NSAlert()
Expand Down
Loading

0 comments on commit ed72ac0

Please # to comment.