diff --git a/redeploy.sh b/redeploy.sh new file mode 100755 index 0000000..553579e --- /dev/null +++ b/redeploy.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# Rebuild and deploy the local COSMIC Media Player fork. +# +# Keep this binary in /usr/local/bin so it intentionally overrides the packaged +# /usr/bin/cosmic-player, but only after rebuilding from the current local +# source tree. + +set -euo pipefail + +REPO="${COSMIC_PLAYER_REPO:-/home/lionel/Projets/COSMIC/cosmic-player}" +TOOLCHAIN="${COSMIC_RUST_TOOLCHAIN:-1.93.0}" +PREFIX="${COSMIC_LOCAL_PREFIX:-/usr/local}" +APPID="com.system76.CosmicPlayer" +BIN_NAME="cosmic-player" + +cd "$REPO" + +echo "==> Repository: $REPO" +echo "==> Branch: $(git branch --show-current 2>/dev/null || echo unknown)" +echo "==> Build release with Rust $TOOLCHAIN" +cargo "+$TOOLCHAIN" build --release + +bin_built="$REPO/target/release/$BIN_NAME" +bin_target="$PREFIX/bin/$BIN_NAME" + +if [[ -e "$bin_target" ]]; then + backup="${bin_target}.bak.$(date +%Y%m%d-%H%M%S)" + echo "==> Backup $bin_target -> $backup" + sudo cp -a "$bin_target" "$backup" +fi + +echo "==> Install binary" +sudo install -Dm0755 "$bin_built" "$bin_target" + +echo "==> Install desktop integration" +sudo install -Dm0644 "target/xdgen/$APPID.desktop" "$PREFIX/share/applications/$APPID.desktop" +sudo install -Dm0644 "target/xdgen/$APPID.metainfo.xml" "$PREFIX/share/metainfo/$APPID.metainfo.xml" +sudo install -Dm0644 "res/$APPID.thumbnailer" "$PREFIX/share/thumbnailers/$APPID.thumbnailer" + +while IFS= read -r icon; do + rel="${icon#res/icons/hicolor/}" + 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 + +echo "OK - COSMIC Media Player rebuilt and redeployed." diff --git a/src/main.rs b/src/main.rs index d9c2233..836fc31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ mod config; mod key_bind; mod localize; mod menu; +mod mime; #[cfg(feature = "mpris-server")] mod mpris; mod project; diff --git a/src/mime.rs b/src/mime.rs new file mode 100644 index 0000000..dd37736 --- /dev/null +++ b/src/mime.rs @@ -0,0 +1,27 @@ +const DESKTOP_ENTRY: &str = include_str!("../res/com.system76.CosmicPlayer.desktop"); + +pub fn supported_mime_types() -> Vec { + 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 { + 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() +} diff --git a/src/mpris.rs b/src/mpris.rs index 8c87244..92dfcef 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -138,12 +138,12 @@ impl RootInterface for Player { async fn supported_uri_schemes(&self) -> fdo::Result> { log::info!("SupportedUriSchemes"); - Ok(vec![]) + Ok(crate::mime::supported_uri_schemes()) } async fn supported_mime_types(&self) -> fdo::Result> { log::info!("SupportedMimeTypes"); - Ok(vec![]) + Ok(crate::mime::supported_mime_types()) } } diff --git a/vendor/iced_video_player/src/pipeline.rs b/vendor/iced_video_player/src/pipeline.rs index 2d9d3e7..792c1ee 100644 --- a/vendor/iced_video_player/src/pipeline.rs +++ b/vendor/iced_video_player/src/pipeline.rs @@ -32,7 +32,7 @@ pub struct VideoPipeline { } impl VideoPipeline { - fn new(device: &wgpu::Device, format: wgpu::TextureFormat, queue: &wgpu::Queue) -> Self { + fn new(device: &wgpu::Device, format: wgpu::TextureFormat, _queue: &wgpu::Queue) -> Self { let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("iced_video_player shader"), source: wgpu::ShaderSource::Wgsl(include_str!("shader.wgsl").into()), @@ -417,7 +417,7 @@ impl Primitive for VideoPrimitive { device: &wgpu::Device, queue: &wgpu::Queue, bounds: &Rectangle, - viewport: &Viewport, + _viewport: &Viewport, ) { if self.upload_frame { if let Some(readable) = self.frame.lock().expect("lock frame mutex").readable() { diff --git a/vendor/iced_video_player/src/video.rs b/vendor/iced_video_player/src/video.rs index 48e521c..6d174e5 100644 --- a/vendor/iced_video_player/src/video.rs +++ b/vendor/iced_video_player/src/video.rs @@ -50,6 +50,7 @@ impl Frame { pub fn new() -> Self { Self(gst::Sample::builder().build()) } + #[allow(dead_code)] pub fn store(&mut self, sample: gst::Sample) -> Option<()> { if sample.buffer().is_some() { self.0 = sample; @@ -58,7 +59,7 @@ impl Frame { None } } - pub fn readable(&self) -> Option> { + pub fn readable(&self) -> Option> { self.0.buffer().map(|x| x.map_readable().ok()).flatten() } }