FolderActions
A simple tool for linux which allows to run scripts on fs changes
Instalation
go get -u
go build -o main
sudo mv main /bin/fslistener
sudo chmod +x /bin/fslistener
Autocompletion
ZSH
fslistener --completion-script-zsh >> ~/.zshrc
Usage
usage: fslistener [<flags>]
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-d, --dir=DIR ... The list of directories to watch
-v, --verbose Increase debug message
-q, --quiet Don't output messages
-a, --allow-unsafe Allow special characters in path and filename
-s, --scripdir=SCRIPDIR The folder containing the scripts
Example:
fslistener --scripdir `pwd`/scripts --dir /dev/ --dir /tmp/ -v
If a file inside /dev/ or /tmp/ gets created or deleted, a script inside the ./scripts folder will be called.
Let's assume the file /dev/sdc gets created (because you inserted a USB drive), the following script will be called:
./scripts/_dev_create.sh
with the argument /dev/sdc
Env
FA_SCRIPT_PATH
- sets the default path containing the scripts
-s/--scriptdir overwrites this value
Scripts
If a file in a folder changes (gets created or removed) a script is called by this tool. The path/name of this script is:
$FA_SCRIPT_PATH
/_real_path_of_changed_file_from_root_MODE.sh
For example if a file named sda inside the dir /dev/ was created, following script would be called:
$FA_SCRIPT_PATH
/_dev_create.sh
The first argument is the name of the changed file