Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Do until loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandoks committed Oct 23, 2023
1 parent ac1da50 commit c2852a3
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions selfcontrol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,20 @@ local function isSelfControlRunning()
end

local function insertPassword()
local prompt_timer
prompt_timer = hs.timer.new(0.1, function()
hs.timer.doUntil(isSelfControlRunning, function()
local security_prompt = hs.application.get("SecurityAgent")
if security_prompt then
local password =
hs.execute("security find-generic-password -a $(whoami) -s hammer-control -w")

hs.eventtap.keyStrokes(password, security_prompt)
local press_ok = [[
tell application "System Events"
click button "Install Helper" of window 1 of application process "SecurityAgent"
end tell
]]
hs.osascript.applescript(press_ok)

if isSelfControlRunning() then
prompt_timer:stop()
return
end
end
end)
prompt_timer:start()
end, 0.1)
end

local function sendToBackCallback(app_name, event_type, app_object)
Expand Down

0 comments on commit c2852a3

Please sign in to comment.