Gentoo Archives: gentoo-user

From: Wang Xuerui <idontknw.wang@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] pop up windows with text message
Date: Thu, 11 Jul 2013 04:47:34
Message-Id: CABK5mSZHc2Nok78-eu4xFaOpDBpN6_SvLy7t-ZdRi4zYP=VjZA@mail.gmail.com
In Reply to: Re: [gentoo-user] pop up windows with text message by Joseph
1 2013/7/11 Joseph <syscon780@×××××.com>:
2 > I just want to monitor one file in a directory.
3 > I usually copy the file over the network to another computer (same file
4 > name) I'll overwrite the file.
5 >
6 > Once I copy the file, the system should notify a use that new file exist (a
7 > message pop-up). If the use closes the message and will not open the file,
8 > after few ours I want to remind the user that the file has not been open
9 > yet.
10 >
11 > Will it be very complicated to write a bash script like this?
12
13 I once wrote a small Python script to help me with automating
14 Git-based deployments, but it's simple enough to be suitable for a
15 variety of use cases:
16
17 https://github.com/xen0n/touchmon
18
19 It allows you to specify a hook for each file observed, just make sure
20 the watched file exists before starting the watcher (a known
21 limitation). Inside the hook script (any language is OK) you can
22 pop-up a dialog and store a timestamp somewhere, if the user has the
23 file opened for him/her. Then for the periodic notofication, maybe a
24 cronjob would suffice? Simply check the stored timestamp with the
25 current time. If polling is not what you want, you can extend the
26 inotify part to also monitor events like IN_OPEN or IN_ACCESS and
27 manipulate your timer accordingly. But be aware of false positives
28 like some background daemon accessing the file, as ALL opens and reads
29 are watched.
30
31 Hope this helps~