poetaman/arttime

Nothing audible when a notification is seen on FreeBSD

grahamperrin opened this issue · 11 comments

Essentially

pacat /usr/local/lib/libreoffice/share/gallery/sounds/gong.wav

arttime --nolearn -a trafficlightgreen -b trafficlightred -t "I heard the gong. Now I'll set a goal, then see a notification but hear nothing …"

Am I missing something?

(I assume that the intention is for sound, when available, to accompany a notification.)

TIA

Context

% pactl info
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
% pulseaudio --start
W: [(null)] caps.c: Normally all extra capabilities would be dropped now, but that's impossible because PulseAudio was built without capabilities support.
% pactl info
Server String: /var/run/user/1002/pulse/native
Library Protocol Version: 34
Server Protocol Version: 34
Is Local: yes
Client Index: 3
Tile Size: 65472
User Name: grahamperrin
Host Name: mowa219-gjp4-8570p-freebsd
Server Name: pulseaudio
Server Version: 14.2
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: oss_output.dsp1
Default Source: oss_input.dsp1
Cookie: 99cf:bba2
% pacat /usr/local/lib/libreoffice/share/gallery/sounds/gong.wav
% arttime --nolearn -a trafficlightgreen -b trafficlightred -t "I heard the gong. Now I'll set a goal, then see a notification but hear nothing …"
% pulseaudio --kill
W: [(null)] caps.c: Normally all extra capabilities would be dropped now, but that's impossible because PulseAudio was built without capabilities support.
% date ; uname -aKU
Wed  5 Oct 2022 03:22:32 BST
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #21 main-n258027-c9baa974717a: Fri Sep 16 15:41:27 BST 2022     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400067 1400067
% 

@grahamperrin On first glance it looks like arttime wasn't able to find music file to play. I thought freedesktop would have come up with standard install directory spec. On Linux freedesktop sounds are installed under /usr/share/sounds/freedesktop/stereo/*. Does a file like /usr/share/sounds/freedesktop/stereo/message-new-instant.oga exist on your FreeBSD DE? I will anyway add an option to specify sound file on the command line, though it will be helpful to know where are freedesktop sounds installed by default. I found a post that looks relevant here: https://www.reddit.com/r/freebsd/comments/ojp3tl/the_freedesktoporg_is_no_longer_a_viable_resource/.

It would be nice to figure out all possible standard directories to look sound files, and have a few defaults not just one...

Thanks for posting to discussions, for other readers, they might find this useful: #26

From https://specifications.freedesktop.org/sound-theme-spec/sound-theme-spec-latest.html:

If you're an application author and you want to install sounds so that they can be used by your application, you should at least install the sound file in the "freedesktop" theme. This means installing a stereo WAV file in $XDG_DATA_DIRS/sounds/freedesktop/stereo/

And $XDG_DATA_DIRS on my Linux machines is: /usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share. arttime is currently just looking under /usr/share/sounds/freedesktop/stereo/. So I will have to fix it for freedesktop systems anyway... Arttime perhaps should also carry a default sound file in its repository, in case it is unable to find a sound in standard directories, it can play that default notification sound file. The default sound on Linux/Unix is message-new-instant.oga which has a 22KB file size. Not sure if it requires any license to be copied though...

Btw, on my Linux system pacat /path/to/file creates a sharp white noise, and paplay /path/to/file plays sound correctly.

A few questions:

  • Is the environment variable XDG_DATA_DIRS defined in your FreeBSD DE?
    • If yes, what's the value?
    • Are there any sound files under $XDG_DATA_DIRS/sounds/freedesktop/stereo.
      • If yes, is there a file message-new-instant.oga?
  • Do you have https://www.freshports.org/devel/xdg-utils/ installed?
    • If no, does installing change anything? (like message-new-instant.oga becomes available under XDG_DATA_DIRS)?
  • What is your Desktop Environment?

@grahamperrin I have added a commit where arttime finds message-new-instant.oga under all possible colon-separated directories of $XDG_DATA_DIRS/sounds/freedesktop/stereo. Not sure if it will fix it for BSD, this commit made it to main anyway to benefit Linux DEs that follow freedesktop spec.

⚙ D24810 Ensure defintion of XDG_DATA_DIRS @tcberner

