@@ -13,6 +13,8 @@ const ALBUMART_ON = TMP_ALBUMART_DIR + "/ON";
1313const ALBUMART_PICS_DIR = TMP_ALBUMART_DIR + "/song-art" ;
1414const ALBUMART_TITLE_FILE = TMP_ALBUMART_DIR + "/title.txt" ;
1515
16+ const ARTS_DIR = XDG_RUNTIME_DIR + "/sound150/arts" ;
17+
1618const MPV_RADIO_PID = XDG_RUNTIME_DIR + "/mpv_radio_PID" ;
1719
1820const PopupMenu = imports . ui . popupMenu ;
@@ -119,6 +121,8 @@ class StreamMenuSection extends PopupMenu.PopupMenuSection {
119121 iconName = "banshee" ;
120122 } else if ( name === "Spotify" ) {
121123 iconName = "spotify" ;
124+ } else if ( name === "Strawberry" ) {
125+ iconName = "strawberry" ;
122126 } else if ( name === "VBox" ) {
123127 name = "Virtualbox" ;
124128 iconName = "virtualbox" ;
@@ -380,7 +384,8 @@ class Player extends PopupMenu.PopupMenuSection {
380384 //~ Util.spawnCommandLine("/usr/bin/env bash -c '%s'".format(DEL_SONG_ARTS_SCRIPT));
381385
382386 if ( this . _seeker ) {
383- if ( this . _seeker . status === "Playing" && this . _seeker . posLabel ) this . _seeker . posLabel . set_text ( " 00:00 " ) ;
387+ if ( this . _seeker . status === "Playing" && this . _seeker . posLabel )
388+ this . _seeker . posLabel . set_text ( " 00:00:00 " ) ;
384389 this . _seeker . startingDate = Date . now ( ) ;
385390 this . _seeker . _setPosition ( 0 ) ;
386391 }
@@ -534,7 +539,8 @@ class Player extends PopupMenu.PopupMenuSection {
534539 }
535540
536541 _setName ( status ) {
537- this . playerLabel . set_text ( this . _name + " - " + _ ( status ) ) ;
542+ if ( this . playerLabel != null )
543+ this . playerLabel . set_text ( this . _name + " - " + _ ( status ) ) ;
538544 }
539545
540546 _updateControls ( ) {
@@ -615,7 +621,8 @@ class Player extends PopupMenu.PopupMenuSection {
615621 } else
616622 this . _artist = _ ( "Unknown Artist" ) ;
617623
618- this . artistLabel . set_text ( this . _artist ) ;
624+ if ( this . artistLabel != null )
625+ this . artistLabel . set_text ( this . _artist ) ;
619626
620627 if ( metadata [ "xesam:album" ] )
621628 this . _album = metadata [ "xesam:album" ] . unpack ( ) ;
@@ -647,7 +654,8 @@ class Player extends PopupMenu.PopupMenuSection {
647654 if ( json_artist ) {
648655 //~ this._artist = capitalize_each_word(json_artist);
649656 this . _artist = json_artist . capitalize ( ) ;
650- this . artistLabel . set_text ( this . _artist ) ;
657+ if ( this . artistLabel != null )
658+ this . artistLabel . set_text ( this . _artist ) ;
651659 } else {
652660 this . _artist = _ ( "Unknown Artist" ) ;
653661 }
@@ -659,7 +667,8 @@ class Player extends PopupMenu.PopupMenuSection {
659667 }
660668 } else if ( this . _title . includes ( " - " ) && this . _artist == _ ( "Unknown Artist" ) ) {
661669 [ this . _artist , this . _title ] = this . _title . split ( " - " ) ;
662- this . artistLabel . set_text ( this . _artist ) ;
670+ if ( this . artistLabel != null )
671+ this . artistLabel . set_text ( this . _artist ) ;
663672 }
664673 } else {
665674 this . _title = _ ( "Unknown Title" ) ;
@@ -677,7 +686,8 @@ class Player extends PopupMenu.PopupMenuSection {
677686 Util . spawnCommandLine ( "/usr/bin/env bash -c %s/get_album_art.sh" . format ( PATH2SCRIPTS ) ) ;
678687 }
679688
680- this . titleLabel . set_text ( this . _title ) ;
689+ if ( this . titleLabel != null )
690+ this . titleLabel . set_text ( this . _title ) ;
681691 this . _seeker . setTrack ( trackid , trackLength , old_title != this . _title ) ;
682692
683693 if ( metadata [ "xesam:url" ] ) {
@@ -840,7 +850,7 @@ class Player extends PopupMenu.PopupMenuSection {
840850 //~ this._applet.setAppletTextIcon(this, false);
841851 this . _applet . setAppletTextIcon ( this , true ) ;
842852 this . _seeker . pause ( ) ;
843- this . _applet . volume_near_icon ( ) ;
853+ this . _applet . volume_near_icon ( "s150PopupMenu - seeker paused" ) ;
844854 } else if ( status == "Stopped" ) {
845855 this . _playButton . setData ( "media-playback-start" , _ ( "Play" ) ) ;
846856 this . playerIcon . set_icon_name ( "media-playback-stop" ) ;
@@ -895,7 +905,7 @@ class Player extends PopupMenu.PopupMenuSection {
895905 }
896906
897907 _showCover ( cover_path ) {
898- let rnd ;
908+ let rnd , baseName ;
899909 if ( ! cover_path || ! GLib . file_test ( cover_path , GLib . FileTest . EXISTS ) ) {
900910 del_song_arts ( ) ;
901911 this . cover = new St . Icon ( {
@@ -907,27 +917,49 @@ class Player extends PopupMenu.PopupMenuSection {
907917 icon_type : St . IconType . SYMBOLIC
908918 } ) ;
909919 cover_path = null ;
920+ this . _cover_path = null ;
921+ this . _applet . setAppletTextIcon ( this , null ) ;
910922 } else {
911- let dir = Gio . file_new_for_path ( ALBUMART_PICS_DIR ) ;
923+ //~ global.log("typeof(cover_path): " + typeof(cover_path) );
924+ baseName = ( typeof ( cover_path ) === "string" ) ? cover_path . split ( "/" ) . pop ( ) : "" ;
925+ //~ let dir = Gio.file_new_for_path(ALBUMART_PICS_DIR);
926+ let dir = Gio . file_new_for_path ( ARTS_DIR ) ;
912927 let dir_children = dir . enumerate_children ( "standard::name,standard::type,standard::icon,time::modified" , Gio . FileQueryInfoFlags . NONE , null ) ;
913928 if ( ( dir_children . next_file ( null ) ) == null ) { // dir does not contain any file.
914929 if ( GLib . file_test ( cover_path , GLib . FileTest . EXISTS ) ) {
915- rnd = randomIntegerInInterval ( 0 , superRND ) . toString ( ) ;
916- if ( this . _applet . runAsync )
917- Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
918- else
919- Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
930+ if ( ! baseName . startsWith ( "R3SongArt" ) ) {
931+ rnd = randomIntegerInInterval ( 0 , superRND ) . toString ( ) ;
932+ if ( this . _applet . runAsync ) {
933+ Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
934+ Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ARTS_DIR } /R3SongArt${ rnd } ` ) ;
935+ } else {
936+ Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
937+ Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ARTS_DIR } /R3SongArt${ rnd } ` ) ;
938+ }
939+ //~ cover_path = `${ALBUMART_PICS_DIR}/R3SongArt${rnd}`;
940+ //~ this._cover_path = `${ALBUMART_PICS_DIR}/R3SongArt${rnd}`;
941+ cover_path = `${ ARTS_DIR } /R3SongArt${ rnd } ` ;
942+ this . _cover_path = `${ ARTS_DIR } /R3SongArt${ rnd } ` ;
943+ }
920944 } else {
921945 cover_path = null ;
946+ this . _cover_path = null ;
922947 }
923948 } else if ( ! GLib . file_test ( MPV_RADIO_PID , GLib . FileTest . EXISTS ) ) { // Radio3.0 is not running.
924949 //del_song_arts();
925950 if ( GLib . file_test ( cover_path , GLib . FileTest . EXISTS ) ) {
926- rnd = randomIntegerInInterval ( 0 , superRND ) . toString ( ) ;
927- if ( this . _applet . runAsync )
928- Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
929- else
930- Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
951+ if ( ! baseName . startsWith ( "R3SongArt" ) ) {
952+ rnd = randomIntegerInInterval ( 0 , superRND ) . toString ( ) ;
953+ if ( this . _applet . runAsync ) {
954+ Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
955+ Util . spawnCommandLineAsync ( `cp -a "${ cover_path } " ${ ARTS_DIR } /R3SongArt${ rnd } ` ) ;
956+ } else {
957+ Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ALBUMART_PICS_DIR } /R3SongArt${ rnd } ` ) ;
958+ Util . spawnCommandLine ( `cp -a "${ cover_path } " ${ ARTS_DIR } /R3SongArt${ rnd } ` ) ;
959+ }
960+ cover_path = `${ ARTS_DIR } /R3SongArt${ rnd } ` ;
961+ this . _cover_path = `${ ARTS_DIR } /R3SongArt${ rnd } ` ;
962+ }
931963 } else {
932964 cover_path = null ;
933965 }
@@ -1094,7 +1126,7 @@ class Seeker extends Slider.Slider {
10941126 this . actor . set_direction ( St . TextDirection . LTR ) ; // Do not invert on RTL layout
10951127 //~ this.actor.expand = true;
10961128 //~ this.actor.set_draw_value(true);
1097- this . tooltipText = "00:00" ;
1129+ this . tooltipText = "00:00:00 " ;
10981130 this . tooltip = new Tooltips . Tooltip ( this . actor , this . tooltipText ) ;
10991131
11001132 this . canSeek = true ;
@@ -1122,7 +1154,7 @@ class Seeker extends Slider.Slider {
11221154
11231155
11241156 this . posLabel = new St . Label ( {
1125- text : " 00:00 " ,
1157+ text : " 00:00:00 " ,
11261158 style : "font-family: 'Digital Numbers',monospace; "
11271159 } ) ;
11281160 this . posLabel . x_align = St . Align . START ;
@@ -1131,7 +1163,7 @@ class Seeker extends Slider.Slider {
11311163 //~ this.posLabel.clutterText.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
11321164 //~ this.posLabel.clutterText.ellipsize = Pango.EllipsizeMode.NONE;
11331165 this . durLabel = new St . Label ( {
1134- text : " 00:00 " ,
1166+ text : " 00:00:00 " ,
11351167 style : "font-family: 'Digital Numbers',monospace; "
11361168 } ) ;
11371169 this . durLabel . x_align = St . Align . END ;
@@ -1230,12 +1262,8 @@ class Seeker extends Slider.Slider {
12301262 time_for_label ( sec ) {
12311263 let milliseconds = 1000 * sec ;
12321264 var date = new Date ( milliseconds ) ;
1233- var timeString ;
1234- if ( milliseconds < 3600000 )
1235- timeString = date . toISOString ( ) . substring ( 14 , 19 ) ;
1236- else
1237- timeString = date . toISOString ( ) . substring ( 11 , 19 ) ;
1238- return " " + timeString + " " ;
1265+ let timeString = date . toISOString ( ) . substring ( 11 , 19 ) ;
1266+ return ` ${ timeString } ` ;
12391267 }
12401268
12411269 play ( ) {
@@ -1298,7 +1326,7 @@ class Seeker extends Slider.Slider {
12981326 this . _trackid = trackid ;
12991327 }
13001328 this . _length = length ;
1301- if ( this . status !== "Stopped" && this . durLabel ) this . durLabel . set_text ( this . time_for_label ( length ) ) ;
1329+ if ( this . status !== "Stopped" && this . durLabel != null ) this . durLabel . set_text ( this . time_for_label ( length ) ) ;
13021330 this . _wantedSeekValue = 0 ;
13031331 this . _updateValue ( ) ;
13041332 }
@@ -1314,15 +1342,16 @@ class Seeker extends Slider.Slider {
13141342 this . startingDate = Date . now ( ) - this . _wantedSeekValue * 1000 ;
13151343 this . setValue ( this . _wantedSeekValue / this . _length ) ;
13161344 this . _currentTime = this . _wantedSeekValue ;
1317- if ( this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
1345+ if ( this . status === "Playing" && this . posLabel != null ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
13181346 this . _wantedSeekValue = 0 ;
13191347 } else if ( ! this . _dragging ) {
13201348 if ( this . _length > 0 && this . _currentTime > 0 ) {
1321- if ( this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
1349+ if ( this . status === "Playing" && this . posLabel != null ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
13221350 this . setValue ( this . _currentTime / this . _length ) ;
13231351 } else {
13241352 this . setValue ( 0 ) ;
1325- if ( this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( " 00:00 " ) ;
1353+ if ( this . status === "Playing" && this . posLabel != null )
1354+ this . posLabel . set_text ( " 00:00:00 " ) ;
13261355 }
13271356 }
13281357 } else {
@@ -1334,10 +1363,10 @@ class Seeker extends Slider.Slider {
13341363 this . startingDate = Date . now ( ) - this . _wantedSeekValue * 1000 ;
13351364 this . setValue ( this . _wantedSeekValue / this . _length ) ;
13361365 this . _currentTime = this . _wantedSeekValue ;
1337- if ( this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
1366+ if ( this . status === "Playing" && this . posLabel != null ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
13381367 this . _wantedSeekValue = 0 ;
13391368 } else if ( ! this . _dragging ) {
1340- if ( this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
1369+ if ( this . status === "Playing" && this . posLabel != null ) this . posLabel . set_text ( this . time_for_label ( this . _currentTime ) ) ;
13411370 this . setValue ( this . _currentTime / this . _length ) ;
13421371 if ( this . _timeoutId != null ) {
13431372 source_remove ( this . _timeoutId ) ;
@@ -1361,7 +1390,8 @@ class Seeker extends Slider.Slider {
13611390 }
13621391 } else {
13631392 this . setValue ( 0 ) ;
1364- if ( ! this . destroyed && this . status === "Playing" && this . posLabel ) this . posLabel . set_text ( " 00:00 " ) ;
1393+ if ( ! this . destroyed && this . status === "Playing" && this . posLabel != null )
1394+ this . posLabel . set_text ( " 00:00:00 " ) ;
13651395 this . hideAll ( ) ;
13661396 }
13671397 }
0 commit comments