Skip to content

Commit

Permalink
Merge pull request #3 from sartbimpson/master
Browse files Browse the repository at this point in the history
Update Hammerspoon base, fix builds, remove updating functionality
  • Loading branch information
kwvg committed May 4, 2020
2 parents 47d455c + 4ad14f7 commit 60c5d3b
Show file tree
Hide file tree
Showing 52 changed files with 2,011 additions and 214 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on: [push, pull_request]
jobs:
build:
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_11.2.app/Contents/Developer
steps:
- name: Cloning Git repository
uses: actions/checkout@v1
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: ReleaseGithubAction

on: [push, pull_request]
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build:
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_11.2.app/Contents/Developer
steps:
- name: Cloning Git repository
uses: actions/checkout@v1
Expand Down
52 changes: 46 additions & 6 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
--
-- Globals:
-- These globals can be set and accessed:
--
globals = {
-- Used by Hammerspoon:
"hs", "rawrequire", "ls", "spoon",
-- Used by Hammerspoon Tests:
"success", "assertIsEqual",
"rawrequire",
}

--
-- These globals can only be accessed:
--
read_globals = {
"hs",
"ls",
"spoon",
}

--
-- Hammerspoon Tests:
--
files["**/test_*.lua"] = {
read_globals = {
"assertFalse",
"assertGreaterThan",
"assertGreaterThanOrEqualTo",
"assertIsAlmostEqual",
"assertIsBoolean",
"assertIsEqual",
"assertIsFunction",
"assertIsNil",
"assertIsNotNil",
"assertIsNumber",
"assertIsString",
"assertIsTable",
"assertIsType",
"assertIsUserdata",
"assertIsUserdataOfType",
"assertLessThan",
"assertLessThanOrEqualTo",
"assertListsEqual",
"assertTableNotEmpty",
"assertTablesEqual",
"assertTrue",
"failure",
"success",
},
ignore = {
"111" -- Setting an undefined global variable
}
}

--
-- Warnings to ignore:
--
ignore = {
"631" -- Line is too long.
}
}
37 changes: 37 additions & 0 deletions Hammerspoon Tests/HSmath.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// HSmath.m
// Hammerspoon Tests
//
// Created by Chris Jones on 23/12/2019.
// Copyright © 2019 Hammerspoon. All rights reserved.
//

#import "HSTestCase.h"

@interface HSmath : HSTestCase

@end

@implementation HSmath

- (void)setUp {
[super setUpWithRequire:@"test_math"];
// Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}

// FIXME: These tests don't really test anything other than the functions exist and don't throw errors

- (void)testRandomFloat {
RUN_LUA_TEST()
}

- (void)testRandomFromRange {
RUN_LUA_TEST()
}

@end
4 changes: 4 additions & 0 deletions Hammerspoon Tests/HSscreen.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ - (void)testSetMode {
RUN_LUA_TEST()
}

- (void)testSetOrigin {
RUN_LUA_TEST()
}

- (void)testFrames {
RUN_LUA_TEST()
}
Expand Down
400 changes: 391 additions & 9 deletions Hammerspoon.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>
12 changes: 7 additions & 5 deletions Hammerspoon/Hammerspoon-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.9.76</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5101</string>
<string>5129</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>a9a43ddffec0ebfb007388756dfd662a9c153188</string>
<string>ffffffffffffffffffffffffffffffffffffffff</string>
<key>Kits</key>
<array>
<dict>
Expand All @@ -40,6 +40,8 @@
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
<true/>
<key>NSAppSleepDisabled</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down Expand Up @@ -101,9 +103,9 @@
<key>OSAScriptingDefinition</key>
<string>Hammerspoon.sdef</string>
<key>SUEnableAutomaticChecks</key>
<true/>
<false/>
<key>SUFeedURL</key>
<string>https://raw.githubusercontent.com/Hammerspoon/hammerspoon/master/appcast.xml</string>
<string></string>
<key>SUScheduledCheckInterval</key>
<integer>21600</integer>
</dict>
Expand Down
18 changes: 9 additions & 9 deletions Hammerspoon/MJAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)fileAnd

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
BOOL isTesting = NO;

