Skip to content

Commit

Permalink
Add a setting to control the function of F14 / F15 keys (MonitorContr…
Browse files Browse the repository at this point in the history
…ol#602)

Co-authored-by: koyama <[email protected]>
Co-authored-by: JoniVR <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2021
1 parent a1615b7 commit b493a42
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 28 deletions.
2 changes: 2 additions & 0 deletions MonitorControl/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self.statusItem.menu = self.statusMenu
self.checkPermissions()
CGDisplayRegisterReconfigurationCallback({ _, _, _ in app.displayReconfigured() }, nil)

MediaKeyTap.useAlternateBrightnessKeys = prefs.bool(forKey: Utils.PrefKeys.altBrightnessKeys.rawValue)
self.updateDisplays(firstrun: true)
}

Expand Down
2 changes: 1 addition & 1 deletion MonitorControl/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>3095</string>
<string>3103</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/Support/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class Utils: NSObject {
/// Change Brightness/Volume for all screens
case allScreens

/// Use F14 / F15 keys to control brightness
case altBrightnessKeys

/// Friendly name changed
case friendlyName

Expand Down
2 changes: 1 addition & 1 deletion MonitorControl/Support/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"Safe Mode Activated" = "Safe Mode Activated";

/* Shown in the alert dialog */
"Shift was pressed during launch. MonitorControl started in safe mode. Default preferences are reloaded, DDC read is blocked." = "Die Shift-Taste wurde beim Programmstart gehalten. MonitorControl wurde im Safe Mode gestartet. Die Standard-Einstellungen werden geladen, DDC lesen ist blockiert.";
"Shift was pressed during launch. MonitorControl started in safe mode. Default preferences are reloaded, DDC read is blocked." = "Shift was pressed during launch. MonitorControl started in safe mode. Default preferences are reloaded, DDC read is blocked.";

/* Shown in the alert dialog */
"Shortcuts not available" = "Kurzbefehle sind nicht verfügbar";
Expand Down
65 changes: 40 additions & 25 deletions MonitorControl/UI/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions MonitorControl/UI/de.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Helligkeit und Lautstärke für alle Bildschirme ändern";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/en.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Change Brightness and Volume for all screens";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/es-419.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Cambiar el brillo y volumen para todas las pantallas";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/fr.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Change Brightness and Volume for all screens";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/hu.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Fényerő/hangerő módosítása az összes képernyőn";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimális";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/it.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Cambia Luminosità e Volume di tutti i display";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimale";

Expand Down
5 changes: 4 additions & 1 deletion MonitorControl/UI/ja.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "すべての画面の画面輝度と音量を変更する";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "低頻度";

/* Class = "NSButtonCell"; title = "Reset Name"; ObjectID = "f9g-8s-gdd"; */
"f9g-8s-gdd.title" = "Reset Name";

/* Class = "NSButtonCell"; title = "Further lower brightness via software dimming"; ObjectID = "fhy-Er-0aI"; */
"fhy-Er-0aI.title" = "画面輝度変更後、コントラストを下げる";
"fhy-Er-0aI.title" = "ソフトウェアディミングを用いて輝度を通常以上に下げる";

/* Class = "NSMenuItem"; title = "None"; ObjectID = "FoA-yh-Yx3"; */
"FoA-yh-Yx3.title" = "設定しない";
Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/ko.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "모든 화면의 밝기와 볼륨 조절";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "최소";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/nl.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Verander Helderheid en Volume voor alle beeldschermen";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Gebruik F14 / F15 keys voor helderheid";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimaal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/pl.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Zmień Jasność i Głośność dla wszystkich wyświetlaczy";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimalny";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/ru.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Изменить яркость и громоксть на всех экранах";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Редко";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/tr.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Tüm ekranlar için Parlaklığı ve Sesi değiştir";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Minimal";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/uk.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "Change Brightness and Volume for all screens";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "Мінім.";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/zh-Hans.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "改变所有屏幕的亮度和音量";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "少量";

Expand Down
3 changes: 3 additions & 0 deletions MonitorControl/UI/zh-Hant-TW.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
/* Class = "NSButtonCell"; title = "Change Brightness and Volume for all screens"; ObjectID = "E6M-ih-S8Y"; */
"E6M-ih-S8Y.title" = "更改所有螢幕的亮度和音量";

/* Class = "NSButtonCell"; title = "Enable F14 / F15 keys for Brightness Control"; ObjectID = "E6M-ih-SZY"; */
"E6M-ih-SZY.title" = "Enable F14 / F15 keys for Brightness Control";

/* Class = "NSMenuItem"; title = "Minimal"; ObjectID = "Eq3-z9-yIo"; */
"Eq3-z9-yIo.title" = "少量";

Expand Down
17 changes: 17 additions & 0 deletions MonitorControl/View Controllers/MainPrefsViewController.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Cocoa
import MediaKeyTap
import os.log
import Preferences
import ServiceManagement
Expand Down Expand Up @@ -26,6 +27,7 @@ class MainPrefsViewController: NSViewController, PreferencePane {
@IBOutlet var fallbackSw: NSButton!
@IBOutlet var listenFor: NSPopUpButton!
@IBOutlet var allScreens: NSButton!
@IBOutlet var altBrightnessKeys: NSButton!
@IBOutlet var showAdvancedDisplays: NSButton!

override func viewDidLoad() {
Expand All @@ -51,6 +53,7 @@ class MainPrefsViewController: NSViewController, PreferencePane {
self.fallbackSw.state = self.prefs.bool(forKey: Utils.PrefKeys.fallbackSw.rawValue) ? .on : .off
self.listenFor.selectItem(at: self.prefs.integer(forKey: Utils.PrefKeys.listenFor.rawValue))
self.allScreens.state = self.prefs.bool(forKey: Utils.PrefKeys.allScreens.rawValue) ? .on : .off
self.altBrightnessKeys.state = self.prefs.bool(forKey: Utils.PrefKeys.altBrightnessKeys.rawValue) ? .on : .off
self.showAdvancedDisplays.state = self.prefs.bool(forKey: Utils.PrefKeys.showAdvancedDisplays.rawValue) ? .on : .off
}

Expand All @@ -68,6 +71,20 @@ class MainPrefsViewController: NSViewController, PreferencePane {
#endif
}

@IBAction func altBrightnessKeysTouched(_ sender: NSButton) {
switch sender.state {
case .on:
self.prefs.set(true, forKey: Utils.PrefKeys.altBrightnessKeys.rawValue)
case .off:
self.prefs.set(false, forKey: Utils.PrefKeys.altBrightnessKeys.rawValue)
default: break
}
MediaKeyTap.useAlternateBrightnessKeys = (sender.state == .on)
#if DEBUG
os_log("Toggle altBrightnessKeys state: %{public}@", type: .info, sender.state == .on ? "on" : "off")
#endif
}

@IBAction func startAtLoginClicked(_ sender: NSButton) {
switch sender.state {
case .on:
Expand Down

0 comments on commit b493a42

Please sign in to comment.