ScR4tCh / timebox

Divoom timebox CLI utility
148 stars 31 forks source link

Guide to running on macOS - 10.15 RC & 10.14 (Mojave) #16

Open atchoo78 opened 5 years ago

atchoo78 commented 5 years ago

By trial and error (lots of both 🤯) I have now managed to assemble a complete guide for running the timebox CLI on macOS in a virtual enviroment with Python 2.7.

For this guide, I'll just assume that you clone this repository or extract its zip to ~/timebox (/Users/yourusername/timebox). Here we go:

First, check that pip is up to date:

python -m pip install --user --upgrade pip
  1. Install virtualenv. As far as I know, all Macs ship with easy_install, so

    sudo easy_install virtualenv
  2. From your home dir:

    git clone https://github.com/ScR4tCh/timebox.git 

    or extract the zip and copy/move its contents to ~/timebox

    cd ~/timebox
  3. Create the virtual enviroment and activate it:

    virtualenv ~/timebox // or simply "virtualenv timebox"
    source bin/activate
  4. Install (some of) the dependencies

    sudo -H pip install -r requirements.txt
    cd ~/timebox (cd ..)

    Now for the tedious part.

  5. You'll need the "osx" folder from the PyBluez rep later on, so we'll start with cloning it and install the fundamentals.

    git clone https://github.com/karulis/pybluez.git
    cd pybluez
    python setup.py install
  6. (Important!) Use the force and pull off some jedi mind tricks on macOS:

    cd ~/timebox 
    pip install --upgrade git+https://github.com/karulis/pybluez.git#egg=pybluez
    sudo -H cp -R pybluez/osx pybluez/lightblue
    sudo -H cp -R pybluez/lightblue lib/python2.7/site-packages/
  7. Clean up (delete the temporary pybluez folder)

    rm -R pybluez
  8. Do a quick test to check if Bluetooth is working. Save the following to a new .py file and name it bluetooth-test.py. Run the test with python bluetooth-test.py

    
    # simple inquiry example
    import bluetooth
    import sys

nearby_devices = bluetooth.discover_devices(lookup_names=True) print("found %d devices" % len(nearby_devices))

for addr, name in nearby_devices: print(" %s - %s" % (addr, name))


If there's no error messages, and you are presented a Bluetooth device status report, Bluetooth and Python 2 are now best friends, and you are hereby a certified Jedi. The rest is in the help function and the README (Thanks! @ScR4tCh )

Example:

 ```bash
cd timebox
python timebox.py clock --color #FF0000

Hope this helps anyone. I'm off to see where I can take this further 🙂

Best regards,

Andreas

atchoo78 commented 5 years ago

bluetooth-test.zip

atchoo78 commented 5 years ago

I also forgot to mention that I commented out https://github.com/ScR4tCh/timebox/blob/7c1695353da64a5f91cf02a1bb7d35a1392e7280/timebox/timebox.py#L57 It kind of works, but it's temporary, and I'll have to find a way around that later.