Skip to content

Commit

Permalink
Changed directory hierarchi for new python package
Browse files Browse the repository at this point in the history
  • Loading branch information
GulsahKose committed Jan 18, 2015
1 parent a9ecb8b commit 29f4bc7
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 178 deletions.
17 changes: 17 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Language Files

include pebble_remote/data/i18n/ca/LC_MESSAGES/pebble-remote.mo
include pebble_remote/data/i18n/tr/LC_MESSAGES/pebble-remote.mo
include pebble_remote/data/i18n/es/LC_MESSAGES/pebble-remote.mo
include pebble_remote/data/i18n/it/LC_MESSAGES/pebble-remote.mo
include pebble_remote/data/i18n/sl/LC_MESSAGES/pebble-remote.mo

#Manual page

include pebble_remote/data/man/pebble-remote.1.gz

#Mimetype files

include pebble_remote/data/mimetype/pebble-remote
include pebble_remote/data/mimetype/pebble-remote.desktop
include pebble_remote/data/mimetype/pebble-remote.png
28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pebble-remote
=========

This project provides remote control to Libreoffice Impress with Pebble. The directives are all for Ubuntu 14.04, but should be easily adaptable to other platforms.
This project provides remote control to Libreoffice Impress with Pebble. The directives are all for Ubuntu 14.04, but should be easily adaptable to other platforms. Pebble Remote's web site is www.pebbleremote.com


## Installation

Expand All @@ -13,29 +14,13 @@ This project provides remote control to Libreoffice Impress with Pebble. The dir
* `cd lightblue-0.4`
* `sudo python setup.py install`

There are 3 ways to install pebble-remote

* Download debian package from this address[1] and then

* `sudo dpkg -i pebble-remote-2.0.deb`

OR

* Download this project version 2.0 from link[2]