// User is holding down Command (0x37) & Option (0x3A) keys:
if (CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,0x3A) && CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState,0x37)) {

NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Continue"];
[alert addButtonWithTitle:@"Delete Preferences"];
[alert setMessageText:@"Do you want to delete the preferences?"];
[alert setInformativeText:@"Deleting the preferences will reset all Hammerspoon settings (including everything that uses hs.settings) to their defaults."];
[alert setAlertStyle:NSAlertStyleWarning];

if ([alert runModal] == NSAlertSecondButtonReturn) {

// Reset Preferences:
NSDictionary * allObjects;
allObjects = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
Expand All @@ -142,10 +142,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSUserDefaults standardUserDefaults] removeObjectForKey: key];
}
[[NSUserDefaults standardUserDefaults] synchronize];

}
}

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityChanged:) name:@"com.apple.accessibility.api" object:nil];

// Remove our early event manager handler so hs.urlevent can register for it later, if the user has it configured to
Expand Down Expand Up @@ -247,8 +247,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[MJConsoleWindowController singleton] setup];
MJLuaCreate();

if (!MJAccessibilityIsEnabled())
[[MJPreferencesWindowController singleton] showWindow: nil];
//if (!MJAccessibilityIsEnabled())
// [[MJPreferencesWindowController singleton] showWindow: nil];
}

