File: lalarm.lua

package info (click to toggle)
lsyncd 2.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 484 kB
  • sloc: ansic: 2,640; sh: 81; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-----
-- User configuration file for lsyncd.
--
-- While this example does not do anything it shows
-- how user custom alarms can be now. It will log
-- "Beep!" every 5 seconds.
--
settings.nodaemon = true

local function noAction (inlet)
	-- just discard any events that happes in source dir.
	inlet.discardEvent(inlet.getEvent())
end

-----
-- Adds a watch to some not so large directory for this example.
local in1 = sync{source="/usr/local/etc/", action = noAction }

local function myAlarm(timestamp, extra)
	log("Normal", extra.message)
	spawn(extra.inlet.createBlanketEvent(), "/bin/echo", extra.message)
	alarm(timestamp + 5, myAlarm, extra)
end

alarm(now() + 5, myAlarm, {inlet = in1, message = "Beep"})