Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macOS launchd files for automatic syncing #330

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@ if ( HAVE_SYSTEMD )
add_subdirectory( systemd )
endif( HAVE_SYSTEMD )

find_program(
HAVE_LAUNCHD launchd
PATHS /sbin
NO_DEFAULT_PATH
)
if ( HAVE_LAUNCHD )
add_subdirectory( launchd )
endif( HAVE_LAUNCHD )

add_subdirectory( libgrive )
add_subdirectory( grive )
27 changes: 27 additions & 0 deletions launchd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
SET(GRIVE_SYNC_SH_BINARY "${CMAKE_INSTALL_PREFIX}/lib/grive/grive-sync.sh")

CONFIGURE_FILE(
com.github.vitalif.grive2.grive-changes.plist.in
com.github.vitalif.grive2.grive-changes.plist
@ONLY
)
CONFIGURE_FILE(
com.github.vitalif.grive2.grive-timer.plist.in
com.github.vitalif.grive2.grive-timer.plist
@ONLY
)

install(
FILES
${CMAKE_BINARY_DIR}/launchd/com.github.vitalif.grive2.grive-changes.plist
${CMAKE_BINARY_DIR}/launchd/com.github.vitalif.grive2.grive-timer.plist
DESTINATION
lib/launchd
)

install(
PROGRAMS
../systemd/grive-sync.sh
Tatsh marked this conversation as resolved.
Show resolved Hide resolved
DESTINATION
lib/grive
)
21 changes: 21 additions & 0 deletions launchd/com.github.vitalif.grive2.grive-changes.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.vitalif.grive2.grive-changes</string>
<key>ProgramArguments</key>
<array>
<string>@GRIVE_SYNC_SH_BINARY@</string>
<string>listen</string>
<string>RELATIVE PATH FROM $HOME TO SYNC HERE</string>
</array>
<key>RunAtLoad</key>
<true />
<key>StandardOutPath</key>
<!-- Change HOME below to your $HOME path, e.g. /Users/name -->
<string>HOME/Library/Logs/grive2.log</string>
<key>StandardErrorPath</key>
<string>HOME/Library/Logs/grive2.log</string>
</dict>
</plist>
24 changes: 24 additions & 0 deletions launchd/com.github.vitalif.grive2.grive-timer.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.vitalif.grive2.grive-timer</string>
<key>ProgramArguments</key>
<array>
<string>@GRIVE_SYNC_SH_BINARY@</string>
<string>sync</string>
<string>RELATIVE PATH FROM $HOME TO SYNC HERE</string>
</array>
<key>RunAtLoad</key>
<true />
<key>StartInterval</key>
<!-- Every 5 minutes -->
<integer>300</integer>
<key>StandardOutPath</key>
<!-- Change HOME below to your $HOME path, e.g. /Users/name -->
<string>HOME/Library/Logs/grive2.log</string>
<key>StandardErrorPath</key>
<string>HOME/Library/Logs/grive2.log</string>
</dict>
</plist>