// Dragging & Dropping of Text to Dock Item
Expand Down Expand Up @@ -280,7 +280,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
- (void) registerDefaultDefaults {
[[NSUserDefaults standardUserDefaults]
registerDefaults: @{@"NSApplicationCrashOnExceptions": @YES,
MJShowDockIconKey: @YES,
MJShowDockIconKey: @NO,
MJShowMenuIconKey: @YES,
HSAutoLoadExtensions: @YES,
HSUploadCrashDataKey: @YES,
Expand Down
13 changes: 11 additions & 2 deletions Hammerspoon/MJDockIcon.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ void MJDockIconSetVisible(BOOL visible) {
}

static void reflect_defaults(void) {
NSApplication* app = [NSApplication sharedApplication]; // NSApp is typed to 'id'; lame
NSApplication* app = [NSApplication sharedApplication];
NSApplicationActivationPolicy currentPolicy = app.activationPolicy;
NSApplicationActivationPolicy targetPolicy = MJDockIconVisible() ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory;

if (currentPolicy == targetPolicy) {
// No need to do anything, we already have the policy we want
return;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSDisableScreenUpdates();
#pragma clang diagnostic pop
[app setActivationPolicy: MJDockIconVisible() ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory];

[app setActivationPolicy:targetPolicy];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[app unhide: nil];
[app activateIgnoringOtherApps:YES];
Expand Down
10 changes: 5 additions & 5 deletions Hammerspoon/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<action selector="showAboutPanel:" target="Voe-Tx-rLC" id="bG4-ba-EWj"/>
</connections>
</menuItem>
<menuItem title="Check for Updates..." id="BOF-NM-1cW">
<!-- <menuItem title="Check for Updates..." id="BOF-NM-1cW">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="9hz-Cm-Er1" id="sY1-SF-eDC"/>
</connections>
</menuItem>
</menuItem> -->
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="9Kc-1f-Fv2">
<connections>
Expand Down Expand Up @@ -406,12 +406,12 @@
<action selector="showAboutPanel:" target="Voe-Tx-rLC" id="Vu4-C4-kcK"/>
</connections>
</menuItem>
<menuItem title="Check for Updates..." id="zC2-p9-aqe">
<!-- <menuItem title="Check for Updates..." id="zC2-p9-aqe">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="9hz-Cm-Er1" id="ffQ-zR-1tt"/>
</connections>
</menuItem>
</menuItem> -->
<menuItem isSeparatorItem="YES" id="tOT-wg-m6d"/>
<menuItem title="Quit Hammerspoon" id="MPd-JN-QB1">
<modifierMask key="keyEquivalentModifierMask"/>
Expand All @@ -421,7 +421,7 @@
</menuItem>
</items>
</menu>
<customObject id="9hz-Cm-Er1" customClass="SUUpdater"/>
<!-- <customObject id="9hz-Cm-Er1" customClass="SUUpdater"/> -->
<userDefaultsController representsSharedInstance="YES" id="b8h-DN-29z"/>
</objects>
</document>
30 changes: 15 additions & 15 deletions Hammerspoon/PreferencesWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<outlet property="keepConsoleOnTopCheckbox" destination="pYS-Wj-7iw" id="D7c-7r-gAe"/>
<outlet property="openAtLoginCheckbox" destination="e5P-fQ-lSS" id="ug0-D4-eSm"/>
<outlet property="showDockIconCheckbox" destination="LCE-lg-IdY" id="8xH-gB-Wng"/>
<outlet property="showMenuIconCheckbox" destination="onk-bV-cOj" id="OuW-dV-96B"/>
<!-- <outlet property="showMenuIconCheckbox" destination="onk-bV-cOj" id="OuW-dV-96B"/>
<outlet property="updatesCheckbox" destination="8hE-jn-yvO" id="CWE-jl-bYi"/>
<outlet property="uploadCrashDataCheckbox" destination="gOt-KN-83u" id="MPR-aF-ZbI"/>
<outlet property="uploadCrashDataCheckbox" destination="gOt-KN-83u" id="MPR-aF-ZbI"/> -->
<outlet property="window" destination="1ae-mv-r5b" id="d2x-lo-e3M"/>
</connections>
</customObject>
Expand Down Expand Up @@ -49,7 +49,7 @@
<action selector="toggleOpensAtLogin:" target="-2" id="3mA-c3-HVf"/>
</connections>
</button>
<button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gOt-KN-83u">
<!-- <button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="gOt-KN-83u">
<rect key="frame" x="106" y="105" width="228" height="18"/>
<buttonCell key="cell" type="check" title="Send crash data (requires restart)" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="YwH-Pc-MwX">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -65,7 +65,7 @@
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</button> -->
<button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LCE-lg-IdY">
<rect key="frame" x="106" y="168" width="118" height="18"/>
<buttonCell key="cell" type="check" title="Show dock icon" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="1Ay-Q1-93j">
Expand All @@ -76,7 +76,7 @@
<action selector="toggleShowDockIcon:" target="-2" id="UvC-Pk-hFl"/>
</connections>
</button>
<button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="onk-bV-cOj">
<!-- <button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="onk-bV-cOj">
<rect key="frame" x="106" y="148" width="122" height="18"/>
<buttonCell key="cell" type="check" title="Show menu icon" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="uNE-4I-dRd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -85,7 +85,7 @@
<connections>
<action selector="toggleMenuDockIcon:" target="-2" id="Y4S-Ys-VCZ"/>
</connections>
</button>
</button> -->
<button translatesAutoresizingMaskIntoConstraints="NO" id="pYS-Wj-7iw">
<rect key="frame" x="106" y="125" width="198" height="21"/>
<buttonCell key="cell" type="check" title="Keep Console window on top" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="OSm-zw-Lk8">
Expand Down Expand Up @@ -159,14 +159,14 @@
</button>
</subviews>
<constraints>
<constraint firstItem="8hE-jn-yvO" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="1gi-gY-wwp"/>
<!-- <constraint firstItem="8hE-jn-yvO" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="1gi-gY-wwp"/> -->
<constraint firstAttribute="bottom" secondItem="Brc-yV-QuI" secondAttribute="bottom" constant="20" symbolic="YES" id="4Ia-pq-hb4"/>
<constraint firstItem="Brc-yV-QuI" firstAttribute="leading" secondItem="fRb-9A-PSe" secondAttribute="leading" id="4R4-cj-OZh"/>
<constraint firstItem="onk-bV-cOj" firstAttribute="top" secondItem="LCE-lg-IdY" secondAttribute="bottom" constant="6" symbolic="YES" id="7cJ-UV-Ix2"/>
<constraint firstItem="8hE-jn-yvO" firstAttribute="top" secondItem="e5P-fQ-lSS" secondAttribute="bottom" constant="6" symbolic="YES" id="Bgv-Vu-wV9"/>
<constraint firstItem="onk-bV-cOj" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="Fee-Th-1Kw"/>
<constraint firstItem="gOt-KN-83u" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="GLO-zb-nek"/>
<constraint firstItem="Ljs-s0-qtL" firstAttribute="top" secondItem="gOt-KN-83u" secondAttribute="bottom" constant="8" symbolic="YES" id="KjY-cL-UmE"/>
<!-- <constraint firstItem="onk-bV-cOj" firstAttribute="top" secondItem="LCE-lg-IdY" secondAttribute="bottom" constant="6" symbolic="YES" id="7cJ-UV-Ix2"/> -->
<!-- <constraint firstItem="8hE-jn-yvO" firstAttribute="top" secondItem="e5P-fQ-lSS" secondAttribute="bottom" constant="6" symbolic="YES" id="Bgv-Vu-wV9"/> -->
<!-- <constraint firstItem="onk-bV-cOj" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="Fee-Th-1Kw"/> -->
<!-- <constraint firstItem="gOt-KN-83u" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="GLO-zb-nek"/> -->
<!-- <constraint firstItem="Ljs-s0-qtL" firstAttribute="top" secondItem="gOt-KN-83u" secondAttribute="bottom" constant="8" symbolic="YES" id="KjY-cL-UmE"/> -->
<constraint firstItem="pYS-Wj-7iw" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="LWl-EC-tRB"/>
<constraint firstItem="fRb-9A-PSe" firstAttribute="centerY" secondItem="Ljs-s0-qtL" secondAttribute="centerY" id="NAP-P3-3fA"/>
<constraint firstItem="Ljs-s0-qtL" firstAttribute="leading" secondItem="eNw-hu-Cry" secondAttribute="leading" constant="20" symbolic="YES" id="NZc-r0-DHJ"/>
Expand All @@ -175,12 +175,12 @@
<constraint firstItem="4ho-hR-nJI" firstAttribute="leading" secondItem="fRb-9A-PSe" secondAttribute="leading" id="bJX-Rt-08s"/>
<constraint firstItem="fzK-vc-sjF" firstAttribute="leading" secondItem="4ho-hR-nJI" secondAttribute="trailing" constant="8" symbolic="YES" id="bso-mQ-uLc"/>
<constraint firstItem="4ho-hR-nJI" firstAttribute="top" secondItem="fRb-9A-PSe" secondAttribute="bottom" constant="8" symbolic="YES" id="cIB-L9-Qd6"/>
<constraint firstItem="LCE-lg-IdY" firstAttribute="top" secondItem="8hE-jn-yvO" secondAttribute="bottom" constant="6" symbolic="YES" id="cm2-Kd-Fv1"/>
<constraint firstItem="pYS-Wj-7iw" firstAttribute="top" secondItem="onk-bV-cOj" secondAttribute="bottom" constant="6" symbolic="YES" id="drt-sI-apm"/>
<!-- <constraint firstItem="LCE-lg-IdY" firstAttribute="top" secondItem="8hE-jn-yvO" secondAttribute="bottom" constant="6" symbolic="YES" id="cm2-Kd-Fv1"/> -->
<!-- <constraint firstItem="pYS-Wj-7iw" firstAttribute="top" secondItem="onk-bV-cOj" secondAttribute="bottom" constant="6" symbolic="YES" id="drt-sI-apm"/> -->
<constraint firstItem="Brc-yV-QuI" firstAttribute="top" secondItem="4ho-hR-nJI" secondAttribute="bottom" constant="12" symbolic="YES" id="exn-c9-kQ4"/>
<constraint firstItem="e5P-fQ-lSS" firstAttribute="leading" secondItem="VQb-h7-4Va" secondAttribute="trailing" constant="8" symbolic="YES" id="f62-5x-ln4"/>
<constraint firstAttribute="trailing" secondItem="fRb-9A-PSe" secondAttribute="trailing" constant="20" symbolic="YES" id="fXh-3G-uDy"/>
<constraint firstItem="gOt-KN-83u" firstAttribute="top" secondItem="pYS-Wj-7iw" secondAttribute="bottom" constant="6" symbolic="YES" id="lNL-90-rs8"/>
<!-- <constraint firstItem="gOt-KN-83u" firstAttribute="top" secondItem="pYS-Wj-7iw" secondAttribute="bottom" constant="6" symbolic="YES" id="lNL-90-rs8"/> -->
<constraint firstItem="VQb-h7-4Va" firstAttribute="leading" secondItem="eNw-hu-Cry" secondAttribute="leading" constant="20" symbolic="YES" id="mH1-7c-T7R"/>
<constraint firstItem="VQb-h7-4Va" firstAttribute="top" secondItem="eNw-hu-Cry" secondAttribute="top" constant="20" symbolic="YES" id="ofz-7y-fpb"/>
<constraint firstItem="Ljs-s0-qtL" firstAttribute="trailing" secondItem="VQb-h7-4Va" secondAttribute="trailing" id="t2a-YM-4WY"/>
Expand Down
Loading

0 comments on commit 60c5d3b

Please sign in to comment.