Skip to content

Commit

Permalink
Added README
Browse files Browse the repository at this point in the history
  • Loading branch information
DWilliames committed Jan 12, 2021
1 parent 5fe28c0 commit a32359d
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 24 deletions.
Binary file added .DS_Store
Binary file not shown.
16 changes: 13 additions & 3 deletions Desk Controller.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
7D93E2A325AB244500F37364 /* EventMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = "<group>"; };
7DA946FC25AD32BB000B4816 /* deskcontroller.sdef */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = deskcontroller.sdef; sourceTree = "<group>"; };
7DA946FF25AD3462000B4816 /* MoveDeskCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoveDeskCommand.swift; sourceTree = "<group>"; };
7DA9470825AD8F9A000B4816 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -97,6 +98,7 @@
7D93E27B25AAB38B00F37364 = {
isa = PBXGroup;
children = (
7DA9470825AD8F9A000B4816 /* README.md */,
7D93E28625AAB38B00F37364 /* Desk Controller */,
7D93E28525AAB38B00F37364 /* Products */,
7D81874925AC13AF0076DC19 /* Frameworks */,
Expand All @@ -114,14 +116,13 @@
7D93E28625AAB38B00F37364 /* Desk Controller */ = {
isa = PBXGroup;
children = (
7DA946FC25AD32BB000B4816 /* deskcontroller.sdef */,
7DA9470625AD8EDA000B4816 /* AppleScript Commands */,
7D93E28725AAB38B00F37364 /* AppDelegate.swift */,
7DA946FF25AD3462000B4816 /* MoveDeskCommand.swift */,
7D93E28925AAB38B00F37364 /* ViewController.swift */,
7D81871F25ABE9FF0076DC19 /* BluetoothManager.swift */,
7D0361A725AC42770051FB71 /* Desk control */,
7D93E2A325AB244500F37364 /* EventMonitor.swift */,
7D93E29F25AB203800F37364 /* TouchButton.swift */,
7D0361A725AC42770051FB71 /* Desk control */,
7D81872225ABF1500076DC19 /* Extensions.swift */,
7D93E28B25AAB38D00F37364 /* Assets.xcassets */,
7D93E28D25AAB38D00F37364 /* Main.storyboard */,
Expand All @@ -132,6 +133,15 @@
path = "Desk Controller";
sourceTree = "<group>";
};
7DA9470625AD8EDA000B4816 /* AppleScript Commands */ = {
isa = PBXGroup;
children = (
7DA946FC25AD32BB000B4816 /* deskcontroller.sdef */,
7DA946FF25AD3462000B4816 /* MoveDeskCommand.swift */,
);
path = "AppleScript Commands";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "LaunchAtLogin",
"repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin",
"state": {
"branch": null,
"revision": "0f39982b9d6993eef253b81219d3c39ba1e680f3",
"version": "4.0.0"
}
}
]
},
"version": 1
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D93E28325AAB38B00F37364"
BuildableName = "Desk Controller.app"
BlueprintName = "Desk Controller"
ReferencedContainer = "container:Desk Controller.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 = "7D93E28325AAB38B00F37364"
BuildableName = "Desk Controller.app"
BlueprintName = "Desk Controller"
ReferencedContainer = "container:Desk Controller.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D93E28325AAB38B00F37364"
BuildableName = "Desk Controller.app"
BlueprintName = "Desk Controller"
ReferencedContainer = "container:Desk Controller.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "E339415D-E368-4208-B379-467B2E7D2686"
type = "1"
version = "2.0">
</Bucket>
18 changes: 8 additions & 10 deletions Desk Controller/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Preferences.shared.openAtLogin = true
Preferences.shared.isFirstLaunch = false
}

// Don't show the icon in the Dock
NSApp.setActivationPolicy(.accessory)

Expand All @@ -35,7 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusBarMenu.addItem(withTitle: "Preferences", action: #selector(showPreferences), keyEquivalent: "")
statusBarMenu.addItem(.separator())
statusBarMenu.addItem(withTitle: "Quit", action: #selector(quit), keyEquivalent: "")


// Set the status bar icon and action
if let button = statusBarItem.button {
Expand Down Expand Up @@ -69,7 +69,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
PreferencesWindowController.sharedInstance.deskController = viewController?.controller
popover.performClose(self)
}

@objc func moveToSit() {
viewController?.controller?.moveToPosition(.sit)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
menu.popUp(positioning: nil, at: CGPoint(x: -15, y: button.bounds.maxY + 6), in: button)
}


} else {
// Left clicked
togglePopover(sender)
Expand All @@ -124,9 +124,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
eventMonitor?.start()

// On popover showing; force a reconnection with the Table in case the connection is lost
if let viewController = popover.contentViewController as? ViewController {
viewController.reconnect()
}
viewController?.reconnect()
}

func closePopover(_ sender: AnyObject?) {
Expand All @@ -135,8 +133,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

public static func bringToFront(window: NSWindow) {
window.makeKeyAndOrderFront(nil)
NSApp.activate(ignoringOtherApps: true)
}
window.makeKeyAndOrderFront(nil)
NSApp.activate(ignoringOtherApps: true)
}

}
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions Desk Controller/Desk control/DeskController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ enum MovingDirection {
case up, down, none
}


