Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create devcontainer.json #132

Open
wants to merge 38 commits into
base: release/monterey
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5c4db94
1.10.3
ts1 Aug 29, 2021
3fef53d
Merge branch 'release/monterey'
ts1 Sep 12, 2021
7fc5bab
1.11
ts1 Sep 12, 2021
80c5941
Update Apple device names from Device Support Update
ts1 Sep 30, 2021
25ea94d
Add files via upload
Dec 7, 2021
7782840
Support for sleep display on lock (WIP)
ts1 Dec 12, 2021
07ff0d5
Add localizations into project
ts1 Dec 12, 2021
14fb768
Merge branch 'cyberclaus-master'
ts1 Dec 12, 2021
43243a9
Turkish language added
alonewolfx2 Dec 23, 2021
7867e4d
Merge pull request #70 from alonewolfx2/master
ts1 Dec 24, 2021
3923fbc
add 'wake without unlocking' functionality
wxwern Jan 5, 2022
29a88ec
Merge branch 'wernjie-master'
ts1 Jan 8, 2022
63ebe34
Fix Japanese
ts1 Jan 8, 2022
be07dc6
Add files via upload
Jan 6, 2022
82faf73
Don't run "intruded" script if unlock is disabled
ts1 Jan 8, 2022
e7876bb
New year
ts1 Jan 8, 2022
1584a59
Merge branch 'feature/sleep-display'
ts1 Jan 8, 2022
be307a5
Add display sleep option
ts1 Jan 8, 2022
736b5bf
Add localizations for sleep display
ts1 Jan 8, 2022
eccc42b
Fix false manual unlock detection
ts1 Jan 9, 2022
a7e847f
Tweak lock delay values
ts1 Jan 10, 2022
9652e6f
Merge branch 'feature/display-sleep-localizations'
ts1 Jan 10, 2022
c40572c
Squashed commit of the following:
ts1 Jan 16, 2022
6edb826
Update READMEs
ts1 Jan 16, 2022
8c96cf0
1.12
ts1 Jan 16, 2022
487e38d
Update READMEs
ts1 Jan 16, 2022
d46c619
Fixed that scanning stops when the system sleeps and wakes up on Mont…
ts1 Jan 22, 2022
d139f23
Added to README on how to reset Bluetooth on Monterey
ts1 Jan 22, 2022
eda9acd
1.12.1
ts1 Jan 22, 2022
006fd72
Fixed all of the "google translate" errors
tokfrans03 Jun 13, 2022
a8edb92
Merge pull request #83 from tokfrans03/patch-1
ts1 Jun 14, 2022
463f46d
Update README.md
ts1 Jan 28, 2024
33bbe3e
Use notary tool
ts1 Mar 3, 2024
c33a132
Run intruded event if wake without unlock
ts1 Mar 3, 2024
9bce666
Fix README
ts1 Mar 3, 2024
28e96a9
Update FUNDING.yml
ts1 Mar 12, 2024
2eeb35d
Update README.md
ts1 Mar 12, 2024
cf49e25
Create devcontainer.json
TheHolyMecca Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
}
}
{
"name": "my-project-devcontainer",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", // Any generic, debian-based image.
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.18"
},
"ghcr.io/devcontainers/features/docker-in-docker:1": {
"version": "latest",
"moby": true
}
}
}
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ["https://www.buymeacoffee.com/tsone", "https://paypal.me/takeshisone"]
custom: ["https://www.buymeacoffee.com/tsone"]
25 changes: 25 additions & 0 deletions BLEUnlock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
/* Begin PBXFileReference section */
3D2CF85A255102B300157996 /* MediaRemote.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaRemote.framework; path = ../../../../System/Library/PrivateFrameworks/MediaRemote.framework; sourceTree = "<group>"; };
3D2FCF07226C99CB007A06E7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
3D43D0112765FCCB00D15991 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/AboutBox.strings; sourceTree = "<group>"; };
3D43D0122765FCCB00D15991 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
3D43D0132765FCFD00D15991 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/AboutBox.strings; sourceTree = "<group>"; };
3D43D0142765FCFD00D15991 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/Localizable.strings; sourceTree = "<group>"; };
3D43D0152765FD1600D15991 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/AboutBox.strings; sourceTree = "<group>"; };
3D43D0162765FD1600D15991 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
3D43D0172765FD2800D15991 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/AboutBox.strings; sourceTree = "<group>"; };
3D43D0182765FD2800D15991 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
3D4EE40F2279E55A00AF9E93 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3D4EE4102279E55A00AF9E93 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3D4EE4122279E56900AF9E93 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -69,6 +77,8 @@
3DD4B668226C1E3700451B7B /* login.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = login.framework; path = ../../../../System/Library/PrivateFrameworks/login.framework; sourceTree = "<group>"; };
B1EFF91422E010F50010DB0A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/AboutBox.strings"; sourceTree = "<group>"; };
B1EFF91622E010F50010DB0A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
F749D28C277515C600C78C28 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/AboutBox.strings; sourceTree = "<group>"; };
F749D28D277515C600C78C28 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -242,6 +252,11 @@
Base,
ja,
"zh-Hans",
de,
da,
nb,
sv,
tr,
);
mainGroup = 3DD4B647226C1C3200451B7B;
productRefGroup = 3DD4B651226C1C3200451B7B /* Products */;
Expand Down Expand Up @@ -329,6 +344,11 @@
3D600A36226CC1A40068FB7B /* Base */,
3D600A38226CC1AA0068FB7B /* ja */,
B1EFF91622E010F50010DB0A /* zh-Hans */,
3D43D0122765FCCB00D15991 /* de */,
3D43D0142765FCFD00D15991 /* da */,
3D43D0162765FD1600D15991 /* nb */,
3D43D0182765FD2800D15991 /* sv */,
F749D28D277515C600C78C28 /* tr */,
);
name = Localizable.strings;
sourceTree = "<group>";
Expand All @@ -339,6 +359,11 @@
3D953798227853E20017D8B9 /* Base */,
3D95379B227853EC0017D8B9 /* ja */,
B1EFF91422E010F50010DB0A /* zh-Hans */,
3D43D0112765FCCB00D15991 /* de */,
3D43D0132765FCFD00D15991 /* da */,
3D43D0152765FD1600D15991 /* nb */,
3D43D0172765FD2800D15991 /* sv */,
F749D28C277515C600C78C28 /* tr */,
);
name = AboutBox.xib;
sourceTree = "<group>";
Expand Down
78 changes: 78 additions & 0 deletions BLEUnlock.xcodeproj/xcshareddata/xcschemes/BLEUnlock.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DD4B64F226C1C3200451B7B"
BuildableName = "BLEUnlock.app"
BlueprintName = "BLEUnlock"
ReferencedContainer = "container:BLEUnlock.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DD4B64F226C1C3200451B7B"
BuildableName = "BLEUnlock.app"
BlueprintName = "BLEUnlock"
ReferencedContainer = "container:BLEUnlock.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DD4B64F226C1C3200451B7B"
BuildableName = "BLEUnlock.app"
BlueprintName = "BLEUnlock"
ReferencedContainer = "container:BLEUnlock.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
87 changes: 60 additions & 27 deletions BLEUnlock/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
var inScreensaver = false
var lastRSSI: Int? = nil

