[Fire TV General] harlekinwashere:
It has been a long time since I last posted some of my AppleScripts (posted them on reddit way back when...) - so I decided its time for an update, since I changed them quite a bit since I first wrote them.

So what is this?

--

In the .zip file below are small applescripts I use on a daily basis to control my FireTV (/Sticks) and Kodi from my Macbook.

You can look at the source of every single one of those scripts using the AppleScript-Editor that comes with every Mac. I encourage you to look at how they work, and modify them, or write your own eventually.

I use two additional programs from github (aafm and xbev) that are currently included in the .zip file - so its easier for you to use them, without sourcing them first -

the respective project sites are:

https://github.com/sole/aafm

and

https://github.com/bobo1on1/xbev

please visit the sites to say thank you for the work their devs did, or contribute to the projects.

(If you wan't me to take them out of the .zip package, drop me a PN, or post it here in the thread and I will take them out immediately and replace them with readmes on how to source the programs instead.)

--

To use the scripts you have to have adb installed on the Mac.

http://xdaforums.com/android/general/adb-fastboot-binaries-os-x-inclusive-t2941205

It doesn't hurt if you are familiar with adb already. And at least have used the adb connect, adb disconnect and adb devices commands before.

Also of course on the Fire TV ADB has to be enabled. (Developer settings.)

To use aafm and xbev you have to have

python

https://www.python.org/downloads/mac-osx/

and

pygtk

http://python.6.x6.nabble.com/Testing-PyGTK-installer-for-Mac-OS-X-td1948270.html or google it

installed, because both programs depend on it.

--

Getting started with the scripts.

In the .zip file, there is a folder named FireRemote which contains the scripts and the Applescript apps. That folder HAS to be copied to the documents folder in MacOS. The scripts have to be started from there. They are written in a way that depends on it.

All the .sh files in the main folder (not the sub folders, the main folder is the one called FireRemote) have to be made executable (chmod 755) or the scripts will not work. The .sh files generally are helper scripts, meant to be executed by the main script, once you run that.

The reason why this is needed is, that I pull the Fire TV's IP address from the terminal history - and this only works if I use shell scripts that are executable.

--

How do you use them?

there is one prerequisite, and that is that you typed in

adb connect IP.ADD.RE.SS

into the macs Terminal recently. IP.ADD.RE.SS of course being the actual IP address of your FireTV (/Stick). If you are typing it in just now, make sure to disconnect from your FIre TV with

adb disconnect

afterwards - or the adb "channel" won't be open for the scripts to connect. Also - it might not hurt to toggle the FireTVs adb toggle (in Settings) off and on. If you have still issues with the scripts connecting.

--

Scripts and what they do.

aafmtrigger

connects to the FireTV and starts aafm - a GUI adb filebrowser, that allows you to browse the FireTVs file system and transfer files from and to the Mac.

If you start the app again (for example using the cmd+space spotlight shortcut), it closes aafm and the adb connection.

acopy

copies the content of your clipboard to a textfile, names it zwischenablage.m3u, copies it to /sdcard/ on the FireTV and tells Kodi to play it. This is meant to be used with any direct video links you get from the web.

To get direct videolinks (and copy them into your clipboard) you could use the chrome or firefox extension "Video DownloadHelper" - if you need a video to test it on, use a kickstarter.com video - but it works with pretty much everything else as well. ;)

Also - if you look into the corresponding .sh script - I also made it work with youtube links (default link format, not shortlinks) - which requires a slightly different syntax in the .m3u file. Point being - if you want to use it with links that require the urlResolver in Kodi - you might have to tweak the formating of the links - and the youtube example should show you how thats possible.

capmyfire

pulls a screencapture from the FireTV and puts it on the Desktop. Renames the filename, so you can take multiple screencaptures in a row.

FRtrigger

starts xbev and connects it to Kodi. If you have Kodi set up to be able to be controlled from external devices. Look up how thats supposed to be done, on the xbev project site. :)

xbev is a programm that allows you to use your Macs keyboard to control Kodi (play, pause, navigation, text entry... the whole nine yards)

If you start FRtrigger again, it closes the program.

kolog

copies Kodis log file onto your desktop.