% file /usr/share/sounds
/usr/share/sounds: cannot open `/usr/share/sounds' (No such file or directory)
% echo $XDG_DATA_DIRS
XDG_DATA_DIRS: Undefined variable.
% pkg info -x devel/xdg-utils
xdg-utils-1.1.3_2
% pkg info -x kde5
kde5-5.24.6.22.08.1
% cd dev/arttime
% git branch
* main
  oldbsdtput
% git pull
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 14 (delta 5), reused 8 (delta 5), pack-reused 3
Unpacking objects: 100% (14/14), 9.46 KiB | 151.00 KiB/s, done.
From https://github.com/reportaman/arttime
   2cd785d..c5e36a3  main       -> origin/main
   1df6a96..c5e36a3  dev        -> origin/dev
Updating 2cd785d..c5e36a3
Fast-forward
 README.md                      |  2 +-
 bin/arttime                    |  3 ++-
 share/arttime/textart/freebsd1 | 38 +++++++++++++++++++-------------------
 3 files changed, 22 insertions(+), 21 deletions(-)
% ./install.sh 
Progress: 100% done
Installation complete!
Restart your terminal application, type 'arttime' and press Enter.
% 

No sound from arttime (the undefined variable, above), so …

937d380 noted with thanks.

% locate message-new-instant.oga
/usr/local/share/sounds/freedesktop/stereo/message-new-instant.oga
% xdg-settings --help
Use 'man xdg-settings' or 'xdg-settings --manual' for additional info.
% 

xdg-settings(1)

Below: clearly, I'm confused :-)

% xdg-settings set XDG_DATA_DIRS /usr/local/share
Use 'man xdg-settings' or 'xdg-settings --manual' for additional info.
% xdg-settings --list
Known properties:
  default-url-scheme-handler    Default handler for URL scheme
  default-web-browser           Default web browser
% 

Less confused now, I overlooked the obvious, for me, setenv

% echo $0
/bin/tcsh
% setenv XDG_DATA_DIRS /usr/local/share
% pulseaudio --start
W: [(null)] caps.c: Normally all extra capabilities would be dropped now, but that's impossible because PulseAudio was built without capabilities support.
% /usr/local/share/sounds/freedesktop/stereo/message-new-instant.oga
/usr/local/share/sounds/freedesktop/stereo/message-new-instant.oga: Permission denied.
% pacat /usr/local/share/sounds/freedesktop/stereo/message-new-instant.oga
% pacat $XDG_DATA_DIRS/sounds/freedesktop/stereo/message-new-instant.oga
% arttime --nolearn -a trafficlightgreen -b trafficlightred -t "I heard the gong. Now I'll set a goal, then see a notification and …"
% 

yes, I hear a sound.

Proof that it works, there remains the question of how best to set things.

@grahamperrin If I got it right, at the moment DE installation on FreeBSD does not conform to freedesktop spec in setting XDG_DATA_DIRS for the user. But it seems they have those sound files installed anyway. If FreeBSD's fix to set XDG_DATA_DIRS will take time, I can add an if condition in my code for BSD and bypass looking up XDG_DATA_DIRS directory, and look up a few standard locations like /usr/share/sounds... and /usr/local/share/sounds.... If message-new-instant.oga is found then it will be played. Another possibility as I mentioned previously is to add this sound file in the repository of arttime in a new directory and not look up XDG_DATA_DIRS for Linux and BSD. Though I don't know where to look for its license file... A fix will anyway be welcome as I intend to add a feature where user can pass an option like --sound <sound_file_name>, and <sound_file_name> will be looked up under XDG_DATA_DIRS (expecting users to pass entire path is a bit ugly).

As a sidenote, please update the origin's url:

git remote get-url origin --all
git remote set-url origin https://github.com/poetaman/arttime.git
git remote get-url origin --all

@grahamperrin pull dev or main and try again. You shouldn't have to set environment variable as arttime now looks for some standard directories if XDG_DATA_DIRS is not set. Also, if a system has ogg123 then it is preferred over paplay. I am not sure if pulseaudio daemon has anything to do with paplay (on my linux machine pulseaudio --start and pulseaudio --end have no effect on paplay producing sound), but I anyway went ahead and made that change. Can you check again if the issues you mention about pulse daemon have any relation to paplay? I heard some stutter again in ogg123 on Linux VM, it happens once in a while. Changes are in 3a20eba

… pull dev or main and try again. …

Thanks! Working (audible) with main pulled to my everyday FreeBSD 14.0-CURRENT environment.

I have not tested with a fresh installation of any version of FreeBSD, let's assume that the enhancements will be equally good in these environments.

… was closure premature? (I didn't think of documentation; sorry.)


… the issues you mention about pulse daemon …

#26, yes? (Should we continue there?)

@grahamperrin It was ok to close, we can continue discussion there. And your original issue got resolved, any further commits to main should only improve things, which they did in 0c2a0cb, check #26 (comment). Thanks!!