• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created about 4 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ”Š Play sounds while and after shell jobs complete

πŸ”Š Play sounds while and after shell jobs complete

onhold is a command-line utility that allows you to play music while a long job completes.

ding is command-line utility that will play a sound after a long job completes.

Both utilities will take data that is piped into their standard inputs and pipe it to standard output. That is to say that data piped into onhold and ding will be piped right back out.

$ echo "Hello!" | onhold
Hello!

As a result, you can build pipelines with onhold and ding.

For example, you can download an ISO with http, visualize the progress with pv, play music with onhold while writing to /dev/null, and when it's finished, play a sound with ding.

$ export URL="http://releases.ubuntu.com/releases/21.04/ubuntu-21.04-desktop-amd64.iso"
$ http "$URL" | pv | onhold | ding > /dev/null

This project uses play_sounds, a wrapper over playsound and boombox.

onhold

You can either set the $ONHOLD environment variable to the song you'd like to play, or supply the song with the -s flag.

$ export ONHOLD="~/Music/song.mp3"
$ pv /dev/zero | onhold > /dev/null

This allows you to set $ONHOLD in your ~/.bashrc.

You can also specify it with a flag.

$ pv /dev/zero | onhold -s song.mp3 > /dev/null

onhold comes with a default song that will play if neither $ONHOLD or -s are set. You can use the -w flag to show warnings if $ONHOLD or -s are not set.

$ echo "Hello!" | onhold
Hello!

ding

You can either set the $DING environment variable to the sound you'd like to play, or supply the sound with the -s flag.

# You can run ding after a command or as part of a pipeline
$ export DING="~/Music/ding.mp3"
$ sleep 5; ding
$ echo "Hello!" | ding
Hello!

This allows you to set $DING in your ~/.bashrc.

You can also specify it with a flag.

$ echo "Hello!" | ding -s ding.mp3
Hello!

ding comes with a default sound that will play if neither $DING or -s are set. You can use the -w flag to show warnings if $DING or -s are not set.

$ echo "Hello!" | ding
Hello!

ding is its own package, too

You can install ding by itself. Future versions of onhold will not ship with ding. Click here to visit ding's project page with installation instructions.

Installation

Dependencies

  • A Unix shell like Bash, or PowerShell or Command Prompt on Windows
  • Python 3.6+
  • requirements.txt

Linux

You'll need to install GStreamer on Linux, or the play binary from sox.

Ubuntu

On Ubuntu, you will need to install PyGObject, gstreamer1.0-python3-plugin-loader and python3-gst-1.0.

$ sudo apt install python3-gi gstreamer1.0-python3-plugin-loader python3-gst-1.0

Arch

On Arch, you can install onhold or onhold-git and its prerequisites directly from the AUR. Thanks, @jfrcom!

$ yay -S onhold # replace yay with your aur helper

PyPI

$ python3 -m pip install onhold

GitHub

$ python3 -m pip install -r requirements.txt
$ python3 setup.py install

Help

onhold

$ onhold --help
Usage: onhold [OPTIONS]

  Play the specified sound file while data is passed in through standard
  input and passed through standard output.

Options:
  -s, --sound_path PATH  Path to sound to play.
  -b, --bell             Ring the terminal bell, as well.  [default: False]
  -w, --warn             Show warnings.
  --help                 Show this message and exit.

ding

$ ding --help
Usage: ding [OPTIONS]

  Play specified sound after job is complete.

Options:
  -s, --sound_path PATH  Path to sound to play.
  -b, --bell             Ring the terminal bell, as well.  [default: False]
  -w, --warn             Show warnings.
  --help                 Show this message and exit.

Support

Want to support this project and other open-source projects like it?

Buy Me A Coffee

License

See LICENSE. If you'd like to use this project with a different license, please get in touch.

More Repositories

1

cast_control

πŸ“Ί Control Chromecasts from Linux and D-Bus
Python
468
star
2

screenshot

πŸ“Έ Automate capturing screenshots of apps and windows on macOS
Python
153
star
3

aiopath

πŸ“ Asynchronous pathlib for Python
Python
134
star
4

mpris_server

▢️ Integrate MPRIS Media Player support into your app
Python
25
star
5

brightness

β˜€οΈ Dim your Mac's display from the command line via CoreDisplay
Python
25
star
6

limiter

⏲️ Easy rate limiting for Python using a token bucket algorithm, with async and thread-safe decorators and context managers
Python
20
star
7

parse_google_sms

πŸ“±Data forensics and recovery utility for Google Voice chats saved via Google Takeout
Python
18
star
8

save_skype

πŸ’¬ Data forensics and recovery utility for Skype chats and history
Python
13
star
9

cast_convert

πŸ“½οΈ Convert videos to Chromecast compatible formats
Python
7
star
10

ding

Python
7
star
11

play_sounds

πŸ”Š Play music and sounds in your Python scripts, synchronously and asynchronously.
Python
6
star
12

intel-gvtg

Scripts for managing Intel virtual gfx and KVM
Shell
6
star
13

strs

🧡 Easy string tools for the shell
Python
4
star
14

app_paths

πŸ“‚ Like appdirs, but with pathlib, path creation and async support.
Python
4
star
15

grub2systemd

πŸ’Ύ Convert grub.cfg to systemd-boot EFI loader entries
Python
4
star
16

unpackable

πŸ“¦ Destructure Python objects
Python
3
star
17

dreamhost-dyndns

Updates Dreamhost DNS Records via DynamicDNS (DynDNS) API
Python
3
star
18

delete_scrobbles

❌ Automatically delete scrobbles on Last.fm
JavaScript
3
star
19

alexdelorenzo

2
star
20

disjoint_set

Union find / disjoint union set
Python
2
star
21

pinterest_tools

TamperMonkey tools for Pinterest
JavaScript
2
star
22

find-ubuntu-mirrors

πŸ” Find Apt repository mirrors for Ubuntu
Shell
2
star
23

npm-user

🏠 Install npm packages as a non-root user
Shell
2
star
24

ubuntu-kernel

Download latest mainline kernel from Ubuntu's kernel PPA
Shell
2
star
25

rust-book

Code examples, tests, and responses from the Rust Book https://doc.rust-lang.org/book/
Assembly
2
star
26

transmission_user

Change the user of the transmission-daemon in Debian/Ubuntu
Shell
2
star
27

buf_stream

Rust
1
star
28

nth_py

Python
1
star
29

nth_rs

Return or exclude the nth item via stdin
Rust
1
star
30

minesweeper

minesweeper game + shoddily put together gui + a board solver
Python
1
star
31

cacheit

Caching decorator for Python callables
Python
1
star
32

buffers-rs

βŒ› A stream buffer backed by a temporary file.
Rust
1
star
33

userscripts

JavaScript
1
star
34

html_wrapper

HTML parser with lxml backend. Implements subset of BeautifulSoup API
Python
1
star
35

cheapbook

Send email/SMS notifications about Apple's refurb stock
Python
1
star
36

byte_lines

Iterate over lines of bytes from anything that implements std::io::Read
Rust
1
star
37

buffer

βŒ› A stream buffer backed by tempfile.SpooledTemporaryFile
Python
1
star
38

covid_schools

Script that puts together a COVID spreadsheet
Python
1
star
39

wordpress_menu

Drop down menu for Wordpress
JavaScript
1
star