notify.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibCore/ArgsParser.h>
  7. #include <LibGUI/Application.h>
  8. #include <LibGUI/Notification.h>
  9. #include <LibGfx/Bitmap.h>
  10. int main(int argc, char** argv)
  11. {
  12. auto app = GUI::Application::construct(argc, argv);
  13. Core::ArgsParser args_parser;
  14. const char* title = nullptr;
  15. const char* message = nullptr;
  16. const char* icon_path = nullptr;
  17. args_parser.add_positional_argument(title, "Title of the notification", "title");
  18. args_parser.add_positional_argument(message, "Message to display in the notification", "message");
  19. args_parser.add_positional_argument(icon_path, "Path of icon to display in the notification", "icon-path", Core::ArgsParser::Required::No);
  20. args_parser.parse(argc, argv);
  21. auto notification = GUI::Notification::construct();
  22. notification->set_text(message);
  23. notification->set_title(title);
  24. notification->set_icon(Gfx::Bitmap::try_load_from_file(icon_path));
  25. notification->show();
  26. return 0;
  27. }