@@ -153,6 +153,7 @@ type TimeInUs = i64;
153153
154154struct  MprisService  { 
155155    identity :  String , 
156+     desktop_entry :  Option < String > , 
156157} 
157158
158159#[ zbus:: interface( name = "org.mpris.MediaPlayer2" ) ]  
@@ -277,7 +278,7 @@ impl MprisService {
277278        debug ! ( "org.mpris.MediaPlayer2::DesktopEntry" ) ; 
278279        // FIXME: The spec doesn't say anything about the case when there is no .desktop. 
279280        // Is there any convention? Any value that common clients handle in a sane way? 
280-         "" . to_owned ( ) 
281+         self . desktop_entry . clone ( ) . unwrap_or_default ( ) 
281282    } 
282283
283284    // The URI schemes supported by the media player. 
@@ -1123,9 +1124,14 @@ pub struct MprisEventHandler {
11231124} 
11241125
11251126impl  MprisEventHandler  { 
1126-     fn  connection_builder < ' a > ( identity :  & str ,  name :  & str )  -> zbus:: Result < connection:: Builder < ' a > >  { 
1127+     fn  connection_builder < ' a > ( 
1128+         identity :  & str , 
1129+         name :  & str , 
1130+         desktop_entry :  Option < & str > , 
1131+     )  -> zbus:: Result < connection:: Builder < ' a > >  { 
11271132        let  mpris_service = MprisService  { 
11281133            identity :  identity. to_string ( ) , 
1134+             desktop_entry :  desktop_entry. map ( |desktop_entry| desktop_entry. to_string ( ) ) , 
11291135        } ; 
11301136        let  mpris_player_service = MprisPlayerService  { 
11311137            spirc :  None , 
@@ -1145,19 +1151,26 @@ impl MprisEventHandler {
11451151            . serve_at ( "/org/mpris/MediaPlayer2" ,  mpris_player_service) 
11461152    } 
11471153
1148-     pub  async  fn  spawn ( player :  Arc < Player > ,  name :  & str )  -> Result < MprisEventHandler ,  MprisError >  { 
1154+     pub  async  fn  spawn ( 
1155+         player :  Arc < Player > , 
1156+         name :  & str , 
1157+         desktop_entry :  Option < & str > , 
1158+     )  -> Result < MprisEventHandler ,  MprisError >  { 
11491159        let  ( cmd_tx,  cmd_rx)  = mpsc:: unbounded_channel ( ) ; 
11501160
1151-         let  connection = Self :: connection_builder ( name,  "org.mpris.MediaPlayer2.librespot" ) ?
1152-             . build ( ) 
1153-             . await ; 
1161+         let  connection =
1162+             Self :: connection_builder ( name,  "org.mpris.MediaPlayer2.librespot" ,  desktop_entry) ?
1163+                 . build ( ) 
1164+                 . await ; 
11541165        let  connection = match  connection { 
11551166            Err ( zbus:: Error :: NameTaken )  => { 
11561167                let  pid_name =
11571168                    format ! ( "org.mpris.MediaPlayer2.librespot.instance{}" ,  process:: id( ) ) ; 
11581169                warn ! ( "zbus name taken, trying with pid specific name: {pid_name}" ) ; 
11591170
1160-                 Self :: connection_builder ( name,  & pid_name) ?. build ( ) . await 
1171+                 Self :: connection_builder ( name,  & pid_name,  desktop_entry) ?
1172+                     . build ( ) 
1173+                     . await 
11611174            } 
11621175            _ => connection, 
11631176        } ?; 
0 commit comments