class DeskController: NSObject {

var onCurrentMovingDirectionChange: (MovingDirection) -> Void = { _ in }
Expand All @@ -30,9 +29,6 @@ class DeskController: NSObject {
}

let desk: DeskPeripheral
// My preferences
// let preferences = PositionPreferencesManager.shared.currentPreferences
// let preferences = PositionPreferences(sit: 72, stand: 80)

let distanceOffset: Float = 0.5 // e.g if we're within this of the distance and it's currently moving then we can probably stop
let minDurationIncrements: TimeInterval = 0.5
Expand All @@ -43,8 +39,6 @@ class DeskController: NSObject {

static var shared: DeskController?

// var onPositionChange: (Float) -> Void = { _ in }

private var positionChangeCallbacks = [(Float) -> Void]()

init(desk: DeskPeripheral) {
Expand Down Expand Up @@ -113,7 +107,6 @@ class DeskController: NSObject {
}



var previousPosition: Float?

private func moveIfNeeded() {
Expand Down
6 changes: 2 additions & 4 deletions Desk Controller/Preferences/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ class Preferences {
private let isMetricKey = "isMetric"

private let hasLaunched = "hasLaunched"

// 72, 119

var standingPosition: Float {
get {
if let position = UserDefaults.standard.value(forKey: standingKey) {
return position as! Float
}
return 119//110 // Default standing position is
return 110 // Default standing position is
}

set {
Expand All @@ -46,7 +44,7 @@ class Preferences {
if let position = UserDefaults.standard.value(forKey: sittingKey) {
return position as! Float
}
return 73//70 // Default sitting position
return 70 // Default sitting position
}

set {
Expand Down
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Idasen Desk Controller – Mac app


This is a Mac Status Bar application for controlling your [IKEA IDÅSEN (Linak) Desk](https://www.ikea.com/au/en/p/idasen-desk-sit-stand-black-beige-s79280979/)

If you find this at least a little bit useful, why don't you help me out by:
* Starring this project
* Shout me a cup of coffe via [PayPal](https://paypal.me/dtw/5)
* Follow me on Twitter [@davidwilliames](https://twitter.com/davidwilliames)

---

![Animated example](/images/example.gif)

![Preferences example](/images/preferences_example.png)

---

## Why?

The best way I've found to get myself to use my sit/stand desk more; is to remove as much friction around moving it as possible.

The Linak 'Desk Control' mobile app let's you set favourite positions — but then you need to open the app, and press **and hold** the up/down arrow until it get's into position. Having to hold the button the whole time was just a bit annoying for me; and I found myself changing height positions less.

I found a couple of different solutions across Github; but there were no truly Native Mac apps... until now.

I'm already on my Mac when sitting/standing at my desk — so why can't I quickly control the desk from here; without needing to open Linak's Desk Control Mobile app or having to use physical controller?


## Features

* Easy access from the Mac Status Bar
* View current height
* Save sit/stand height positions
* Move up/down
* Move to sit/stand position without having to hold down the button
* Automatic launch on startup (configurable in preferences)
* Supports AppleScript to interact with it (e.g. via an [Alfred App](https://www.alfredapp.com) workflow)


![Animated example](/images/status_bar_example.png)
![App icon](/images/Icon.png)

## Getting started

* Download the 'Desk Controller' App, and move it to your 'Applications' folder
* Double-click to open it
* Now it will show up in your Status Bar

Other info:
* To access the preferences either right-click on the Status bar icon and click `Preferences` – or after clicking on the icon, click on the settings icon in the bottom right
* To quit the application entirely; right-click on the Status bar icon and click `Quit`


## Troublshooting

* Make sure no other phones / computers currently have one of the 'Desk Control' apps open and connected to your desk, if you do, simply quit that app, and this Desk Controller app should work
* Make sure your Idasen Desk still has the word "Desk" in the name of the device — e.g if you changed its name via Linak's Desk Control mobile app
* If it's still not finding your desk; try resetting your desk; to do this:
1. Lower your desk as low as it goes
2. Now once more hold down the physical controller to lower it even more, after a second or 2 it should jump down and up
3. Now press and hold the 'bluetooth' button on the front of the physical controller, for a few seconds – until the blue light starts blinking

---

## Interacting with AppleScript

If you want to interact with your Desk via AppleScript; you can talk directly through the 'Desk Controller' mac app.

This is great for setting up an [Alfred App](https://www.alfredapp.com) workflow

#### Commands:

`move "to-sit"`: Will move to the saved 'Sitting position'

`move "to-stand"`: Will move to the saved 'Standing position'

`move "up"`: Will move the desk up a tiny bit

`move "down"`: Will move the desk down a tiny bit


So you may have an AppleScript script that looks like this:
``` AppleScript
tell application "Desk Controller"
move "to-sit"
end tell
```

Binary file added images/.DS_Store
Binary file not shown.
Binary file added images/Icon.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 added images/example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/preferences_example.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 added images/status_bar_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a32359d

Please sign in to comment.