* `tar xvfz pebble-remote-2.0.tar.gz`
* `cd pebble-remote-2.0/libpebble`
* `sudo python setup.py install

OR

* Run this command:

* `pip install pebble-remote`

## Usage

* Disconnect pebble from your phone.
* Disconnect between the pebble by phone.

* Pair pebble and with your computer on bluetooth.

Expand All @@ -48,13 +33,8 @@ OR
* Open with
* Select Pebble Remote:

* Open music app on your pebble. You can control presentation by using up and down buttons on Pebble. Use middle button of Pebble to close presentation.
* Open music app on your pebble. You can remote presentation by using up and down buttons on Pebble. Use middle button of Pebble for exit presentation.

## Pictures

![1](https://github.com/COMU/pebble-remote/blob/master/pictures/Screenshot%202015-01-02%20at%2001.33.35.png)

---
[1] http:https://tinyurl.com/pebble-remote-2-0
[2] https://github.com/COMU/pebble-remote/releases/tag/2.0

File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions libpebble/MANIFEST.in

This file was deleted.

File renamed without changes.
110 changes: 15 additions & 95 deletions libpebble/pebble/p.py → libpebble/p.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,33 @@
import pebble as libpebble
import time
import pexpect
import platform
import tkMessageBox
from pebble_remote import i18n

from Tkinter import *
from pebble import i18n

_ = i18n.language.gettext

MAX_ATTEMPTS = 5

window = Tk()
window.wm_withdraw()
window.geometry("1x1+200+200") #remember its .geometry("WidthxHeight(+or-)X(+or-)Y")

MAX_ATTEMPTS = 5
LightBluePebbleError = libpebble.LightBluePebble.LightBluePebbleError
PebbleError = libpebble.pebble.PebbleError

def cmd_remote_linux(pebble, args):

# odp file's path
def cmd_remote(pebble, args):
path=args.odp_file_path

# Command for start libreoffice impress
runodp = args.app_name+" --impress "+path

# Sets text on pebble smart watch's music app
pebble.set_nowplaying_metadata(_("LibreOffice Remote Control "), _("Next"), _("Previous"))

try:
# Starts libreffice impress.
pexpect.run(runodp)

# Gets window id for send keystrokes
pexpect.run(runodp, timeout=5)
window_id = pexpect.run("xdotool search --sync --onlyvisible --class \"libreoffice\"")

# Sends f5 keystroke to libreoffice impress for view fullscreen
fullscreen = "xdotool key --window " +window_id+" F5"
pexpect.run(fullscreen)
except Exception as e:
pexpect.run(fullscreen)
except Exception:
print _("Something's wrong")
raise e
return False

def libreoffice_event_handler(event):
Expand All @@ -57,7 +44,7 @@ def libreoffice_event_handler(event):
if event == "previous":
pexpect.run(left_click)

if event == "exit":
if event == "exit":
try:
window_ids = pexpect.run("xdotool search --sync --onlyvisible --name \"libreoffice\"").split("\r\n")
window_ids.pop()
Expand All @@ -66,71 +53,16 @@ def libreoffice_event_handler(event):
window_ids[0:2]
altf4_presentation = "xdotool windowactivate --sync "+window_ids[0]+" key --clearmodifiers --delay 100 alt+F4"
altf4_edit = "xdotool windowactivate --sync "+window_ids[1]+" key --clearmodifiers --delay 100 alt+F4"
pexpect.run(altf4_presentation)
pexpect.run(altf4_edit)
pexpect.run(altf4_presentation)
pexpect.run(altf4_edit)
if len(window_ids)<2:
altf4_edit = "xdotool windowactivate --sync "+window_ids[0]+" key --clearmodifiers --delay 100 alt+F4"
pexpect.run(altf4_edit)
pexpect.run("exit_click.sh")
pexpect.run(altf4_edit)
pexpect.run("exit_click.sh")
except Exception as e:
raise e
print event

def music_control_handler(endpoint, resp):
events = {
"PLAYPAUSE": "exit",
"PREVIOUS": "previous",
"NEXT": "next"
}

libreoffice_event_handler(events[resp])

print _("waiting for events")
while True:
try:
pebble.register_endpoint("MUSIC_CONTROL", music_control_handler)
time.sleep(5)
except LightBluePebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 7"
raise e
raise KeyboardInterrupt
except PebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 8"
raise e
raise KeyboardInterrupt
except KeyboardInterrupt:
return


def cmd_remote_darwin(pebble, args):
path=args.odp_file_path
runodp = args.app_name+" --impress "+path
pebble.set_nowplaying_metadata(_("LibreOffice Remote Control "), _("Next"), _("Previous"))

try:
pexpect.run(runodp)
window_id = pexpect.run("xdotool search --sync --onlyvisible --class \"libreoffice\"")
fullscreen = "xdotool key --window " +window_id+" F5"
pexpect.run(fullscreen)
except Exception:
print _("Something's wrong")
return False

def libreoffice_event_handler(event):
right_click = "xdotool key --window "+ window_id + "Right"
left_click = "xdotool key --window "+ window_id + "Left"
exit_click= "bash /usr/lib/python2.7/pebble/exit_click"

if event == "next":
pexpect.run(right_click)

if event == "previous":
pexpect.run(left_click)

if event == "exit":
pexpect.run(exit_click)

def music_control_handler(endpoint, resp):
events = {
Expand All @@ -148,21 +80,15 @@ def music_control_handler(endpoint, resp):
time.sleep(5)
except LightBluePebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 0"
raise e
raise KeyboardInterrupt
except PebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 1"
raise e
raise KeyboardInterrupt
except KeyboardInterrupt:
return





def main():
parser = argparse.ArgumentParser(description='a utility belt for pebble development')
parser.add_argument('--pebble_id', type=str, help='the last 4 digits of the target Pebble\'s MAC address. \nNOTE: if \
Expand All @@ -177,10 +103,7 @@ def main():
remote_parser = subparsers.add_parser('remote', help='control LibreOffice Impress app with music app on Pebble')
remote_parser.add_argument('app_name', type=str, help='title of application to be controlled')
remote_parser.add_argument('odp_file_path', type=str, help='path for libreoffice impress presentation file')
if platform.system() == 'Linux':
remote_parser.set_defaults(func=cmd_remote_linux)
else:
remote_parser.set_defaults(func=cmd_remote_darwin)
remote_parser.set_defaults(func=cmd_remote)


args = parser.parse_args()
Expand All @@ -195,12 +118,11 @@ def main():
pebble_id = os.environ["PEBBLE_ID"]
pebble = libpebble.Pebble(pebble_id, args.lightblue, args.pair)
break
except LightBluePebbleError as e:
except LightBluePebbleError as e:
tkMessageBox.showerror(title="Error", message=_("Bluetooth connection error"), parent=window)
raise KeyboardInterrupt
except PebbleError as e:
except PebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 3"
raise e
raise KeyboardInterrupt
except:
Expand All @@ -211,12 +133,10 @@ def main():
args.func(pebble, args)
except LightBluePebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 4"
raise e
raise KeyboardInterrupt
except PebbleError as e:
tkMessageBox.showerror(title="Error", message=e._message, parent=window)
print "Not discovered 5"
raise e
raise KeyboardInterrupt
except Exception as e:
Expand Down
File renamed without changes.
33 changes: 0 additions & 33 deletions libpebble/setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions pebble_remote/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#__init__.py
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# the License at http:https://www.apache.org/licenses/LICENSE-2.0 .
#
[Desktop Entry]
Version=1.0
Version=2.0
Terminal=false
Icon=/usr/share/pixmaps/pebble-remote.png
Type=Application
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 4 additions & 9 deletions libpebble/pebble/i18n.py → pebble_remote/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os, sys
import locale
import gettext
import platform

# Change this variable to your app name!
# The translation files will be under
Expand All @@ -21,14 +20,10 @@
# (on desktop is usually LANGUAGES)
DEFAULT_LANGUAGES = os.environ.get('LANG', '').split('.')
DEFAULT_LANGUAGES += ['en_US']

if platform.system() == 'Linux':
lc, encoding = locale.getdefaultlocale()
if lc:
languages = [lc]
else:
lc ='en'
encoding = 'UTF-8'

lc, encoding = locale.getdefaultlocale()
if lc:
languages = [lc]

# Concat all languages (env + default locale),
# and here we have the languages and location of the translations
Expand Down
Binary file removed pictures/IMG_20150117_141742.jpg
Binary file not shown.
Binary file removed pictures/pebble-screenshot_2015-01-07_07-37-09.png
Binary file not shown.
Binary file removed pictures/pebble-screenshot_2015-01-07_07-41-15.png
Binary file not shown.
Binary file removed pictures/pebble-screenshot_2015-01-07_07-42-25.png
Binary file not shown.
Loading

0 comments on commit 29f4bc7

Please sign in to comment.