override init() {
// Hide dock icon.
// This is required because we can't have LSUIElement set to true in Info.plist,
// otherwise CBCentralManager.scanForPeripherals won't work.
NSApp.setActivationPolicy(.accessory)
}

func menuWillOpen(_ menu: NSMenu) {
if menu == deviceMenu {
ble.startScanning()
Expand Down Expand Up @@ -209,12 +202,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
}
}

func lockOrSaveScreen() -> Bool {
func lockOrSaveScreen() {
if prefs.bool(forKey: "screensaver") {
NSWorkspace.shared.launchApplication("ScreenSaverEngine")
return true // Really!?
} else {
return lockScreen()
if SACLockScreenImmediate() != 0 {
print("Failed to lock screen")
}
if prefs.bool(forKey: "sleepDisplay") {
print("sleep display")
sleepDisplay()
}
}
}

Expand All @@ -238,12 +236,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
} else {
if (!isScreenLocked() && ble.lockRSSI != ble.LOCK_DISABLED) {
pauseNowPlaying()
if lockOrSaveScreen() {
notifyUser(reason)
runScript(reason)
} else {
print("Failed to lock")
}
lockOrSaveScreen()
notifyUser(reason)
runScript(reason)
}
manualLock = false
}
Expand Down Expand Up @@ -297,21 +292,23 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
CGEvent(keyboardEventSource: src, virtualKey: 0x35, keyDown: false)?.post(tap: .cghidEventTap)
}

guard !self.prefs.bool(forKey: "wakeWithoutUnlocking") else { return }

Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: { _ in
guard self.isScreenLocked() else { return }
guard let password = self.fetchPassword(warn: true) else { return }

print("Entering password")
self.unlockedAt = Date().timeIntervalSince1970
self.fakeKeyStrokes(password)
self.playNowPlaying()
self.runScript("unlocked")
self.unlockedAt = Date().timeIntervalSince1970
})
}

