Skip to content

Commit d4309e6

Browse files
Yifei0727neo
andauthored
feat: support "only when external display show menu bar icon" option (#1817)
Co-authored-by: neo <[email protected]>
1 parent f62c7e6 commit d4309e6

File tree

22 files changed

+72
-1
lines changed

22 files changed

+72
-1
lines changed

MonitorControl/Enums/PrefKey.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ enum MenuIcon: Int {
191191
case show = 0
192192
case sliderOnly = 1
193193
case hide = 2
194+
case externalOnly = 3
194195
}
195196

196197
enum MenuItemStyle: Int {

MonitorControl/Support/MenuHandler.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ class MenuHandler: NSMenu, NSMenuDelegate {
3333
if !dontClose {
3434
self.cancelTrackingWithoutAnimation()
3535
}
36-
app.updateStatusItemVisibility(prefs.integer(forKey: PrefKey.menuIcon.rawValue) == MenuIcon.show.rawValue ? true : false)
36+
let menuIconPref = prefs.integer(forKey: PrefKey.menuIcon.rawValue)
37+
var showIcon = false
38+
if menuIconPref == MenuIcon.show.rawValue {
39+
showIcon = true
40+
} else if menuIconPref == MenuIcon.externalOnly.rawValue {
41+
let externalDisplays = DisplayManager.shared.displays.filter {
42+
CGDisplayIsBuiltin($0.identifier) == 0
43+
}
44+
if externalDisplays.count > 0 {
45+
showIcon = true
46+
}
47+
}
48+
app.updateStatusItemVisibility(showIcon)
3749
self.clearMenu()
3850
let currentDisplay = DisplayManager.shared.getCurrentDisplay()
3951
var displays: [Display] = []

MonitorControl/UI/Base.lproj/Main.storyboard

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
<items>
369369
<menuItem title="Always show in the menu bar" state="on" id="MM0-Lf-VgF"/>
370370
<menuItem title="Only if at least one slider is present" tag="1" id="xLa-PN-rsq"/>
371+
+ <menuItem title="Only when external display is present" tag="3" id="Tb1-6s-qOo"/>
371372
<menuItem title="Always hide" tag="2" id="6mo-7S-oOO"/>
372373
</items>
373374
</menu>

MonitorControl/UI/cs.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Jen pokud je k dispozici alespoň jeden posuvník";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Pouze když je externí displej přítomen";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Standardní i vlastní zkratky";
381384

MonitorControl/UI/de.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Nur wenn mindestens ein Regler vorhanden ist";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Nur wenn externer Bildschirm vorhanden ist";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Sowohl Standard- als auch benutzerdefinierte Tastenkombinationen";
381384

MonitorControl/UI/en.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Only if at least one slider is present";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Only when external display is present";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Both standard and custom shortcuts";
381384

MonitorControl/UI/es.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Sólo si hay presente al menos un slider";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Solo cuando la pantalla externa está presente";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Ambos, atajos estándar y personalizados";
381384

MonitorControl/UI/fr.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Uniquement si au moins un curseur est présent";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Seulement lorsqu'un écran externe est présent";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Raccourcis standard et personnalisés";
381384

MonitorControl/UI/hi.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@
428428
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
429429
"xLa-PN-rsq.title" = "केवल तभी जब कम से कम एक स्लाइडर मौजूद हो";
430430

431+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
432+
"Tb1-6s-qOo.title" = "केवल तभी जब बाहरी डिस्प्ले मौजूद हो";
433+
431434
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
432435
"xQJ-aJ-VhH.title" = "मानक और कस्टम दोनों शॉर्टकट";
433436

MonitorControl/UI/hu.lproj/Main.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@
376376
/* Class = "NSMenuItem"; title = "Only if at least one slider is present"; ObjectID = "xLa-PN-rsq"; */
377377
"xLa-PN-rsq.title" = "Csak ha legalább egy vezérlő megjelenik";
378378

379+
/* Class = "NSMenuItem"; title = "Only when external display is present"; ObjectID = "Tb1-6s-qOo"; */
380+
"Tb1-6s-qOo.title" = "Csak ha külső kijelző van jelen";
381+
379382
/* Class = "NSMenuItem"; title = "Both standard and custom shortcuts"; ObjectID = "xQJ-aJ-VhH"; */
380383
"xQJ-aJ-VhH.title" = "Hagyományos és egyedi billentyűkombinációk";
381384

0 commit comments

Comments
 (0)