Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Use PressSecretary from AlfredSwift
Browse files Browse the repository at this point in the history
This gieves a nice dialog for restarting Alfred.
The restart is essential because press secretary
doesn't start working until Alfred is restarted.

Fixes #6
  • Loading branch information
mr-pennyworth committed May 29, 2021
1 parent 8b28afa commit 87c61e1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
6 changes: 3 additions & 3 deletions alfred-gif-browser/AlfredGifBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.3.1;
MARKETING_VERSION = 0.3.2;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = mr.pennyworth.AlfredGifBrowser;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -342,7 +342,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 0.3.1;
MARKETING_VERSION = 0.3.2;
ONLY_ACTIVE_ARCH = YES;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = mr.pennyworth.AlfredGifBrowser;
Expand Down Expand Up @@ -388,7 +388,7 @@
repositoryURL = "https://github.com/mr-pennyworth/AlfredSwift";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.0.8;
minimumVersion = 0.0.9;
};
};
D0E43DF9265CB0330016375D /* XCRemoteSwiftPackageReference "FileWatcher" */ = {
Expand Down
3 changes: 3 additions & 0 deletions alfred-gif-browser/AlfredGifBrowser/AlfredWatcher.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Alfred
import Cocoa
import CoreFoundation

Expand Down Expand Up @@ -26,6 +27,8 @@ class AlfredWatcher {
onLeftArrowPressed: @escaping () -> Void,
setAlfredFrame: @escaping (NSRect) -> Void
) {
PressSecretary.enable()

onDestroy = onAlfredWindowDestroy
onDownArrow = onDownArrowPressed
onUpArrow = onUpArrowPressed
Expand Down
46 changes: 35 additions & 11 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,10 @@ rm *.html</string>
<key>ignoredynamicplaceholders</key>
<false/>
<key>largetypetext</key>
<string>Allow "Accessibility"
For "AlfredGifBrowser.app"
<string>Allow "Accessibility" For "AlfredGifBrowser.app"
1) If the app is already present in the pane, remove it.
2) Drag and drop to add the app again.
The GIF browser needs these permissions
for monitoring arrow key presses</string>
Expand All @@ -1198,25 +1200,47 @@ for monitoring arrow key presses</string>
<key>script</key>
<string>#!/bin/bash
xattr -d com.apple.quarantine ./AlfredGifBrowser.app
xattr -d com.apple.quarantine ./AlfredGifBrowser.app/Contents/MacOS/AlfredGifBrowser
# Enable AlfredGifBrowser.app to listen to Alfred's events
defaults write com.runningwithcrayons.Alfred experimental.presssecretary -bool YES
wfdir="$alfred_preferences/workflows/$alfred_workflow_uid"
cat &lt;&lt;EOF | osascript
tell application "Finder"
set wfDir to POSIX file "$wfdir"
open wfDir
activate
set win to front Finder window
set gifApp to item "AlfredGifBrowser.app" of win
set bounds of win to {0, 0, 220, 350}
set the toolbar visible of win to false
set the statusbar visible of win to false
set the pathbar visible of win to false
set the sidebar width of win to 0
set the current view of win to icon view
set icon size of icon view options of win to 220
set arrangement of icon view options of win to not arranged
set position of gifApp to {-5000, -5000}
close win
open wfDir
select gifApp
end tell
EOF
# Open the app so that it shows in the Accessibility Settings
open ./AlfredGifBrowser.app
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"
osascript &lt;&lt;END
tell application "System Preferences"
activate
tell the preferences window
set bounds to {320, 0, 500, 500}
end tell
end tell
END
# The app needs to be restarted anyway, so close it
killall AlfredGifBrowser</string>
END</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -2118,7 +2142,7 @@ EOF</string>
<string>giphy_key</string>
</array>
<key>version</key>
<string>0.3.1</string>
<string>0.3.2</string>
<key>webaddress</key>
<string>https://github.com/mr-pennyworth/alfred-gif</string>
</dict>
Expand Down

0 comments on commit 87c61e1

Please sign in to comment.