player: register MPEG and WMV support cleanly
Some checks failed
Validate .desktop files / validate (push) Has been cancelled

This commit is contained in:
Lionel DARNIS 2026-05-18 17:26:13 +02:00
parent fd03f98738
commit a670d2afd7
4 changed files with 52 additions and 2 deletions

View file

@ -42,6 +42,28 @@ while IFS= read -r icon; do
sudo install -Dm0644 "$icon" "$PREFIX/share/icons/hicolor/$rel"
done < <(find "res/icons/hicolor" -type f -name "$APPID.svg" | sort)
if command -v update-desktop-database >/dev/null 2>&1; then
echo "==> Refresh desktop database"
if [[ -w "$PREFIX/share/applications" ]]; then
update-desktop-database "$PREFIX/share/applications" || true
else
sudo -n update-desktop-database "$PREFIX/share/applications" 2>/dev/null || \
echo " skipped: sudo authentication required"
fi
fi
if command -v xdg-mime >/dev/null 2>&1; then
echo "==> Register common legacy video defaults"
xdg-mime default "$APPID.desktop" \
video/mpeg \
video/x-mpeg \
video/x-mpeg2 \
video/x-ms-wmv \
video/x-ms-wm \
video/x-ms-asf \
application/vnd.ms-asf
fi
echo "==> Installed version"
"$bin_target" --version

View file

@ -33,6 +33,7 @@ mod config;
mod key_bind;
mod localize;
mod menu;
mod mime;
#[cfg(feature = "mpris-server")]
mod mpris;
mod project;

27
src/mime.rs Normal file
View file

@ -0,0 +1,27 @@
const DESKTOP_ENTRY: &str = include_str!("../res/com.system76.CosmicPlayer.desktop");
pub fn supported_mime_types() -> Vec<String> {
DESKTOP_ENTRY
.lines()
.find_map(|line| line.strip_prefix("MimeType="))
.map(|mime_types| {
mime_types
.split(';')
.filter(|mime_type| !mime_type.is_empty())
.map(ToOwned::to_owned)
.collect()
})
.unwrap_or_default()
}
pub fn supported_uri_schemes() -> Vec<String> {
supported_mime_types()
.into_iter()
.filter_map(|mime_type| {
mime_type
.strip_prefix("x-scheme-handler/")
.map(ToOwned::to_owned)
})
.chain(["file".to_string(), "http".to_string(), "https".to_string()])
.collect()
}

View file

@ -138,12 +138,12 @@ impl RootInterface for Player {
async fn supported_uri_schemes(&self) -> fdo::Result<Vec<String>> {
log::info!("SupportedUriSchemes");
Ok(vec![])
Ok(crate::mime::supported_uri_schemes())
}
async fn supported_mime_types(&self) -> fdo::Result<Vec<String>> {
log::info!("SupportedMimeTypes");
Ok(vec![])
Ok(crate::mime::supported_mime_types())
}
}