@objc func onDisplayWake() {
print("display wake")
unlockedAt = Date().timeIntervalSince1970
//unlockedAt = Date().timeIntervalSince1970
displaySleep = false
wakeTimer?.invalidate()
wakeTimer = nil
Expand All @@ -327,6 +324,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
print("system wake")
Timer.scheduledTimer(withTimeInterval: 1, repeats: false, block: { _ in
print("delayed system wake job")
NSApp.setActivationPolicy(.accessory) // Hide Dock icon again
self.systemSleep = false
self.tryUnlockScreen()
})
Expand All @@ -335,13 +333,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
@objc func onSystemSleep() {
print("system sleep")
systemSleep = true
// Set activation policy to regular, so the CBCentralManager can scan for peripherals
// when the Bluetooth will become on again.
// This enables Dock icon but the screen is off anyway.
NSApp.setActivationPolicy(.regular)
}

@objc func onUnlock() {
if Date().timeIntervalSince1970 >= unlockedAt + 10 {
runScript("intruded")
self.playNowPlaying()
}
Timer.scheduledTimer(withTimeInterval: 2, repeats: false, block: { _ in
print("onUnlock")
if Date().timeIntervalSince1970 >= self.unlockedAt + 10 {
if self.ble.unlockRSSI != self.ble.UNLOCK_DISABLED {
self.runScript("intruded")
}
self.playNowPlaying()
}
})
manualLock = false
Timer.scheduledTimer(withTimeInterval: 2, repeats: false, block: { _ in
checkUpdate()
Expand Down Expand Up @@ -525,6 +532,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
prefs.set(value, forKey: "screensaver")
menuItem.state = value ? .on : .off
}

@objc func toggleSleepDisplay(_ menuItem: NSMenuItem) {
let value = !prefs.bool(forKey: "sleepDisplay")
prefs.set(value, forKey: "sleepDisplay")
menuItem.state = value ? .on : .off
}

@objc func togglePassiveMode(_ menuItem: NSMenuItem) {
let passiveMode = !prefs.bool(forKey: "passiveMode")
Expand All @@ -533,11 +546,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
ble.setPassiveMode(passiveMode)
}

@objc func toggleWakeWithoutUnlocking(_ menuItem: NSMenuItem) {
let wakeWithoutUnlocking = !prefs.bool(forKey: "wakeWithoutUnlocking")
prefs.set(wakeWithoutUnlocking, forKey: "wakeWithoutUnlocking")
menuItem.state = wakeWithoutUnlocking ? .on : .off
}

@objc func lockNow() {
guard !isScreenLocked() else { return }
manualLock = true
pauseNowPlaying()
_ = lockOrSaveScreen()
lockOrSaveScreen()
}

@objc func showAboutBox() {
Expand Down Expand Up @@ -581,10 +600,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa

let lockDelayItem = mainMenu.addItem(withTitle: t("lock_delay"), action: nil, keyEquivalent: "")
lockDelayItem.submenu = lockDelayMenu
lockDelayMenu.addItem(withTitle: "0 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 0
lockDelayMenu.addItem(withTitle: "2 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 2
lockDelayMenu.addItem(withTitle: "5 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 5
lockDelayMenu.addItem(withTitle: "10 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 10
lockDelayMenu.addItem(withTitle: "20 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 20
lockDelayMenu.addItem(withTitle: "15 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 15
lockDelayMenu.addItem(withTitle: "30 " + t("seconds"), action: #selector(setLockDelay), keyEquivalent: "").tag = 30
lockDelayMenu.addItem(withTitle: "1 " + t("minute"), action: #selector(setLockDelay), keyEquivalent: "").tag = 60
lockDelayMenu.addItem(withTitle: "2 " + t("minutes"), action: #selector(setLockDelay), keyEquivalent: "").tag = 120
Expand All @@ -605,6 +623,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
item.state = .on
}

item = mainMenu.addItem(withTitle: t("wake_without_unlocking"), action: #selector(toggleWakeWithoutUnlocking), keyEquivalent: "")
if prefs.bool(forKey: "wakeWithoutUnlocking") {
item.state = .on
}

item = mainMenu.addItem(withTitle: t("pause_now_playing"), action: #selector(togglePauseNowPlaying), keyEquivalent: "")
if prefs.bool(forKey: "pauseItunes") {
item.state = .on
Expand All @@ -614,6 +637,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
if prefs.bool(forKey: "screensaver") {
item.state = .on
}

item = mainMenu.addItem(withTitle: t("sleep_display"), action: #selector(toggleSleepDisplay), keyEquivalent: "")
if prefs.bool(forKey: "sleepDisplay") {
item.state = .on
}

mainMenu.addItem(withTitle: t("set_password"), action: #selector(askPassword), keyEquivalent: "")

Expand Down Expand Up @@ -691,11 +719,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSMenuItemVa
dnc.addObserver(self, selector: #selector(onScreensaverStart), name: NSNotification.Name(rawValue: "com.apple.screensaver.didstart"), object: nil)
dnc.addObserver(self, selector: #selector(onScreensaverStop), name: NSNotification.Name(rawValue: "com.apple.screensaver.didstop"), object: nil)

if ble.unlockRSSI != ble.UNLOCK_DISABLED && fetchPassword() == nil {
if ble.unlockRSSI != ble.UNLOCK_DISABLED && !prefs.bool(forKey: "wakeWithoutUnlocking") && fetchPassword() == nil {
askPassword()
}
checkAccessibility()
checkUpdate()

// Hide dock icon.
// This is required because we can't have LSUIElement set to true in Info.plist,
// otherwise CBCentralManager.scanForPeripherals won't work.
NSApp.setActivationPolicy(.accessory)
}

func applicationWillTerminate(_ aNotification: Notification) {
Expand Down
Loading