Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 6353e24

Browse files
committed
hsmodule: Execute initialization script via zsh instead of running them ourselves
1 parent 06695e8 commit 6353e24

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

LESmain.lua

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@ if testfirstrun() == false then -- stuff to do when you start the program for th
6262
hFile:close()
6363
end
6464

65-
os.execute([[mkdir -p ~/.les/resources]]) -- creates the resources folder
66-
os.execute([[echo '' >~/.les/resources/firstrun.txt]]) -- making sure the section of this script doesn't trigger twice
67-
os.execute([[echo '' >~/.les/resources/strict.txt]]) -- enables strict time by default
68-
os.execute([[cp "]] .. resourcePath .. [[/assets/settings.ini" ~/.les/]]) -- extracting config defaults from the .Hidden directory embedded inside the modified hammerspoon .app package.
69-
os.execute([[cp "]] .. resourcePath .. [[/assets/menuconfig.ini" ~/.les/]])
70-
os.execute([[cp "]] .. resourcePath .. [[/assets/readmejingle.wav" ~/.les/resources/]])
65+
function executeusingshell(proc, arg1, arg2)
66+
arg1 = arg1:gsub(" ", "\\ ")
67+
arg2 = arg2:gsub(" ", "\\ ")
68+
copyExecInstruction = proc .. " " .. arg1 .. " " .. arg2
69+
print("Executing " .. copyExecInstruction .. " using zsh")
70+
os.execute("zsh -c \"" .. copyExecInstruction .. "\"")
71+
end
72+
73+
os.execute("zsh -c \"mkdir -p ~/.les/resources\"") -- creates the resources folder
74+
os.execute("zsh -c \"echo '' >~/.les/resources/firstrun.txt\"") -- making sure the section of this script doesn't trigger twice
75+
os.execute("zsh -c \"echo '' >~/.les/resources/strict.txt\"") -- enables strict time by default
76+
executeusingshell("cp", resourcePath .. "/assets/settings.ini", "~/.les/")
77+
executeusingshell("cp", resourcePath .. "/assets/menuconfig.ini", "~/.les/")
78+
executeusingshell("cp", resourcePath .. "/assets/readmejingle.ini", "~/.les/resources/")
7179

7280
b, t, o = hs.osascript.applescript([[tell application "System Events" to display dialog "You're all set! Would you like to set LES to launch on login? (this can be changed later)" buttons {"Yes", "No"} default button "No" with title "Live Enhancement Suite" with icon POSIX file ]] .. iconPath)
7381
-- I'm using applescript to create dialog boxes, becuase it gives me more options about how to present them. I only keep the user's "option", the other variables are basically always cleared right after to save memory.

0 commit comments

Comments
 (0)