Skip to content

Commit 726eb58

Browse files
committed
Added:
- Command to edit configuration file - Repeat URL check N times and exit - Per-URL configuration via JSON configuration file - Run a custom command on change detection Changed: - Configuration is now in JSON format - Combined URL configuration with new JSON configuration format - Intervals are now available in seconds, minutes, hours - Dependencies now include timeout - Desktop notification default is now false - Reorganized code for maintainability and logic Removed: - Support for bash based configuration files - Separate URL file Fixed: - Console logging formatting errors - All paths are now normalized
1 parent af2b139 commit 726eb58

File tree

12 files changed

+807
-438
lines changed

12 files changed

+807
-438
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22
*.tar.gz
3+
test/cache/*

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"request": "launch",
1010
"name": "Bash-Debug (simplest configuration)",
1111
"program": "${file}",
12-
"argsString": " -v -L DEBUG"
12+
"argsString": " -v -L DEBUG -c test/test.json -N 1"
13+
// "argsString": " -v -L DEBUG -c new_test/test.json -N 1 '[5]binarynoir.tech'"
1314
// "argsString": "-L TRACE" // test invalid log level
1415
// "argsString": "--clean" // test clean
1516
}

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"cSpell.words": [
3+
"coreutils",
4+
"grealpath",
35
"mandb",
46
"mktemp",
57
"msys",

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- none
1111

12+
## [1.3.0] - 2024-12-20
13+
14+
### Added
15+
16+
- Command to edit configuration file
17+
- Repeat URL check N times and exit
18+
- Per-URL configuration via JSON configuration file
19+
- Run a custom command on change detection
20+
21+
### Changed
22+
23+
- Configuration is now in JSON format
24+
- Combined URL configuration with new JSON configuration format
25+
- Intervals are now available in seconds, minutes, hours
26+
- Dependencies now include timeout
27+
- Desktop notification default is now false
28+
- Reorganized code for maintainability and logic
29+
30+
### Removed
31+
32+
- Support for bash based configuration files
33+
- Separate URL file
34+
35+
### Fixed
36+
37+
- Console logging formatting errors
38+
- All paths are now normalized
39+
1240
## [1.2.1] - 2024-11-29
1341

1442
### Changed

README.md

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ NoirWatch monitors specified websites for changes and sends notifications. It su
2121
- [x] Send notifications via Pushover
2222
- [x] Send notifications via native desktop notifications (macOS, Linux, Windows)
2323
- [x] Run as a background service
24-
- [ ] Run the check a specific number of times and then exit
24+
- [x] Run a custom script on change detection
25+
- [x] Run the check a specific number of times and then exit
26+
- [x] Robust configuration using JSON which includes per URL options
2527
- [ ] Output change averages for all urls
2628
- [ ] Add averages to notifications
2729
- [ ] Full historical average change report
@@ -32,6 +34,7 @@ NoirWatch monitors specified websites for changes and sends notifications. It su
3234
- Bash 4.0+
3335
- `curl` for fetching website content
3436
- `sed` for HTML content normalization
37+
- `timeout` for custom command files
3538
- `xmllint` for HTML content normalization
3639
- `powershell` for Windows desktop notifications
3740
- `notify-send` for Linux desktop notifications
@@ -291,22 +294,43 @@ NoirWatch uses a configuration file to store default settings. The default locat
291294

292295
### Example Configuration File
293296

294-
```bash
295-
# NoirWatch Configuration File
296-
CACHE_DIR="/tmp/noirwatch_cache"
297-
LOG_FILE="/tmp/noirwatch_cache/noirwatch.log"
298-
CONFIG_FILE="~/.config/noirwatch.conf"
299-
URL_FILE="~/.config/noirwatch_urls.conf"
300-
CHECK_INTERVAL=15
301-
TIMEOUT=5
302-
SYSTEM_NAME="My System"
303-
PUSHOVER_NOTIFICATION=false
304-
PUSHOVER_USER_KEY=""
305-
PUSHOVER_API_TOKEN=""
306-
DESKTOP_NOTIFICATION=true
307-
VERBOSE=false
308-
LOG_LEVEL="INFO"
309-
THRESHOLD=0
297+
```json
298+
{
299+
"configuration": {
300+
"CACHE_DIR": "/tmp/noirwatch_cache",
301+
"LOG_FILE": "/tmp/noirwatch_cache/noirwatch.log",
302+
"CHECK_INTERVAL": "60s",
303+
"TIMEOUT": "5s",
304+
"SYSTEM_NAME": "Test System",
305+
"PUSHOVER_NOTIFICATION": "false",
306+
"PUSHOVER_USER_KEY": "",
307+
"PUSHOVER_API_TOKEN": "",
308+
"DESKTOP_NOTIFICATION": "false",
309+
"VERBOSE": "true",
310+
"LOG_LEVEL": "DEBUG",
311+
"THRESHOLD": "0"
312+
},
313+
"urls": {
314+
"default": [
315+
{
316+
"NAME": "Apple Newsroom",
317+
"URL": "https://www.apple.com/newsroom/",
318+
"TIMEOUT": "5s",
319+
"THRESHOLD": "1",
320+
"UPDATED_CMD": "./test/test_cmd.sh",
321+
"CMD_TIMEOUT": "5s"
322+
},
323+
{
324+
"NAME": "9to5mac Homepage",
325+
"URL": "https://9to5mac.com",
326+
"TIMEOUT": "10s",
327+
"THRESHOLD": "5",
328+
"UPDATED_CMD": "./test/test_cmd.sh",
329+
"CMD_TIMEOUT": "5s"
330+
}
331+
]
332+
}
333+
}
310334
```
311335

312336
## Options
@@ -344,16 +368,12 @@ THRESHOLD=0
344368
- `-o, --output <file>`: Specify a custom log file location.
345369
- `-L, --log-level <level>`: Set the log level (FATAL, ERROR, WARN, INFO, DEBUG).
346370

347-
### URL Management
348-
349-
- `-f, --url-file <file>`: Specify a file containing a list of URLs to monitor.
350-
- `-U, --list-urls`: List all watched URLs.
351-
352371
### Remote Connection Configuration
353372

354373
- `-i, --interval <minutes>`: Set the interval between checks (default is 15 minutes).
355374
- `-T, --timeout <seconds>`: Set the timeout for ping and DNS tests (default: 5 seconds).
356375
- `-H, --threshold <percentage>`: Set the threshold percentage for detecting changes (default: 0%).
376+
- `-U, --list-urls`: List all watched URLs.
357377

358378
### Process Management
359379

@@ -383,21 +403,43 @@ Ensure you have the following installed on your system:
383403

384404
2. **Update the Test Configuration File:** Open the test_noirwatch.conf file in your preferred text editor and ensure it contains the following configuration:
385405

386-
```bash
387-
# NoirWatch Configuration File
388-
CONFIG_FILE="./test_noirwatch.conf"
389-
URL_FILE="./test_urls.conf"
390-
CACHE_DIR="./test_cache"
391-
LOG_FILE="./test_noirwatch.log"
392-
CHECK_INTERVAL=1
393-
TIMEOUT=5
394-
THRESHOLD=1
395-
SYSTEM_NAME="test system"
396-
BACKGROUND=false
397-
PUSHOVER=false
398-
DESKTOP=false
399-
VERBOSE=true
400-
LOG_LEVEL="DEBUG"
406+
```json
407+
{
408+
"configuration": {
409+
"CACHE_DIR": "./test/cache",
410+
"LOG_FILE": "./test/cache/noirwatch.log",
411+
"CHECK_INTERVAL": "60s",
412+
"TIMEOUT": "5s",
413+
"SYSTEM_NAME": "Test System",
414+
"PUSHOVER_NOTIFICATION": "false",
415+
"PUSHOVER_USER_KEY": "",
416+
"PUSHOVER_API_TOKEN": "",
417+
"DESKTOP_NOTIFICATION": "false",
418+
"VERBOSE": "true",
419+
"LOG_LEVEL": "DEBUG",
420+
"THRESHOLD": "0"
421+
},
422+
"urls": {
423+
"default": [
424+
{
425+
"NAME": "Apple Newsroom",
426+
"URL": "https://www.apple.com/newsroom/",
427+
"TIMEOUT": "5s",
428+
"THRESHOLD": "1",
429+
"UPDATED_CMD": "./test/test_cmd.sh",
430+
"CMD_TIMEOUT": "5s"
431+
},
432+
{
433+
"NAME": "9to5mac Homepage",
434+
"URL": "https://9to5mac.com",
435+
"TIMEOUT": "10s",
436+
"THRESHOLD": "5",
437+
"UPDATED_CMD": "./test/test_cmd.sh",
438+
"CMD_TIMEOUT": "5s"
439+
}
440+
]
441+
}
442+
}
401443
```
402444

403445
3. **Update the Test URL File:** Open the test_urls.conf file in your preferred text editor and ensure it contains the following URLs:

0 commit comments

Comments
 (0)