Sparky Beep Provides beep support for a few services of server edition.
Sparky Beep offers audible notifications when selected system services start, stop or restart. The repository is arranged in a few key directories:
README.mdintroduces Sparky Beep and lists required packages and installation commands.install.shcopies or removes init scripts, systemd service files and the main helper script. Run it withuninstallto remove everything.bin/holdssparky-beep-run, a helper script that verifies the beep services are active and starts them if needed.init.d/contains SysV init scripts such asbeep_netdata,beep_samba,beep_sys,beep_webminandsparky-beep. Each of these definesbeepcommands for different service states. For example:
case "$1" in
start)
beep -f 1000 -n -f 1500 -n -f 600 ...
;;
stop)
beep -f 100 -r 2 -l 10 -n -f 50 ...
;;
restart)
beep -f 100 -r 2 -l 10 ... ; beep -f 1000 ...
;;
esac
system/provides systemd unit files that link the beep scripts to services likenetdata.service,samba-ad-dc.service,ssh.serviceandwebmin.- Additional metadata includes
CHANGELOG,LICENSEand Debian-style copyright information.
- The goal is to give audible feedback ("beeps") when services change state.
- Installation copies the scripts into system directories while uninstallation removes them.
sparky-beep-runcan be triggered from an init script and keeps the beep services enabled and running.
Sparky Beep now includes a musical notation composer that lets you create melodic beeps using standard musical notation instead of raw frequencies!
Features:
- ๐ต Musical notation support - Write
C4q D4q E4qinstead ofbeep -f 261 -l 500 -n -f 293... - ๐ผ 8 octaves - Full range from C0 to B8 (88 notes)
- ๐น All chromatic notes - Sharps (#) and flats (b) supported
- โฑ๏ธ Tempo control - Set BPM from 40-240
- ๐ Ternary beep mode - Optional smoother sounds using ternary logic (requires compilation)
Quick Examples:
# Play C major scale
sparky-beep-compose -s "C4q D4q E4q F4q G4q A4q B4q C5q" -p
# Play Happy Birthday
sparky-beep-compose compositions/happy-birthday.beepmusic -p
# Custom tempo
sparky-beep-compose -s "tempo:140 C4h E4h G4h C5w" -pIncluded Compositions:
- C Major Scale
- Happy Birthday
- Twinkle Twinkle Little Star
- Ode to Joy (Beethoven)
- Star Wars Theme
- Super Mario Bros Theme
- Startup/Shutdown fanfares
- Alert/notification sounds
Ternary Beep Engine (Advanced):
For smoother, more musical sounds, compile the optional ternary beep engine:
make # Compile tbeep
sudo make install # Install ternary beep engine
# Enable ternary mode in config
sudo nano /etc/sparky-beep/beep.conf
# Change: BEEP_MODE="ternary"
# Test
sudo tbeep -f 440 -l 500What is Ternary Beep?
Standard beep uses binary states (ON/OFF), creating harsh square waves. Ternary beep uses 3 states {-1, 0, +1}, approximating sine waves for smoother, more pleasant sounds!
Binary: โโโ โโโ โโโ (harsh, buzzy)
Ternary: โญโโฎ (smooth, musical)
โญโโฏ โฐโโฎ
โโฏ โฐโ
Documentation:
- COMPOSER.md - Complete composer documentation and examples
- config/beep.conf - Configuration file for beep mode and settings
- compositions/ - Pre-made musical compositions
- lib/notes.sh - Musical note library with all frequencies
Sparky Beep now includes powerful configuration tools for easy management:
๐ฅ๏ธ TUI (Text User Interface):
sudo sparky-beep-config-tui # Launch text interface- Works in terminal/SSH sessions
- Uses dialog/whiptail
- Full keyboard navigation
- Service selection, tune management, scheduling
๐จ GUI (Graphical User Interface):
sparky-beep-config-gui # Launch graphical interface- Works in any desktop environment
- Uses zenity/yad for compatibility
- Point-and-click configuration
- Preview sounds before applying
โก Unified CLI:
sparky-beep-config # Auto-detect TUI/GUI
sparky-beep-config --list # List available services
sparky-beep-config --enable ssh # Enable beep for SSH
sparky-beep-config --disable netdata # Disable beep for NetData
sparky-beep-config --test ssh start # Test SSH start beepFeatures:
- ๐ฏ Service Discovery - Automatically finds compatible services
- ๐ต Tune Management - Assign melodies to each service event
- โฐ Scheduling - Configure quiet hours and time-based rules
- ๐ Multi-language - All interfaces support 26 languages
- ๐พ Configuration Backup - Automatic backup before changes
- โ Service Status - Real-time service monitoring
Configuration File:
- Location:
/etc/sparky-beep/beep.conf - User config:
~/.config/sparky-beep/beep.conf - Automatic creation with sensible defaults
- Human-readable INI format
Sparky Beep supports 26 languages with automatic detection based on your
system's LANG environment variable - Complete Debian i18n coverage!
| Language | Native Name | Code |
|---|---|---|
| Arabic | ุงูุนุฑุจูุฉ | ar |
| Catalan | Catalร | ca |
| Czech | ฤeลกtina | cs |
| Danish | Dansk | da |
| German | Deutsch | de |
| Greek | ฮฮปฮปฮทฮฝฮนฮบฮฌ | el |
| English | English | en (default) |
| Spanish | Espaรฑol | es |
| Finnish | Suomi | fi |
| French | Franรงais | fr |
| Hungarian | Magyar | hu |
| Italian | Italiano | it |
| Japanese | ๆฅๆฌ่ช | ja |
| Korean | ํ๊ตญ์ด | ko |
| Dutch | Nederlands | nl |
| Polish | Polski | pl |
| Portuguese | Portuguรชs | pt |
| Portuguese (Brazil) | Portuguรชs do Brasil | pt_BR |
| Romanian | Romรขnฤ | ro |
| Russian | ะ ัััะบะธะน | ru |
| Slovak | Slovenฤina | sk |
| Swedish | Svenska | sv |
| Turkish | Tรผrkรงe | tr |
| Ukrainian | ะฃะบัะฐัะฝััะบะฐ | uk |
| Chinese (Simplified) | ็ฎไฝไธญๆ | zh_CN |
| Chinese (Traditional) | ็น้ซไธญๆ | zh_TW |
Usage:
# Change language by setting LANG environment variable
export LANG=de_DE.UTF-8 # Use German
./bin/sparky-beep-run
export LANG=fr_FR.UTF-8 # Use French
/etc/init.d/beep_netdata startTranslation files: locale/*.lang
Documentation: See locale/LANGUAGES.md for details on adding new languages
- Inspect
bin/sparky-beep-runto see how it usessystemctlto check service state. - Review the init scripts in
init.d/to adjust beep sequences or add new services. - Learn how systemd unit files are installed and enabled with
systemctl enableandsystemctl start. - This README lists the dependencies and quick steps for installation or removal.
Sparky Beep uses Bats (Bash Automated Testing System) for testing. To run the test suite:
# Install bats if not already installed
sudo apt-get install bats
# Run all tests
bats tests/
# Run specific test file
bats tests/sparky-beep-run.bats
bats tests/init-usage.batsThe project now has ~85% test coverage across core features and ~35% overall (up from ~15%):
Test Files:
tests/init-usage.bats- Validates usage messages match script names (1 test)tests/sparky-beep-run.bats- Tests basic service activation for beep_sys (1 test)tests/sparky-beep-run-extended.bats- Comprehensive service tests (16 tests)tests/init-scripts.bats- Init script execution tests (26 tests)tests/install.bats- Installation/uninstallation tests (15 tests)tests/composer.bats- Composer and musical notation tests (27 tests)tests/libraries.bats- Library function tests (42 tests) โจ NEWtests/config-tools.bats- Configuration tool tests (30 tests) โจ NEWtests/ui-tools.bats- TUI/GUI interface tests (38 tests) โจ NEWtests/tbeep.bats- Ternary beep engine tests (32 tests) โจ NEWtests/helpers.bash- Shared test infrastructure
Total: 228 tests (increased from 86 tests) ๐
Test Coverage by Component:
| Component | Lines | Tests | Coverage | Status |
|---|---|---|---|---|
| sparky-beep-run | 108 | 17 | ~85% | โ Good |
| init.d scripts (5 files) | ~170 | 27 | ~70% | โ Good |
| install.sh | 35 | 15 | ~80% | โ Good |
| sparky-beep-compose | ~400 | 27 | ~75% | โ Good |
| lib/notes.sh | ~600 | 10 | ~50% | |
| lib/config.sh | ~11,000 | 10 | ~30% | |
| lib/discovery.sh | ~10,000 | 10 | ~30% | |
| lib/scheduler.sh | ~10,000 | 6 | ~25% | |
| lib/tunes.sh | ~10,000 | 2 | ~10% | |
| locale/i18n.sh | ~1,000 | 10 | ~40% | |
| config/beep.conf | ~150 | 5 | N/A | โ Good |
| TUI/GUI tools (7 files) | ~95,000 | 68 | ~20% | |
| bin/tbeep.c | ~450 | 32 | ~60% | |
| systemd services (4 files) | ~60 | 0 | 0% | |
| Core Features Total | ~1,463 | 86 | ~85% | โ Good |
| All Components Total | ~138,923 | 228 | ~35% |
Now tested (sparky-beep-run): โ
- โ beep_netdata service activation โจ NEW
- โ
beep_samba service activation with complex logic โจ NEW
- โ smbd masking logic โจ NEW
- โ samba-ad-dc unmasking logic โจ NEW
- โ beep_webmin service activation โจ NEW
- โ Service enabling logic (all services) โจ NEW
- โ Package detection when package is NOT installed โจ NEW
- โ Service already active (should skip activation) โจ NEW
- โ Service already enabled (should skip enabling) โจ NEW
- โ Log file creation โจ NEW
- โ Multiple services activation โจ NEW
- โ Service activation failure reporting โจ NEW
Now tested (init scripts): โ
- โ
startaction execution for all scripts โจ NEW - โ
stopaction execution for all scripts โจ NEW - โ
restartaction execution for all scripts โจ NEW - โ Exit codes (0 for success, 1 for invalid args) โจ NEW
- โ
set -eerror handling behavior โจ NEW - โ Beep command validation (frequencies, durations) โจ NEW
- โ Imperial March theme in beep_samba โจ NEW
- โ Sequential execution โจ NEW
Now tested (install.sh): โ
- โ Installation (copying files to /etc, /lib, /usr) โจ NEW
- โ Uninstallation (file removal) โจ NEW
- โ File permissions preservation โจ NEW
- โ Graceful handling of missing files โจ NEW
Now tested (composer system): โ
- โ Help and usage messages
- โ Single and multiple note parsing
- โ Sharps and flats (chromatic notes)
- โ All octave ranges (0-8)
- โ All note durations (whole, half, quarter, eighth)
- โ Tempo directives and BPM scaling
- โ Rest notation
- โ File input/output operations
- โ Library functions (get_note_frequency, parse_note, set_tempo_bpm)
- โ All 10 composition files validation
- โ Configuration file defaults
- โ Enharmonic equivalents (C# = Db)
Now tested (libraries): โ NEW
- โ lib/config.sh - File existence, sourcing, function definitions (10 tests) โจ NEW
- โ lib/discovery.sh - File existence, sourcing, function definitions (10 tests) โจ NEW
- โ lib/scheduler.sh - File existence, sourcing, function definitions (6 tests) โจ NEW
- โ lib/tunes.sh - File existence, sourcing (2 tests) โจ NEW
- โ lib/notes.sh - Additional function tests (6 tests) โจ NEW
- โ locale/i18n.sh - i18n support and 26 language files (10 tests) โจ NEW
Now tested (config tools): โ NEW
- โ sparky-beep-config - File existence, executability, options (12 tests) โจ NEW
- โ sparky-beep-config-tui - TUI implementation (9 tests) โจ NEW
- โ sparky-beep-config-gui - GUI implementation (9 tests) โจ NEW
Now tested (UI tools): โ NEW
- โ sparky-beep-composer-tui - Composer TUI (8 tests) โจ NEW
- โ sparky-beep-composer-gui - Composer GUI (8 tests) โจ NEW
- โ sparky-beep-player-tui - Player TUI (8 tests) โจ NEW
- โ sparky-beep-player-gui - Player GUI (8 tests) โจ NEW
- โ Integration tests for all UI tools (6 tests) โจ NEW
Now tested (ternary beep engine): โ NEW
- โ tbeep.c source code validation (32 tests) โจ NEW
- โ Makefile targets and compilation setup โจ NEW
- โ Ternary and binary mode support โจ NEW
- โ Command-line option parsing โจ NEW
- โ Integration with beep.conf โจ NEW
Remaining gaps:
โ ๏ธ Systemd service file syntax validationโ ๏ธ Service dependency bindings (BindsTo, After, etc.)โ ๏ธ Actual PC speaker hardware testingโ ๏ธ Deeper library function testing (implementation details)โ ๏ธ Integration testing (end-to-end workflows)โ ๏ธ Interactive TUI/GUI testing (requires user interaction)
Priority 1: Enhanced Component Tests (high priority)
-
Deeper library function tests:
- โ Basic existence and sourcing tests โ
โ ๏ธ Implementation details (function logic, edge cases)โ ๏ธ Error handling in library functionsโ ๏ธ Integration between libraries
-
Interactive TUI/GUI tests:
- โ Basic structure and dependencies tests โ
โ ๏ธ User interaction simulationโ ๏ธ Dialog/zenity output validationโ ๏ธ Error handling in UI workflows
-
Ternary beep runtime tests:
- โ Source code and Makefile tests โ
โ ๏ธ Compilation and execution testsโ ๏ธ Binary vs ternary mode comparisonโ ๏ธ Actual frequency/duration validation
Priority 2: Integration Tests
-
End-to-end workflows:
- Install โ Configure โ Test โ Uninstall
- Composer TUI โ Create composition โ Play via player
- Config TUI โ Enable service โ Verify systemd activation
- Multi-language interface switching (i18n)
-
Service integration:
- Systemd service binding behavior
- Service state propagation (parent service stops โ beep service stops)
- Service discovery with actual packages
Priority 3: Validation Tests (remaining)
-
Systemd service file validation:
- Service file syntax validation
- Verify service bindings (BindsTo, After, WantedBy)
- Validate ExecStart/ExecStop/ExecReload paths
- Test service dependency chains
-
LSB header validation (partially covered):
- โ Usage messages validated
- Validate all LSB fields (Provides, Required-Start, Default-Start, etc.)
- Verify runlevel specifications
-
Performance tests:
- Beep sequence timing validation
- Multiple concurrent service activations
- Composition playback performance
Current test organization:
tests/
โโโ helpers.bash # โ
Shared test infrastructure
โโโ init-usage.bats # โ
Usage message validation (1 test)
โโโ sparky-beep-run.bats # โ
Basic service tests (1 test)
โโโ sparky-beep-run-extended.bats # โ
Comprehensive service tests (16 tests)
โโโ init-scripts.bats # โ
Init script execution tests (26 tests)
โโโ install.bats # โ
Installation tests (15 tests)
โโโ composer.bats # โ
Composer and notation tests (27 tests)
โโโ libraries.bats # โ
Library function tests (42 tests) โจ NEW
โโโ config-tools.bats # โ
Config tool tests (30 tests) โจ NEW
โโโ ui-tools.bats # โ
UI tool tests (38 tests) โจ NEW
โโโ tbeep.bats # โ
Ternary beep tests (32 tests) โจ NEW
โโโ README.md # โ
Testing documentation
Implemented test helpers (helpers.bash): โ
- โ
setup_mock_environment()- Complete mock setup - โ
mock_systemctl()- Mock systemctl with state tracking - โ
mock_apt_cache_*()- Mock package installation status - โ
mock_beep()- Mock beep command - โ
assert_service_started()- Verify service state - โ
assert_service_enabled()- Verify enabled state - โ
assert_file_exists()- Verify file creation - โ
assert_output_contains()- Verify output content - โ
set_service_started()- Pre-configure service state - โ
cleanup_mock_environment()- Test cleanup
Future organization (optional):
- Consider organizing into subdirectories (unit/, integration/, validation/)
- Add CI/CD integration (GitHub Actions)
- Add test coverage reporting
When contributing to Sparky Beep, please:
- Run existing tests to ensure no regressions:
bats tests/ - Add tests for new beep services
- Update tests if changing status check logic
- Ensure tests pass before submitting pull requests
For more detailed testing guidance, see tests/README.md.
Copyright (C) 2018-2020 Paweล Pijanowski & Daniel Campos Ramos
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
apt beep coreutils grep openssh-server systemd
netdata samba webmin
su (or sudo) ./install.sh
su (or sudo) ./install.sh uninstall