LoginSignup
5
5

More than 5 years have passed since last update.

Linuxでビープ音を出す際にハマったメモ

Last updated at Posted at 2017-07-12

Linuxでprintf("\a\n"); でビープ音を鳴らす際にハマったのでメモ。

環境

  • OS: Linux Mint 18.1 (多分Ubuntu系なら一緒と思います)
  • デスクトップPCでスピーカはUSB接続

やりたかったこと

  • C言語のprintf("\a\n")またはシェルのecho -e "\a"でビープを鳴らしたい

鳴らすためにやったこと

  • /etc/pulse/default.pa で以下の行をアンコメント。(行は多少離れてるので bell で検索)
load-sample-lazy x11-bell /usr/share/sounds/freedesktop/stereo/bell.oga
load-module module-x11-bell sample=x11-bell
  • 1回再起動するまたは pulseaudio --kill; pulseaudio --startを実行

これで鳴りました。
なお、上記のbell.ogaのところのファイルパスを変えれば、好きな音をビープ音に出来ます。
ビープ音のサンプルは /usr/share/sounds/以下に色々とあります。

備考

検索すると以下をやれという説明がよく出てきますが、私の環境では不要でした。

  • /etc/modprobe.d/blacklist.conf で blacklist pcspkr をコメントアウト (一時的でいいなら sudo modprobe pcspkr を実行)

おわり

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5