-
-
Save dmitrym0/24ab96c37123c63b9ddac6334829735a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local clockingLog = hs.logger.new("clocking") | |
local clockingMenu = hs.menubar.new() | |
local currentTask = nil | |
local function trim(s) | |
return (s:gsub("^%s*(.-)%s*$", "%1")) | |
end | |
local function eval(sexp, callback) | |
hs.task.new( | |
"/usr/local/bin/emacsclient", | |
function(exitCode, stdOut, stdErr) | |
if exitCode == 0 then | |
callback(trim(stdOut)) | |
end | |
end, | |
{ "--eval", sexp } | |
):start() | |
end | |
local function updateClockingMenu() | |
eval( | |
"(org-clock-is-active)", | |
function(value) | |
if value == "nil" then | |
clockingMenu:setTitle("No Task") | |
else | |
eval( | |
"(org-clock-get-clock-string)", | |
function(value) | |
clockingMenu:setTitle(string.match(value, '"(.+)"')) | |
end | |
) | |
end | |
end | |
) | |
end | |
local function startUpdatingClockingMenu() | |
hs.timer.doEvery(10, updateClockingMenu) | |
end | |
local mod = {} | |
function mod.init() | |
updateClockingMenu() | |
startUpdatingClockingMenu() | |
end | |
return mod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment