2020-12-16 15:40:29 +00:00
|
|
|
/*
|
2022-01-09 05:16:27 +00:00
|
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
2020-12-16 15:40:29 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-16 15:40:29 +00:00
|
|
|
*/
|
|
|
|
|
2023-03-01 20:05:04 +00:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2022-01-09 05:16:27 +00:00
|
|
|
#include <LibCore/System.h>
|
|
|
|
#include <LibMain/Main.h>
|
2020-12-16 15:40:29 +00:00
|
|
|
|
2023-03-01 20:05:04 +00:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-12-16 15:40:29 +00:00
|
|
|
{
|
2023-08-25 17:26:44 +00:00
|
|
|
TRY(Core::System::pledge("stdio rpath wpath"));
|
|
|
|
TRY(Core::System::unveil("/dev/beep", "rw"));
|
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2023-03-01 20:05:04 +00:00
|
|
|
Optional<size_t> tone;
|
2023-08-25 17:26:18 +00:00
|
|
|
Optional<size_t> milliseconds_duration;
|
2023-03-01 20:05:04 +00:00
|
|
|
Core::ArgsParser args_parser;
|
|
|
|
args_parser.add_option(tone, "Beep tone", "beep-tone", 'f', "Beep tone (frequency in Hz)");
|
2023-08-25 17:26:18 +00:00
|
|
|
args_parser.add_option(milliseconds_duration, "Duration", "duration", 'n', "Duration (in milliseconds)");
|
2023-03-01 20:05:04 +00:00
|
|
|
args_parser.parse(arguments);
|
2023-08-25 17:26:18 +00:00
|
|
|
TRY(Core::System::beep(tone.value_or(440), milliseconds_duration.value_or(200)));
|
2020-12-16 15:40:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|