Skip to content

Commit

Permalink
Added Apache OpenOffice support
Browse files Browse the repository at this point in the history
  • Loading branch information
GulsahKose committed Jan 24, 2015
1 parent 271faea commit 621497b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions libpebble/p.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,32 @@

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

try:
pexpect.run(runodp, timeout=5)
window_id = pexpect.run("xdotool search --sync --onlyvisible --class \"libreoffice\"")
fullscreen = "xdotool key --window " +window_id+" F5"
window_id = pexpect.run("xdotool search --sync --onlyvisible --class \"libreoffice\"", timeout=5)
if window_id == "":
productname = "openoffice"
window_id = pexpect.run("xdotool search --sync --onlyvisible --class \"openoffice\"").split('\r\n')
fullscreen = "xdotool key --window " +window_id[0]+" F5"
else:
productname = "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"
if productname == "libreoffice":
right_click = "xdotool key --window "+ window_id + " Right"
left_click = "xdotool key --window "+ window_id + " Left"
else:
window_ids = pexpect.run("xdotool search --sync --onlyvisible --class \"openoffice\"").split('\r\n')
right_click = "xdotool key --window "+ window_ids[1] + " Right"
left_click = "xdotool key --window "+ window_ids[1] + " Left"

if event == "next":
pexpect.run(right_click)
Expand All @@ -46,7 +57,10 @@ def libreoffice_event_handler(event):

if event == "exit":
try:
window_ids = pexpect.run("xdotool search --sync --onlyvisible --name \"libreoffice\"").split("\r\n")
if productname == "libreoffice":
window_ids = pexpect.run("xdotool search --sync --onlyvisible --name \"libreoffice\"").split("\r\n")
else:
window_ids = pexpect.run("xdotool search --sync --onlyvisible --name \"openoffice\"").split("\r\n")
window_ids.pop()
window_ids.reverse()
if len(window_ids)>=2:
Expand All @@ -58,6 +72,7 @@ def libreoffice_event_handler(event):
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")
except Exception as e:
raise e
Expand Down

0 comments on commit 621497b

Please sign in to comment.