Recent

Author Topic: Bell for Linux  (Read 1782 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 1462
Re: Bell for Linux
« Reply #30 on: October 23, 2020, 04:52:26 pm »
I've got nothing against libasound with a concise shim, it was running a secondary program (aplay) that I very much disliked. I was assuming that libasound- at least until one started considering codecs etc.- was itself a comparatively thin layer on top of the kernel.

I agree that using a sine wave as the parameter would be ideal, since apart from anything else that would be in the spirit of the original Beep() from TP etc.

Having said which, the "right way" is probably to use libnotify so that it works properly with the desktop's configuration stuff, and the associated daemon/backend seems to be widely adopted.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

Fred vS

  • Hero Member
  • *****
  • Posts: 1983
    • StrumPract is the musicians best friend
Re: Bell for Linux
« Reply #31 on: October 23, 2020, 05:33:55 pm »
Having said which, the "right way" is probably to use libnotify so that it works properly with the desktop's configuration stuff, and the associated daemon/backend seems to be widely adopted.

Hum, the combat will be hard.

I did check in the debian-standard.packages (distro without GUI) and indeed notification-daemon is also included, like libasound package.

So both dont need extra-installation of packages.

So we all wait for your notification-daemon solution to have something concrete to compare.

 O:-)




I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs
https://gitlab.com/fredvs

MarkMLl

  • Hero Member
  • *****
  • Posts: 1462
Re: Bell for Linux
« Reply #32 on: October 23, 2020, 06:37:27 pm »
I think a lot depends on whether the community prefers to have Beep()  be /strictly/ a PC-style beep, or prefer it to be the early-C21st equivalent configurable by thematicisation etc.

If Beep() took parameters specifying frequency and duration I'd definitely lean towards the former. It doesn't, so generally speaking I lean towards the latter.

I notice that the messages used by KDE Konsole are variously described as "Bell in Focussed Session" and "Bell in Non-Focussed Session"

If anybody has any familiarity with the actual messages (via D-Bus or whatever) involved please say since I'm having trouble pulling things together.

MaekMLl


Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2429
  • Compiler Developer
Re: Bell for Linux
« Reply #33 on: October 23, 2020, 10:22:29 pm »
I think a lot depends on whether the community prefers to have Beep()  be /strictly/ a PC-style beep, or prefer it to be the early-C21st equivalent configurable by thematicisation etc.

On Windows beep uses MessageBeep(0) which simply plays back the default Windows beep sound (see here). So the output itself does not need to be “PC-style beep”.

If Beep() took parameters specifying frequency and duration I'd definitely lean towards the former. It doesn't, so generally speaking I lean towards the latter.

The purpose of Beep is simply an acoustic notification of the user.

MarkMLl

  • Hero Member
  • *****
  • Posts: 1462
Re: Bell for Linux
« Reply #34 on: October 25, 2020, 10:27:19 am »
If a program is started from a shell running in e.g. KDE Konsole and if that has been told to honour the ASCII bell control character, then a simple  Write(#$07)  will result in a sound controlled by the desktop environment's thematicisation.

I was hoping that there would be a way of getting themed control using either libnotify or wmctrl, but so far have had no success. libnotify is oriented towards displaying an alert panel, it can in principle specify a sound name as a hint, but people who definitely wanted an audible alert in a script file were using both send-notify (client to libnotify) and aplay or similar.

General investigation suggests that while aplay is not universally installed, libasound is... at least on systems which purport to be general-purpose. The alsapas libraries are excessively cumbersome for generating a simple beep, and elsewhere it is noted that alsapas includes stuff which varies by ALSA version... I'm already at the position of having to use Docker to generate a binary for one particular server since the ALSA version is different from most of what I'm running around here.

Robert Rozee's approach at https://forum.lazarus.freepascal.org/index.php/topic,49502.msg359352.html?PHPSESSID=ju53vbrr54cosmk03869a2i6r2#msg359352 appears to work, I'm currently converting it from static to dynamic linkage so that it doesn't force a program to have a hard dependency on libasound.

It would probably be desirable for a GUI app to check whether it has a stdout and has Konsole etc. as a parent, and if those conditions were met to use  Write(#$07)  since this will output themed (or no) sound as selected by the user, and will interact with any notification hooks he has set up. I've not yet worked out a reliable way to do this, and suspect that it might depend on the desktop environment installed (i.e. KDE vs Gnome etc.).

MarkMLl



« Last Edit: October 29, 2020, 10:13:14 am by MarkMLl »
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

MarkMLl

  • Hero Member
  • *****
  • Posts: 1462
Re: Bell for Linux
« Reply #35 on: October 28, 2020, 12:28:03 pm »
This discussion ended up being continued at https://forum.lazarus.freepascal.org/index.php/topic,49502.msg382109.html#msg382109

As stated there a dynamically-linked version of work by various people went to Mantis but was rejected. I offer no comment other than to hope that the code turns out useful to various people.

In actual fact somebody has pointed out libcanberra on Linux as a themed sound generator. I'm trying to determine to what extent it is useful.

Later: As usual, the most useful description comes from Arch Linux https://wiki.archlinux.org/index.php/Libcanberra which includes examples. On Debian canberra-gtk-play comes from gnome-session-canberra which doesn't have heavyweight dependencies, and I can confirm that a command line

$ canberra-gtk-play -i KDE-Sys-App-Message

works subject the the existence of /usr/share/sounds/KDE-Sys-App-Message.ogg

However while this does appear to interact sensibly with the theme configuration it's hardly transparent since the names of the various sounds are not easily determined, and also the overhead of converting from a .ogg file strikes me as almost as undesirable as explicitly invoking something like the aplay binary.

MarkMLl
« Last Edit: October 28, 2020, 03:55:42 pm by MarkMLl »
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

 

TinyPortal © 2005-2018