├── .gitignore
├── CHANGELOG.md
├── HaxWithFlic.dmg
├── README.md
├── Screenshot.png
└── scripts
├── BeardedSpice
├── next.AppleScript
├── playpause.AppleScript
└── previous.AppleScript
├── Clipboard-Tools
├── removeDuplicateLines.sh
├── reverseLines.sh
├── sortLines.sh
└── textToSpeech.sh
├── Desktop-Tools
├── interactiveScreenshot.sh
├── maximizeApplicationWindow.AppleScript
├── screenshot.sh
└── splitApplicationWindows.AppleScript
├── Finder-Tools
├── copyPathToClipboard.AppleScript
└── moveSelectedFilesToFolder.AppleScript
├── General
├── currentDateToClipboard.AppleScript
├── currentDateToClipboardAndPaste.AppleScript
├── displayCurrentDateInDialog.AppleScript
├── displaysleep.sh
├── saveClipboardToFile.AppleScript
├── sleep.sh
└── startCalculator.AppleScript
├── Google-Chrome
├── chrome-CloseFrontWindow.AppleScript
├── chrome-Reload.AppleScript
└── chrome-ShowSourceFile.AppleScript
├── Hue
├── hue_all_off.rb
├── hue_all_on.rb
├── hue_switch.rb
└── hue_switch.sh
├── Keynote
├── keynoteNextSlide.sh
└── keynotePreviousSlide.sh
├── Sonos
├── sonos-NextTrack.sh
├── sonos-Pause.sh
├── sonos-Play.sh
├── sonos-PlayPauseToggle.sh
└── sonos-PreviousTrack.sh
├── Spotify
├── pauseSpotifyAndSleep.sh
├── spotify-NextTrack.AppleScript
├── spotify-PlayPause.AppleScript
└── spotify-PreviousTrack.AppleScript
└── VLC
├── vlc-Fullscreen.AppleScript
├── vlc-Mute.AppleScript
├── vlc-NextPlaylistItem.AppleScript
├── vlc-PlayPause.AppleScript
├── vlc-PreviousPlaylistItem.AppleScript
├── vlc-StepBackward.AppleScript
├── vlc-StepForward.AppleScript
├── vlc-StopPlayback.AppleScript
├── vlc-VolumeDown.AppleScript
└── vlc-VolumeUp.AppleScript
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | #hax-with-flic-osx 0.2.4
2 |
3 | **Changes**
4 |
5 | * Improved stability on macOS Sierra.
6 | * Fixed a bug that caused button scanning to fail sometimes.
7 |
8 | #hax-with-flic-osx 0.2.3
9 |
10 | **Changes**
11 |
12 | * Added support for multiple buttons.
13 | * Improved button connectivity.
14 | * Script text fields now truncated on the left to improve readability.
15 |
16 | #hax-with-flic-osx 0.1.6
17 |
18 | Minor bug fix release.
19 |
20 | #hax-with-flic-osx 0.1.5
21 |
22 | Minor bug fix release.
23 |
24 | **Changes**
25 |
26 | * The app will now tell you if Bluetooth Low Energy is not supported on this computer when you start a scan.
27 |
28 | **Issues Fixed**
29 |
30 | * [Issue #6](https://github.com/50ButtonsEach/hax-with-flic-osx/issues/6) Queued click events that was generated when the button was disconnected will now be delivered if they are less than 5 seconds old. This change is added to avoid click event loss in case the connection was dropped at the time of the button press. Typically if the button is disconnected when it is pressed, then it will connect immediately once pressed if within range.
31 |
32 | * [Issue #5](https://github.com/50ButtonsEach/hax-with-flic-osx/issues/5) If you have custom trust settings on your certificates then it could is some cases cause the initial button unlock during scan to fail due to certificate pinning error. This has been fixed.
33 |
34 |
--------------------------------------------------------------------------------
/HaxWithFlic.dmg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/50ButtonsEach/hax-with-flic-osx/da2a750aca5ffb704e0d3802a54ec0f1a4af118b/HaxWithFlic.dmg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NOTE
2 |
3 | This app only supports the first generation Flic buttons and is no longer in development. Instead we suggest using the newer [Flic Mac App](https://flic.io/mac-app). Alternatively, Flic 2 buttons can simulate a keyboard and be connected as a generic Bluetooth keyboard. See [Flic Universal](https://flic.io/flic-universal) for more info.
4 |
5 | # hax-with-flic-osx
6 |
7 | This is a basic app for Mac that integrates with Flic 1 buttons.
8 |
9 | 
10 |
11 | The application allows you to execute your own scripts on Flic button presses. This requires OSX 10.10 or above operating systems running on a machine that supports Bluetooth Low Energy. It is unclear exactly which machines that have Bluetooth Low Energy support, but Apple supposedly started the transition around 2012. Running the following in a terminal will output the Bluetooth LMP Version:
12 |
13 | system_profiler -detailLevel full SPBluetoothDataType | grep "LMP Version"
14 |
15 | Version 0x6 was the first one that supported Low Energy, but we cannot guarantee that this will be correct for all computers. Using a Bluetooth Low Energy compatible USB dongle should also work if it is just configured correctly.
16 |
17 | **Important notice**
18 |
19 | Since this application will blindly execute the scripts that you tell it to execute, it is very important that you make sure that you know what these scripts do. You need to verify, or have verified by someone who you trust, that the code being executed is not malicious in any way. We will not take responsibility for any harm that you may cause to your machine.
20 |
21 | **How it works**
22 |
23 | This application will allow you to connect multiple Flic buttons to your Mac computer and then select which scripts that you wish to execute on `click`, `double click`, `hold`, `up` and `down`.
24 |
25 | **Supported script files**
26 |
27 | The following files are supported:
28 |
29 | * Automator workflows (`.workflow`)
30 | * All files that are executable (`chmod +x a_script.py`) and contains a shebang on its first line (`#!/some/path`)
31 |
32 | Some examples of supported files:
33 |
34 | * AppleScript - `.scpt, .AppleScript` - `#!/usr/bin/osascript`
35 | * Shell Script - `.sh` - `#!/bin/sh`
36 | * Ruby Script - `.rb` - `#!/usr/bin/env ruby`
37 | * Python Script - `.py` - `#!/usr/bin/env python`
38 |
39 | This can of course vary a bit depending on how your Mac is configured.
40 |
41 | **Installation**
42 |
43 | 1. Download the repository by pressing the "Download ZIP" button.
44 | 2. Mount the dmg file and drag and drop the HaxWithFlic.app to your applications folder.
45 | 3. When launching the application from the applications folder the first time it will ask you if you want to open a file that was downloaded from the internet. Press open.
46 | 4. Press on the flic icon in the menu bar and start using the application. For example, press scan if you want to add a new Flic.
47 |
48 | **Configuration**
49 |
50 | 1. Press “Configure scripts..”.
51 | 2. Add search paths to the scripts you want to launch.
52 |
53 | Please note that some actions (like window resizing) requires that you add “HackWithFlic” to the accessibility list under the privacy settings of your mac. You can turn off the audio notifications by unchecking the "Play audio" option. If you are using the button for tasks that require very low latency then you can lower the latency by checking the "Low latency mode" option, but remember that this will decrease the battery life of your Flic significantly. The low latency mode reduces the latency down to 45ms from the normal 280ms. Notice, however, that these are worst case times and that the expected time is about half of that. The button down event always arrives before any other event, so it can be used for time critical applications.
54 |
55 | **Scripts**
56 |
57 | We have added a few pre-made scripts that you can find in this repository. All of them are very small and should be self explanatory. If you have any cool scripts of your own that you believe could be useful to other people, then feel free to submit a pull request on this repository.
58 |
59 |
60 | # Scripts
61 |
62 | **Clipboard-Tools**
63 |
64 | * `removeDuplicateLines.sh` Goes through your clipboard and removes all duplicate lines.
65 | * `reverseLines.sh` Goes through your clipboard and reverses the characters on each line.
66 | * `sortLines.sh` Goes through your clipboard and sorts all lines.
67 | * `textToSpeech.sh` Takes the contents of your clipboard and plays it using text to speech.
68 |
69 | **Desktop-Tools**
70 |
71 | * `interactiveScreenshot.sh` Lets you select an area of your screen that you want to take a screenshot of. Resulting image is saved to your desktop folder.
72 | * `maximizeApplicationWindow.sh` Maximizes the size of the frontmost window of the active application.
73 | * `screenshot.sh` Takes a screenshot of your full desktop. Resulting image is saved to your desktop.
74 | * `splitApplicationWindows.AppleScript` Resizes the two frontmost windows of your active application and displays them side by side.
75 |
76 | **Finder-Tools**
77 |
78 | * `copyPathToClipboard.AppleScript` Copies the path of the selected item in your frontmost finder window to your clipboard.
79 | * `moveSelectedFilesToFolder.AppleScript` Lets you move the selected items in your frontmost finder window to a different location.
80 |
81 | **General**
82 |
83 | * `currentDateToClipboard.AppleScript` Copies the current time and date to your clipboard.
84 | * `currentDateToClipboardAndPaste.AppleScript` Same as above but also pastes to your active application.
85 | * `displayCurrentDateInDialog.AppleScript` Displays a dialog window with the current time and date.
86 | * `saveClipboardToFile.AppleScript` Lets you save the contents of the clipboard to a new file at a location that you choose.
87 | * `startCalculator.AppleScript` Launches the Mac Calculator app.
88 | * `displaysleep.sh` Shuts down the display, system continues to run in the background. (Added by [jonashoechst](https://github.com/jonashoechst))
89 | * `sleep.sh` Puts system to sleep, no network working anymore. (Added by [jonashoechst](https://github.com/jonashoechst))
90 |
91 | **Google-Chrome**
92 |
93 | * `chrome-CloseFrontWindow.AppleScript` Closes the frontmost chrome window. This closes all tabs in that window.
94 | * `chrome-Reload.AppleScript` Reload the selected tab of the frontmost chrome window.
95 | * `chrome-ShowSourceFile.AppleScript` Opens a new tab showing the source code of the selected tab of the frontmost chrome window.
96 |
97 | **Hue**
98 |
99 | * `hue_switch.sh` Toggle all your Philips Hue lights on/off. (Added by [patricks](https://github.com/patricks))
100 | * `hue_all_off.rb` Turns off all lights. (Added by [patricks](https://github.com/patricks))
101 | * `hue_all_on.rb` Turns on all lights. (Added by [patricks](https://github.com/patricks))
102 | * `hue_switch.rb` Switches the current state of all lights. (Added by [patricks](https://github.com/patricks))
103 |
104 | **Keynote**
105 |
106 | * `keynoteNextSlide.sh` Display next slide. This actually only simulates a keypress on the space key.
107 | * `keynotePreviousSlide.sh` Display previous slide. This simulates a press on the p-key.
108 |
109 | **Spotify**
110 |
111 | * `spotify-NextTrack.AppleScript` Moves to the next track. Also works with Spotify connect.
112 | * `spotify-PlayPause.AppleScript` Play or Pause the music. Also works with Spotify connect.
113 | * `spotify-PreviousTrack.AppleScript` Moves to the previous track. Also works with Spotify connect.
114 | * `pauseSpotifyAndSleep.sh` Pauses Spotify if a track is currently playing and then puts mac to sleep. (Added by [echo0101](https://github.com/echo0101))
115 |
116 | **Sonos**
117 |
118 | Notice: All Sonos scripts requires that you find the IP address of your Sonos and then change the script accordingly.
119 |
120 | * `sonos-NextTrack.sh` Skip to next track in your current playing playlist.
121 | * `sonos-Pause.sh` Pause the playback.
122 | * `sonos-Play.sh` Play the previously paused playback.
123 | * `sonos-PlayPauseToggle.sh` Toggle between play and pause.
124 | * `sonos-PreviousTrack.sh` Skip to the previous track in your current playing playlist.
125 |
126 | **VLC**
127 |
128 | * `vlc-Fullscreen.AppleScript` Toggle fullscreen.
129 | * `vlc-Mute.AppleScript` Toggle mute.
130 | * `vlc-NextPlaylistItem.AppleScript` Jump to next item in playlist.
131 | * `vlc-PlayPause.AppleScript` Toggle play/pause.
132 | * `vlc-PreviousPlaylistItem.AppleScript` Jump to previous item in playlist.
133 | * `vlc-StepBackward.AppleScript` Step backward. Step length can be configured.
134 | * `vlc-StepForward.AppleScript` Step forward. Step length can be configured.
135 | * `vlc-StopPlayback.AppleScript` Stop the current playback.
136 | * `vlc-VolumeDown.AppleScript` Decrease volume by one step. Step length can be configured.
137 | * `vlc-VolumeUp.AppleScript` Increase volume by one step. Step length can be configured.
138 |
139 |
140 |
--------------------------------------------------------------------------------
/Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/50ButtonsEach/hax-with-flic-osx/da2a750aca5ffb704e0d3802a54ec0f1a4af118b/Screenshot.png
--------------------------------------------------------------------------------
/scripts/BeardedSpice/next.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "BeardedSpice" is true then
3 | tell application "BeardedSpice"
4 | next
5 | end tell
6 | end if
7 |
--------------------------------------------------------------------------------
/scripts/BeardedSpice/playpause.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "BeardedSpice" is true then
3 | tell application "BeardedSpice"
4 | playpause
5 | end tell
6 | end if
7 |
--------------------------------------------------------------------------------
/scripts/BeardedSpice/previous.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "BeardedSpice" is true then
3 | tell application "BeardedSpice"
4 | previous
5 | end tell
6 | end if
7 |
--------------------------------------------------------------------------------
/scripts/Clipboard-Tools/removeDuplicateLines.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | pbpaste | sort | uniq | pbcopy
--------------------------------------------------------------------------------
/scripts/Clipboard-Tools/reverseLines.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | pbpaste | rev | pbcopy
--------------------------------------------------------------------------------
/scripts/Clipboard-Tools/sortLines.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | pbpaste | sort | pbcopy
3 |
--------------------------------------------------------------------------------
/scripts/Clipboard-Tools/textToSpeech.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | pbpaste | iconv -f utf-8 -t utf-8 -c | say
--------------------------------------------------------------------------------
/scripts/Desktop-Tools/interactiveScreenshot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | screencapture -i ~/Desktop/$(date +%Y%m%d%H%M%S).png
--------------------------------------------------------------------------------
/scripts/Desktop-Tools/maximizeApplicationWindow.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | tell application "Finder"
3 | set {screen_top, screen_left, screen_width, screen_height} to bounds of window of desktop
4 | end tell
5 |
6 | tell application "System Events"
7 | set myFrontMost to name of first item of (processes whose frontmost is true)
8 | end tell
9 |
10 | tell application "System Events"
11 | tell process myFrontMost
12 |
13 | try
14 | set position of window 1 to {0, 0}
15 | set size of window 1 to {screen_width, screen_height}
16 | on error errStr
17 | return errStr
18 | end try
19 | end tell
20 | end tell
21 |
--------------------------------------------------------------------------------
/scripts/Desktop-Tools/screenshot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | screencapture ~/Desktop/$(date +%Y%m%d%H%M%S).png
--------------------------------------------------------------------------------
/scripts/Desktop-Tools/splitApplicationWindows.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | tell application "Finder"
3 | set {screen_top, screen_left, screen_width, screen_height} to bounds of window of desktop
4 | end tell
5 |
6 | tell application "System Events"
7 | set myFrontMost to name of first item of (processes whose frontmost is true)
8 | end tell
9 |
10 | tell application "System Events"
11 | tell process myFrontMost
12 |
13 | try
14 | set position of window 1 to {0, 0}
15 | set size of window 1 to {screen_width / 2, screen_height}
16 | set position of window 2 to {screen_width / 2, 0}
17 | set size of window 2 to {screen_width / 2, screen_height}
18 | on error errStr
19 | return errStr
20 | end try
21 | end tell
22 | end tell
23 |
--------------------------------------------------------------------------------
/scripts/Finder-Tools/copyPathToClipboard.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | tell application "Finder"
3 | set pathFile to selection as text
4 | set pathFile to get POSIX path of pathFile
5 | set the clipboard to pathFile
6 | end tell
--------------------------------------------------------------------------------
/scripts/Finder-Tools/moveSelectedFilesToFolder.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | tell application "Finder"
3 | set mvfiles to selection
4 | set destFolderPath to choose folder
5 | set destFolder to name of destFolderPath
6 | set destFolder to destFolderPath as string
7 | move mvfiles to destFolder
8 | end tell
--------------------------------------------------------------------------------
/scripts/General/currentDateToClipboard.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | set currdate to current date as Unicode text
3 | set the clipboard to currdate
4 |
--------------------------------------------------------------------------------
/scripts/General/currentDateToClipboardAndPaste.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | set currdate to (current date) as Unicode text
3 | set the clipboard to currdate
4 | tell application "System Events"
5 | keystroke "v" using {command down}
6 | end tell
7 |
--------------------------------------------------------------------------------
/scripts/General/displayCurrentDateInDialog.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | set currdate to (current date) as Unicode text
3 | display dialog currdate
4 |
--------------------------------------------------------------------------------
/scripts/General/displaysleep.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Shuts down the display, system continues to run in the background (network, etc...)
3 | pmset displaysleepnow
4 |
--------------------------------------------------------------------------------
/scripts/General/saveClipboardToFile.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | set d to the clipboard as «class utf8»
3 | set fn to choose file name
4 | set fid to open for access fn with write permission
5 | write d to fid
6 | close access fid
--------------------------------------------------------------------------------
/scripts/General/sleep.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Puts system to sleep, no network working anymore.
3 | pmset sleepnow
4 |
--------------------------------------------------------------------------------
/scripts/General/startCalculator.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | tell application "Calculator"
3 | launch
4 | activate
5 | end tell
--------------------------------------------------------------------------------
/scripts/Google-Chrome/chrome-CloseFrontWindow.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "/Applications/Google Chrome.app" is true then
3 | tell application "/Applications/Google Chrome.app"
4 | close of front window
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/Google-Chrome/chrome-Reload.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "/Applications/Google Chrome.app" is true then
3 | tell application "/Applications/Google Chrome.app"
4 | reload of active tab of front window
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/Google-Chrome/chrome-ShowSourceFile.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "/Applications/Google Chrome.app" is true then
3 | tell application "/Applications/Google Chrome.app"
4 | view source of active tab of front window
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/Hue/hue_all_off.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # the hue ruby gem is requried
4 | # installation: sudo gem install hue
5 |
6 | require 'hue'
7 |
8 | # setup the client
9 | client = Hue::Client.new
10 |
11 | # get all lights
12 | lights = client.lights
13 |
14 | # switch all lights off
15 | lights.each do |light|
16 | light.off!
17 | end
18 |
--------------------------------------------------------------------------------
/scripts/Hue/hue_all_on.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # the hue ruby gem is requried
4 | # installation: sudo gem install hue
5 |
6 | require 'hue'
7 |
8 | # setup the client
9 | client = Hue::Client.new
10 |
11 | # get all lights
12 | lights = client.lights
13 |
14 | # switch all lights on
15 | lights.each do |light|
16 | light.on!
17 | end
18 |
--------------------------------------------------------------------------------
/scripts/Hue/hue_switch.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # the hue ruby gem is requried
4 | # installation: sudo gem install hue
5 |
6 | require 'hue'
7 |
8 | # setup the client
9 | client = Hue::Client.new
10 |
11 | # get all lights
12 | lights = client.lights
13 |
14 | bridge = client.bridge
15 |
16 | # switch the current state of all lights
17 | lights.each do |light|
18 | if light.on?
19 | light.off!
20 | else
21 | light.on!
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/scripts/Hue/hue_switch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # the hue ruby gem is requried
4 | # installation: sudo gem install hue
5 |
6 | DATE=`date "+%d.%m.%Y-%H:%M:%S"`
7 | STATEON=/tmp/hue.state.on
8 | STATEOFF=/tmp/hue.state.off
9 | LOGFILE=/tmp/hue.log
10 | HUEBIN=/usr/local/bin/hue
11 |
12 | if [ -f $STATEON ]; then
13 | $HUEBIN all off > /dev/null
14 | rm -f $STATEON
15 | touch $STATEOFF
16 |
17 | echo "state: off $DATE" > $LOGFILE
18 | else
19 | $HUEBIN all on > /dev/null
20 | rm -f $STATEOFF
21 | touch $STATEON
22 |
23 | echo "state: on $DATE" > $LOGFILE
24 | fi
25 |
--------------------------------------------------------------------------------
/scripts/Keynote/keynoteNextSlide.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | echo "tell application \"System Events\" to keystroke \" \"" | osascript
--------------------------------------------------------------------------------
/scripts/Keynote/keynotePreviousSlide.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | echo "tell application \"System Events\" to keystroke \"p\"" | osascript
--------------------------------------------------------------------------------
/scripts/Sonos/sonos-NextTrack.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Move to the next track on your sonos playlist.
4 |
5 | # Change the IP address to the IP address of your Sonos.
6 |
7 | IP_ADDRESS=192.168.2.25
8 |
9 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Next"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
10 |
11 |
--------------------------------------------------------------------------------
/scripts/Sonos/sonos-Pause.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Pause sonos that is available on the local network
4 | # Change the IP address to the IP address of your Sonos.
5 |
6 | IP_ADDRESS=192.168.2.25
7 |
8 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Pause"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
--------------------------------------------------------------------------------
/scripts/Sonos/sonos-Play.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Play sonos that is available on the local network
4 | # Change the IP address to the IP address of your Sonos.
5 |
6 | IP_ADDRESS=192.168.2.25
7 |
8 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
--------------------------------------------------------------------------------
/scripts/Sonos/sonos-PlayPauseToggle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Toggle Play/Pause sonos that is available on the local network.
4 | # You may have to press it two times the first time to get it to enter the correct state.
5 |
6 | # Change the IP address to the IP address of your Sonos.
7 |
8 | IP_ADDRESS=192.168.2.25
9 |
10 | STATEON=/tmp/sonos.state.playing
11 | STATEOFF=/tmp/sonos.state.paused
12 |
13 | if [ -f $STATEON ]; then
14 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
15 | rm -f $STATEON
16 | touch $STATEOFF
17 | else
18 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Pause"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
19 | rm -f $STATEOFF
20 | touch $STATEON
21 | fi
22 |
--------------------------------------------------------------------------------
/scripts/Sonos/sonos-PreviousTrack.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Move to the next track on your sonos playlist.
4 |
5 | # Change the IP address to the IP address of your Sonos.
6 |
7 | IP_ADDRESS=192.168.2.25
8 |
9 | curl --header 'Content-Type: "text/xml"' --header 'SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Previous"' --data '01' http://$IP_ADDRESS:1400/MediaRenderer/AVTransport/Control
10 |
11 |
--------------------------------------------------------------------------------
/scripts/Spotify/pauseSpotifyAndSleep.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Pause Spotify and Sleep
4 | # - pauses Spotify if a track is currently playing.
5 | # - puts mac to sleep
6 |
7 | state=`osascript -e 'tell application "Spotify" to player state as string'`;
8 | if [ $state = "playing" ]; then
9 | osascript -e 'tell application "Spotify" to playpause';
10 | fi
11 |
12 | pmset displaysleepnow
13 |
14 |
--------------------------------------------------------------------------------
/scripts/Spotify/spotify-NextTrack.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "Spotify" is true then
3 | tell application "Spotify"
4 | next track
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/Spotify/spotify-PlayPause.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "Spotify" is true then
3 | tell application "Spotify"
4 | playpause
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/Spotify/spotify-PreviousTrack.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | if running of application "Spotify" is true then
3 | tell application "Spotify"
4 | previous track
5 | end tell
6 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-Fullscreen.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Toggle VLC fullscreen mode.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | fullscreen
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-Mute.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Mute or unmute the VLC audio playback.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | mute
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-NextPlaylistItem.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Jump to next item in playlist.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | next
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-PlayPause.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Play or Pause the current playlist item
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | play
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-PreviousPlaylistItem.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Jump to previous item in playlist.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | previous
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-StepBackward.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Step backward. The step width can be changed below.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | # Step width (1=extraShort, 2=short, 3=medium, 4=long).
7 | step backward 2
8 | end tell
9 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-StepForward.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Step forward. The step width can be changed below.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | # Step width (1=extraShort, 2=short, 3=medium, 4=long).
7 | step forward 2
8 | end tell
9 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-StopPlayback.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Stop playing the current playlist item.
3 |
4 | if running of application "/Applications/VLC.app" is true then
5 | tell application "/Applications/VLC.app"
6 | stop
7 | end tell
8 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-VolumeDown.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Decrease volume by one step. There are a total of 32 steps.
3 | # If you want to decrease the volume more on each execution then just uncomment the second volumeDown below.
4 |
5 | if running of application "/Applications/VLC.app" is true then
6 | tell application "/Applications/VLC.app"
7 | volumeDown
8 | # Uncomment next line for more decrease..
9 | # volumeDown
10 | end tell
11 | end if
--------------------------------------------------------------------------------
/scripts/VLC/vlc-VolumeUp.AppleScript:
--------------------------------------------------------------------------------
1 | #!/usr/bin/osascript
2 | # Increase volume by one step. There are a total of 32 steps.
3 | # If you want to increase the volume more on each execution then just uncomment the second volumeUp below.
4 |
5 | if running of application "/Applications/VLC.app" is true then
6 | tell application "/Applications/VLC.app"
7 | volumeUp
8 | # Uncomment next line for more increase..
9 | # volumeUp
10 | end tell
11 | end if
--------------------------------------------------------------------------------