Issue
soundfilechooser Settings Widget restricts choice of files to certain system folders.
Users sound files are not available to select.
Steps to reproduce
The simplest way is to use the built in Settings API Demo and try to select a file.
Most folders do not show any sound files even when they exist.
Only sound files in /usr seem to be located and selectable
Expected behaviour
Any sound file with appropriate ownership should be displayed and be able to be selected and tested.
Other information
The description in Devhelp is also confusing:
* type: should be soundfilechooser
* description: String describing the setting
* default: default icon path or icon name to use
Provides a button which shows the currently selected file name and opens a file dialog when clicked.
A preview button is also provided to allow the user to test the selected sound. Stores as a string.
Why does default: refer to Icon Path and Name? Surely it should be a Sound File Path?
The soundfilechooser widget only seems to be used in one applet by @jake1164 which I have not been able to test as it does not load.
Hi @pdcurtis,
The cause seems to be in the file /usr/share/cinnamon/cinnamon-settings/bin/SettingsWidgets.py.
Line 915 and following:
sound_filter = Gtk.FileFilter()
sound_filter.add_mime_type("audio/x-wav")
sound_filter.add_mime_type("audio/x-vorbis+ogg")
sound_filter.set_name(_("Sound files"))
dialog.add_filter(sound_filter)
Only x-wav and x-vorbis+ogg audio files!
This is a serious limit to user choice.
@claudiux It is worse than that as even ogg files are not found in ones home folder, only in /usr. I could not see where the restriction occured
@pdcurtis .oga and .wav files are found in home folder (I just tried copying some files from /usr into my home folder, successfully).
Here is a part of my settings-schema.json file:
"useSoundAlert": {
"type": "checkbox",
"indent": true,
"default": false,
"description": "Emit an audible alert when VPN shuts down.",
"tooltip": "Checking this allows this applet to emit an audible alert when VPN shuts down."
},
"useSoundAlertAtBeginning": {
"type": "checkbox",
"indent": true,
"default": false,
"description": "Emit this audible alert when this Applet starts, if VPN is down.",
"tooltip": "Check this if you want to emit this audible alert when this Applet starts, if VPN is down.",
"dependency": "useSoundAlert"
},
"usedSound": {
"type": "soundfilechooser",
"description": "The sound to emit:",
"default": "/usr/share/sounds/freedesktop/stereo/phone-outgoing-busy.oga",
"dependency": "useSoundAlert"
},
(The required fields for a soundfilechooser are "type", "description" and "default".)
@claudiux It does not find either an existing .oga or .mp3 in my home folder but has found a .wav and .oga copied from /usr . Checked owner and permissions are all the same as I expected and the .oga is one I am already using as an alert. Only difference I can see is that it is longer.
For the test I am still using the built in applet Settings API Demo which has an empty default field ie "default": "", - this defaults to /home.
Very odd. Are you using Cinnamon 4.0.8 and Mint 19.1
Yes, I use the same.
Do your filenames contain spaces? I will make tests tomorrow.
The filter doesn't accept mp3 files.
Hello, everybody.
My guess is that the MIME type limitation for audio files has a purpose. The SoundFileChooser widget is not only used by the xlets settings, but also by Cinnamon itself in System Settings > Sound > Sounds tab. Allowing all audio MIME types might lead to confusion due to Cinnamon not being able to play all audio file types.
But, due to the nature of xlets, one isn't limited to just what Cinnamon can do. Maybe a middle point can be adding a new field for the soundfilechooser widget, lets call it all_mimetypes.
{
"sound_pref": {
"type": "soundfilechooser",
"description": "The sound to play:",
"all_mimetypes": true,
"default": ""
}
}
...and in the SoundFileChooser widget class...
# If all_mimetypes is set to true in the soundfilechooser xlet widget,
# allow to display all audio files in the file selector.
if all_mimetypes_parameter:
sound_filter.add_mime_type("audio/*")
else:
sound_filter.add_mime_type("audio/x-wav")
sound_filter.add_mime_type("audio/x-vorbis+ogg")
What do you think, @collinss?
P.S.: @pdcurtis: Just checking. Are you sure that the files that you cannot see, and are supposed to be displayed in the file chooser, aren't hidden files (dot files)?

I think I have found the difference the .oga files not displayed are type audio/x-flac+ogg and displayed ones are audio/x-vorbis+ogg. And for reference I understand hidden files and files names do not have spaces.
@Odyseus Your suggestion of opening up the choices would be good for me - I actually wanted to access .mp3 files and only tried .oga to find out what was going on.
So this is really turning out to be a feature request not an Issue.
@Odyseus Yeah, I was having the same thought. It's been long enough since I worked on this that I don't remember details about that widget. (Most likely I just used whatever was there before). However, as you pointed out, by default we probably only want the ones cinnamon can handle, but then have the option to select all sound files if the spice dev is using something other than Cinnamon to play sounds.
@collinss I have just started to use the event-sounds:option you added in #8312 now Cinnamon 4.2 is available.
It allows me to select any audio file as expected but the preview only seems to work for the original subset of sound files and does nothing when an .mp3 file is selected.
I am only currently using it in the batterymonitor@pdcurtis applet
@pdcurtis yeah, that's because the tool we're using to preview the sounds is the same one that Cinnamon uses to play the sounds, and that tool doesn't support .mp3s (I think it only handles .wav and .ogg but I'm not sure). I suppose we could disable the preview if it's unsupported, but I don't think it's worth the effort to add support for previewing sound formats that cinnamon can't even play. Also, doing so would probably add an extra dependency on Cinnamon, which is also kind of overkill imo. Even just allowing sound files that Cinnamon can't play is rather niche anyway, and I don't really see the point in putting too much into this.
@collinss No problem, I will add a comment somewhere next time I update so people do not raise an Issue with me.
Thanks for do it in the first place.
Most helpful comment
@Odyseus Yeah, I was having the same thought. It's been long enough since I worked on this that I don't remember details about that widget. (Most likely I just used whatever was there before). However, as you pointed out, by default we probably only want the ones cinnamon can handle, but then have the option to select all sound files if the spice dev is using something other than Cinnamon to play sounds.