Serenity Operating System
1/*
2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibCore/ArgsParser.h>
8#include <LibGUI/Application.h>
9#include <LibGUI/Notification.h>
10#include <LibGfx/Bitmap.h>
11#include <LibMain/Main.h>
12
13ErrorOr<int> serenity_main(Main::Arguments arguments)
14{
15 auto app = TRY(GUI::Application::try_create(arguments));
16
17 Core::ArgsParser args_parser;
18 StringView title {};
19 StringView message {};
20 StringView icon_path {};
21 args_parser.add_positional_argument(title, "Title of the notification", "title");
22 args_parser.add_positional_argument(message, "Message to display in the notification", "message");
23 args_parser.add_positional_argument(icon_path, "Path of icon to display in the notification", "icon-path", Core::ArgsParser::Required::No);
24 args_parser.parse(arguments);
25
26 auto notification = TRY(GUI::Notification::try_create());
27 notification->set_text(message);
28 notification->set_title(title);
29 if (!icon_path.is_empty()) {
30 notification->set_icon(TRY(Gfx::Bitmap::load_from_file(icon_path)));
31 }
32 notification->show();
33
34 return 0;
35}