Skip to content

Commit

Permalink
rewrite in python for macOS Monterey
Browse files Browse the repository at this point in the history
  • Loading branch information
stroebjo committed Mar 13, 2022
1 parent 48520e5 commit e45d68e
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 220 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Alfred Pushover

This workflow for [Alfred 3](https://www.alfredapp.com/) allows you to send notifcations to your mobile devices with [Pushover](https://pushover.net/).
This workflow for [Alfred](https://www.alfredapp.com/) allows you to send notifications to your mobile devices with [Pushover](https://pushover.net/).

![Preview of Pushover workflow](docs/alfred-pushover.png)

The workflow has to keywords `push <text to push>` and `pushc` to push your current clipboard. You can than push it to all your devices or select a sepcific one (see step 4. under Installation).
The workflow has two keywords `push <text to push>` and `pushc` to push your current clipboard. You can than push it to all your devices or select a specific one (see step 4. under Installation).

- If you push an URL the workflow will use the Pushover feature for pushing URLs so it can be directly be opend in the App.
- If you push a URL the workflow will use the Pushover feature for pushing URLs, so it can be directly be opened in the App.
- If the URL points to an image it will send the image also.
- If you have the path to an local image in your clipboard it will send the image as well.
- If you have the path to a local image in your clipboard it will send the image as well.

## Installation

1. Head over to Pushover an [create a new application](https://pushover.net/apps/build). Set a name and choose `Script` in the Type-dropdown. Copy the API Token of the newly created application.
1. Head over to Pushover and [create a new application](https://pushover.net/apps/build). Set a name and choose `Script` in the Type-dropdown. Copy the API Token of the newly created application.
2. [Download the Workflow here](https://github.com/stroebjo/alfred-pushover/releases/latest) and open it.
3. Head over to the settings pane of the Pushover worklfow and configure the variables with your `USER_KEY` and the `APP_TOKEN` of the App you just created.
4. Optionally you can enter the names of your devices so you can push notification to a specfic device.
3. Head over to the settings pane of the Pushover workflow and configure the variables with your `USER_KEY` and the `APP_TOKEN` of the App you just created.
4. Optionally you can enter the names of your devices, so you can push notification to a specific device. For that set the `DEVICES` key in the workflow variables with a list of comma separated device names.

For the image preview to work you need to install the [requests](https://docs.python-requests.org/en/master/user/install/#install) package. Be sure to install it with the macOS system python: `$ /usr/bin/python3 -m pip install requests`.
64 changes: 16 additions & 48 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>3CDD977D-FE3F-4760-8D67-BE2C0F567165</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>FBDD0BD4-E336-4DE7-99C4-611868218099</key>
<array>
Expand Down Expand Up @@ -140,9 +130,9 @@
<key>escaping</key>
<integer>100</integer>
<key>script</key>
<string>/opt/homebrew/bin/php -f pushover.php "{query}"</string>
<string>python3 pushover.py "{query}"</string>
<key>scriptargtype</key>
<integer>1</integer>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
Expand Down Expand Up @@ -204,7 +194,7 @@
<array>
<dict>
<key>inputstring</key>
<string>{var:devices}</string>
<string>{var:DEVICES}</string>
<key>matchcasesensitive</key>
<true/>
<key>matchmode</key>
Expand Down Expand Up @@ -236,7 +226,7 @@
<false/>
<key>variables</key>
<dict>
<key>message</key>
<key>MESSAGE</key>
<string>{query}</string>
</dict>
</dict>
Expand Down Expand Up @@ -293,23 +283,6 @@ end run</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argument</key>
<string>'{query}', {allvars}</string>
<key>cleardebuggertext</key>
<false/>
<key>processoutputs</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.utility.debug</string>
<key>uid</key>
<string>3CDD977D-FE3F-4760-8D67-BE2C0F567165</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand All @@ -336,7 +309,7 @@ end run</string>
<key>runningsubtext</key>
<string>Fetching your devices…</string>
<key>script</key>
<string>/opt/homebrew/bin/php -f select.php "{query}"</string>
<string>python3 select_device.py "{query}"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand All @@ -346,7 +319,7 @@ end run</string>
<key>title</key>
<string>Select device</string>
<key>type</key>
<integer>5</integer>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
Expand All @@ -369,11 +342,13 @@ The User Key can be found on your Pushover dashboard.
Create a new Pushover application here https://pushover.net/apps/build.
## devices
## DEVICES
To allow you to push notifcations to specific devices instead of all, enter the names of your devices seperated by a comma (i.e. "ipad, android").
To allow you to push notifications to specific devices instead of all, enter the names of your devices separated by a comma (i.e. "ipad, android").
For the preview of images the [requests](https://docs.python-requests.org/en/master/user/install/#install) package is required.
## PREVIEW_REMOTE
If set to `1` will check if the submitted query is a URL and do a request to it and use HTML `&lt;title&gt;` to enhance the notification. In case of an image it will be saved locally and sent to Pushover as an attachment (see https://pushover.net/api#attachments).
Expand All @@ -390,13 +365,6 @@ If set to `1` will check if the submitted query is a valid local file and if it'
<key>ypos</key>
<integer>120</integer>
</dict>
<key>3CDD977D-FE3F-4760-8D67-BE2C0F567165</key>
<dict>
<key>xpos</key>
<integer>790</integer>
<key>ypos</key>
<integer>335</integer>
</dict>
<key>4CAE3596-46D2-48AB-8E10-D6421B1CC0B6</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -428,9 +396,9 @@ If set to `1` will check if the submitted query is a valid local file and if it'
<key>EA8A3C6A-35A5-4451-82B0-1F1A008CB9BB</key>
<dict>
<key>xpos</key>
<integer>580</integer>
<integer>575</integer>
<key>ypos</key>
<integer>350</integer>
<integer>360</integer>
</dict>
<key>FBDD0BD4-E336-4DE7-99C4-611868218099</key>
<dict>
Expand All @@ -451,23 +419,23 @@ If set to `1` will check if the submitted query is a valid local file and if it'
<dict>
<key>APP_TOKEN</key>
<string></string>
<key>DEVICES</key>
<string></string>
<key>PREVIEW_LOCAL</key>
<string>1</string>
<key>PREVIEW_REMOTE</key>
<string>1</string>
<key>USER_KEY</key>
<string></string>
<key>devices</key>
<string></string>
</dict>
<key>variablesdontexport</key>
<array>
<string>devices</string>
<string>DEVICES</string>
<string>APP_TOKEN</string>
<string>USER_KEY</string>
</array>
<key>version</key>
<string>1.1.2</string>
<string>2.0.0</string>
<key>webaddress</key>
<string>http://jonathanstroebele.de</string>
</dict>
Expand Down
141 changes: 0 additions & 141 deletions pushover.php

This file was deleted.

Loading

0 comments on commit e45d68e

Please sign in to comment.