Skip to content

Commit

Permalink
Merge pull request #6 from visini/remove-desk-handler
Browse files Browse the repository at this point in the history
Remove desk handler
  • Loading branch information
visini authored Apr 25, 2023
2 parents 43a7446 + be85e66 commit a1536cb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 292 deletions.
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ VERSION_SET := 1
endif

install:
@echo "If pip error, export the below flags (NOT via Makefile, since every line has separate shell! run directly)"
#export SYSTEM_VERSION_COMPAT=1
#export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib"
#export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include"
#export LDFLAGS="${LDFLAGS} -L/usr/local/opt/sqlite/lib"
#export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/sqlite/include"
#export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig"
#export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/sqlite/lib/pkgconfig"
poetry install
dev:
poetry run python main.py
Expand All @@ -26,9 +18,9 @@ ifeq ($(VERSION_SET),1)
poetry version $(VERSION)
git add pyproject.toml
git commit -m "Release $(VERSION)"
git push
git push
cd dist && zip -r "$(APP_NAME).app.zip" "$(APP_NAME).app"
gh release create $(VERSION) 'dist/$(APP_NAME).app.zip#$(APP_NAME).app.zip'
else
$(error VERSION not defined - use like this: make release VERSION=...)
endif
endif
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Menu bar utility app (macOS) for adding [Timeboxing](https://en.wikipedia.org/wi

![Screenshot](screenshot.png)

Integrated with a _Raspberry Pi-/Arduino-powered standing desk_ for setting a new desk height after the current task has been completed. See implementation details in [visini/desk](https://github.com/visini/desk) and [visini/stand](https://github.com/visini/stand).

See `Makefile` for how to install, debug, build, and release. Or download the [latest release](https://github.com/visini/timebox/releases).

Note: Since April 14, 2023, Things 3 stores data in a unique location - you will have to build the app after setting the proper path in `main.py` via `THINGS_SQLITE_PATH`.

Download using GitHub CLI:

```shell
Expand Down
26 changes: 4 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@
import sqlite3
import os

from ssh_desk_handler import SSHDeskHandler

SEC_TO_MIN = 60
THINGS_SQLITE_PATH = "~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/ThingsData-4R6L5/Things Database.thingsdatabase/main.sqlite"

def timez():
return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime())


def get_things_today_tasks(index=0, complete_task=False):
conn = sqlite3.connect(
os.path.expanduser(
"~/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/Things Database.thingsdatabase/main.sqlite"
)
)
conn = sqlite3.connect(os.path.expanduser(THINGS_SQLITE_PATH))
sql = (
"SELECT\n"
" TAG.title,\n"
Expand All @@ -29,7 +22,6 @@ def get_things_today_tasks(index=0, complete_task=False):
" LEFT JOIN TMTag TAG ON TAGS.tags = TAG.uuid\n"
" LEFT OUTER JOIN TMTask PROJECT ON TASK.project = PROJECT.uuid\n"
" LEFT OUTER JOIN TMArea AREA ON TASK.area = AREA.uuid\n"
" LEFT OUTER JOIN TMTask HEADING ON TASK.actionGroup = HEADING.uuid\n"
" WHERE TASK.trashed = 0 AND TASK.status = 0 AND TASK.type = 0 AND TAG.title IS NOT NULL\n"
" AND TASK.start = 1\n"
" AND TASK.startdate is NOT NULL\n"
Expand Down Expand Up @@ -78,20 +70,13 @@ def __init__(self, timer_interval=1):
self.timer.stop() # timer running when initialized
self.timer.count = 0
self.app = rumps.App("Timebox", "🥊")
self.desk_handler = SSHDeskHandler()
self.interval = SEC_TO_MIN
self.interval = 60
self.current_things_task_url = None
self.start_pause_button = rumps.MenuItem(
title="Start Timer",
callback=lambda _: self.start_timer(_, self.interval),
key="s",
)
self.toggle_sit_stand_button = rumps.MenuItem(
title="Toggle Sit/Stand",
callback=lambda sender: self.toggle_button(sender),
key="t",
)
self.toggle_sit_stand_button.state = True
self.stop_button = rumps.MenuItem(title="Stop Timer", callback=None)
self.buttons = {}
self.buttons_callback = {}
Expand All @@ -114,7 +99,6 @@ def __init__(self, timer_interval=1):
self.app.menu = [
self.start_pause_button,
self.sync_button,
self.toggle_sit_stand_button,
None,
self.sum_menu_item,
# *self.things_buttons.values(),
Expand Down Expand Up @@ -168,7 +152,7 @@ def run(self):
def set_mins(self, sender, interval, task_url):
for btn in [*self.things_buttons.values(), *self.buttons.values()]:
if sender.title == btn.title:
self.interval = interval * SEC_TO_MIN
self.interval = interval * 60
cleaned_title = " ".join(sender.title.split()[:-2])
if task_url is not None:
self.menu_title = " → " + cleaned_title
Expand Down Expand Up @@ -215,8 +199,6 @@ def on_tick(self, sender):
shlex.split("open '" + self.current_things_task_url + "'")
)
self.current_things_task_url = None
if self.toggle_sit_stand_button.state == True:
self.desk_handler.toggle()
self.stop_timer(sender)
self.stop_button.set_callback(None)
self.sync_data()
Expand Down
Loading

0 comments on commit a1536cb

Please sign in to comment.