Skip to content

Commit

Permalink
Really simple toggl integration
Browse files Browse the repository at this point in the history
There's probably a better way to do this.
  • Loading branch information
evantravers committed May 21, 2020
1 parent 78cef22 commit 0e31708
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions headspace.lua
Expand Up @@ -12,6 +12,7 @@ local module = {}
local hyper = require('hyper')
local hs_app = require('hs.application')
local fn = require('hs.fnutils')
local toggl = require('toggl')

module.choices = {
{
Expand Down
2 changes: 2 additions & 0 deletions init.lua
Expand Up @@ -94,6 +94,8 @@ local airpods = require 'airpods'
local tabjump = require 'tabjump'
local headspace = require 'headspace'
headspace.start()
local toggl = require('toggl')
toggl.start()

hyper:bind({}, 'r', nil, function() hs.reload() end)

Expand Down
15 changes: 15 additions & 0 deletions toggl.lua
Expand Up @@ -6,6 +6,21 @@ module.get_key = function()
return io.read()
end

module.projects = {
communications = "160553883",
meetings = "160775332",
planning = "160831759"
}

module.start_timer = function(project_id, description)
command = [[curl -v -u ]] .. module.key .. [[:api_token \
-H "Content-Type: application/json" \
-d '{"time_entry":{"description":"]] .. description .. [[","pid":]] .. project_id .. [[,"created_with":"curl"}}' \
-X POST https://www.toggl.com/api/v8/time_entries/start]]

os.execute(command)
end

module.start = function()
module.key = module.get_key()
end
Expand Down

0 comments on commit 0e31708

Please sign in to comment.