3535#include < unistd.h>
3636#include < vector>
3737
38+ #include " ../common/notification.hpp"
39+
3840// Data in string to render in UI
3941std::vector<std::string> track_strings;
4042std::vector<std::string> home_track_strings;
@@ -231,7 +233,9 @@ void setupMPRISForDaemon(std::shared_ptr<MusicPlayer> player,
231233 int current_track_index) {
232234 mpris_handler = std::make_unique<MPRISHandler>(player);
233235 mpris_handler->initialize ();
234- system (" notify-send 'MPRIS integration initialized'" );
236+ // system("notify-send 'MPRIS integration initialized'");
237+ notifications::send (" MPRIS integration initialized" );
238+
235239
236240 mpris_handler->setTrackCallbacks (
237241 [&]() -> std::string {
@@ -385,7 +389,8 @@ int main(int argc, char *argv[]) {
385389 };
386390
387391 auto updateMetadata = [&]() {
388- system ((" notify-send 'Tuisic' 'Updating metadata'" ));
392+ // system(("notify-send 'Tuisic' 'Updating metadata'"));
393+ notifications::send (" updating songs" );
389394 std::map<std::string, sdbus::Variant> properties;
390395 properties[" Metadata" ] = sdbus::Variant (getMetadata ());
391396 g_concatenator->emitPropertiesChangedSignal (interfaceName2);
@@ -525,6 +530,9 @@ int main(int argc, char *argv[]) {
525530 curl_global_init (CURL_GLOBAL_ALL );
526531 auto config = std::make_shared<Config>();
527532
533+ // Initialize notification system with config
534+ notifications::init (config.get ());
535+
528536 using namespace ftxui ;
529537
530538 // Placeholder for search input
@@ -675,7 +683,8 @@ int main(int argc, char *argv[]) {
675683
676684 screen.PostEvent (Event::Custom);
677685 } catch (const std::exception &e) {
678- std::cerr << e.what () << std::endl;
686+ // std::cerr << e.what() << std::endl;
687+ notifications::send (" Error: " + std::string (e.what ()));
679688 }
680689 });
681690 next_tracks_thread.detach ();
@@ -695,19 +704,21 @@ int main(int argc, char *argv[]) {
695704 std::string is_wayland = getenv (" XDG_SESSION_TYPE" );
696705 if (is_wayland == " wayland" ) {
697706 system ((" echo \" " + url + " \" | wl-copy" ).c_str ());
698- system ((" notify-send \" Copied URL: " + url + " \" " ).c_str ());
699- std::cout << " Copied URL: " << url << std::endl;
707+ // system(("notify-send \"Copied URL: " + url + "\"").c_str());
708+ notifications::send_url_copied ();
709+ // std::cout << "Copied URL: " << url << std::endl;
700710 return true ;
701711 }
702- system (
703- ( " echo \" " + url + " \" | xclip -selection clipboard " ).c_str ());
704- system (( " notify-send \" Copied URL: " + url + " \" " ). c_str () );
705- std::cout << " Copied URL: " << url << std::endl;
712+ system (( " echo \" " + url + " \" | xclip -selection clipboard " ). c_str ());
713+ // system(("notify-send \"Copied URL: " + url + "\"").c_str());
714+ notifications::send_url_copied ( );
715+ // std::cout << "Copied URL: " << url << std::endl;
706716 return true ;
707717 }
708718 }
709719 if (event == Event::Character (' L' )) {
710- std::cerr << " pressed L" << std::endl;
720+ // std::cerr << "pressed L" << std::endl;
721+ notifications::send (" toggle subtitles" );
711722 player->toggle_subtitles ();
712723 }
713724
@@ -732,20 +743,24 @@ int main(int argc, char *argv[]) {
732743 // Start download
733744 if (player->download_track (track_data[selected].url , path,
734745 current_song)) {
735- system ((" notify-send \" Started downloading: " +
736- track_data[selected].name + " \" " )
737- .c_str ());
746+ // system(("notify-send \"Started downloading: " +
747+ // track_data[selected].name + "\"")
748+ // .c_str());
749+ notifications::send_download_started (" " + track_data[selected].name );
738750 } else {
739- system ((" notify-send \" Failed to start download: " +
740- track_data[selected].name + " \" " )
741- .c_str ());
751+ // system(("notify-send \"Failed to start download: " +
752+ // track_data[selected].name + "\"")
753+ // .c_str());
754+ notifications::send_download_failed (" " + track_data[selected].name );
755+
742756 }
743757 }
744758 return true ;
745759 }
746760 if (event == Event::Character (' p' )) {
747761 std::string some = config->get_download_path ();
748- system ((" notify-send \" Download path: " + some + " \" " ).c_str ());
762+ // system(("notify-send \"Download path: " + some + "\"").c_str());
763+ notifications::send (" Download path: " + some);
749764 }
750765
751766 if (event == Event::Character (' r' )) {
@@ -756,7 +771,8 @@ int main(int argc, char *argv[]) {
756771 #ifdef WITH_MPRIS
757772 daemon_mode_active = true ;
758773 // system(("notify-send \"Starting daemon..." + track[0].id.c_str() + "\"").c_str());
759- system ((" notify-send 'Starting daemon...'" ));
774+ // system(("notify-send 'Starting daemon...'"));
775+ notifications::send (" Starting daemon..." );
760776
761777
762778 std::string url = player->get_current_track ();
0 commit comments