diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d71660..f9bc1c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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 )
diff --git a/launchd/CMakeLists.txt b/launchd/CMakeLists.txt
new file mode 100644
index 0000000..c414802
--- /dev/null
+++ b/launchd/CMakeLists.txt
@@ -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
+ DESTINATION
+ lib/grive
+)
diff --git a/launchd/com.github.vitalif.grive2.grive-changes.plist.in b/launchd/com.github.vitalif.grive2.grive-changes.plist.in
new file mode 100644
index 0000000..dbb51f0
--- /dev/null
+++ b/launchd/com.github.vitalif.grive2.grive-changes.plist.in
@@ -0,0 +1,21 @@
+
+
+
+
+ Label
+ com.github.vitalif.grive2.grive-changes
+ ProgramArguments
+
+ @GRIVE_SYNC_SH_BINARY@
+ listen
+ RELATIVE PATH FROM $HOME TO SYNC HERE
+
+ RunAtLoad
+
+ StandardOutPath
+
+ HOME/Library/Logs/grive2.log
+ StandardErrorPath
+ HOME/Library/Logs/grive2.log
+
+
diff --git a/launchd/com.github.vitalif.grive2.grive-timer.plist.in b/launchd/com.github.vitalif.grive2.grive-timer.plist.in
new file mode 100644
index 0000000..7dacab1
--- /dev/null
+++ b/launchd/com.github.vitalif.grive2.grive-timer.plist.in
@@ -0,0 +1,24 @@
+
+
+
+
+ Label
+ com.github.vitalif.grive2.grive-timer
+ ProgramArguments
+
+ @GRIVE_SYNC_SH_BINARY@
+ sync
+ RELATIVE PATH FROM $HOME TO SYNC HERE
+
+ RunAtLoad
+
+ StartInterval
+
+ 300
+ StandardOutPath
+
+ HOME/Library/Logs/grive2.log
+ StandardErrorPath
+ HOME/Library/Logs/grive2.log
+
+