firefire, firekodi, and firereboot

Are just simple apps that start Firestarter, Kodi, or reboot the FireTV;

pandorapeek

is an app to control the pandora app from your Mac.

(

homeadb

ATTENTION! Use with caution.

(I am modifying the .bash_history file here - now while thats a file thats common to all Linux and macOS systems - and shouldn't have changed in structure across different version releases, I havent tested it with all macOS versions, and I havent tested it with Sierra yet. Also it is important that you follow the instructions below regarding the empty line thats needed - so there is a small amount of risk that you might have to clear the .bash_history - if it shouldn't work.

You can find information on how to do that here:

http://askubuntu.com/questions/191999/how-to-clear-bash-history-completely )

homeadb is meant to be integrated as part of the macs "Login Items", and is a script that will write the "adb connect IP.ADD.RE.SS" line into your terminal history file every time you boot up your Mac. To use it, first you have to change the IP address in the firetv_ip file in the FireRemote folder, to resemble the IP address of your FireTV. Please make sure, that after the IP address there always is an empty line in the file. This is IMPORTANT.

If you run the script manually - nothing will happen until the next reboot of your mac, because there is only a short window at boot where the terminal history file is writable and hasn't already been pulled into ram. Thats why the homeadb script is meant to be integrated as a "Login Item".

The other reason is, that eventually you might loose the adb connect IP.ADD.RE.SS line from your terminal history, as it only stores a limited number of recent entries. Having this script "repopulate" the line on every boot up usually is enough for it to stay there.

Why do I use the terminal history, and not a hardcoded IP address for the scripts?

Using the terminal history makes it very easy to switch between FireTVs (/Sticks), and use the scripts with another one. You just enter adb connect IP.ADD.RE.SS into the terminal (which is something you usually do anyways -) and all the scripts are set up and ready to go.)

(

usrbin

ATTENTION! Use with caution.

(in this case, because /usr/bin/ is a directory where other important files are situated - so basically, don't go haywire and delete them by accident - apart from that, there is no risk)

In the folder usrbin are two files that you could copy to /usr/bin/ on your mac (dont forget to make them executable with chmod 755). The files are called adb.sh and telnet.sh and basically do the same "history loockup" my scripts to.

adb.sh will look up the last adb connect command you entered into the terminal and enter it again -

telnet.sh will look up the last telnet connect command you entered into the terminal and enter it again -

both are meant to be used as shortcuts. Once you moved them to /usr/bin/ and have made them executable - you can just type in adb.sh or telnet.sh in the terminal (in any directory), to establish a adb or telnet connection to the last device you were conncted to. Both are only meant to be used from the terminal. If you dont use the terminal that often, don't bother with them).

(

miscellaneous folder

in the miscellaneous folder you find a few scripts that probably will not work "out of the box" for you, and are meant for you to be played with, if you are interested what else is possible with a little Applescript codeing.

The webkey apps start/kill webkey (a remote desktop app for android - to be able to remote control Fire TVs from a laptop - but they are coded pretty specific to my needs. :) F.e. after starting the app they go to the third desktop on my mac, where a chrome window is always open, open a new tab, enter the ip:port for the webkey server, enter username and password, press enter --- and so forth... So not necessarily something thats instantly usable by everyone - but you can make it work... :))

The kill webkey app is there to kill webkey after using it, so it doesnt draw cpu cycles in Kodi, while watching videos. :)

The adbwebkey app uses webkey to toggle the FireTVs adb toggle. As webkey doesnt use adb to pipe into the FireTV you can use it to reset the adb toggle. But this one is dependent on having the adb wifi app installed (you find the app name in the script), and being placed on a certain position in the firestarter grid, to be launched -- so again, not something you can use, without at least some modification.

There also are two Kodi configuration examples in there I use, that you could look at, and another script thats just pure overkill... ;) )

Oh - and of course install the Play to Kodi addon for Chrome - if you haven't done so already - it opens up a few more usecases :)*https://chrome.google.com/webstore/detail/play-to-kodi/fncjhcjfnnooidlkijollckpakkebden

Thats it, have fun parsing all this information and using the scripts, if you are a Mac user. :)