lib/journal-cli/checkin.rb in journal-cli-1.0.35 vs lib/journal-cli/checkin.rb in journal-cli-1.0.36
- old
+ new
@@ -91,16 +91,15 @@
## Launch Day One and quit if it wasn't running
##
def launch_day_one
# Launch Day One to ensure database is up-to-date
# test if Day One is open
- running = !`ps ax | grep "/MacOS/Day One" | grep -v grep`.strip.empty?
+ @running = !`ps ax | grep "/MacOS/Day One" | grep -v grep`.strip.empty?
# -g do not bring app to foreground
# -j launch hidden
`/usr/bin/open -gj -a "Day One"`
- # quit if it wasn't running
- `osascript -e 'tell app "Day One" to quit'` if !running
+ sleep 3
end
##
## Save journal entry to Day One using the command line tool
##
@@ -117,9 +116,12 @@
cmd << %(-j "#{@journal["journal"]}") if @journal.key?("journal")
cmd << %(-t #{@journal["tags"].join(" ")}) if @journal.key?("tags")
cmd << %(-date "#{@date.strftime("%Y-%m-%d %I:%M %p")}")
`echo #{Shellwords.escape(to_markdown(yaml: false, title: true))} | #{cmd.join(" ")} -- new`
Journal.notify("{bg}Entered one entry into Day One")
+
+ # quit if it wasn't running
+ `osascript -e 'tell app "Day One" to quit'` if !@running
end
##
## Save entry to an existing Markdown file
##