beep.cpp 697 B

123456789101112131415161718192021
  1. /*
  2. * Copyright (c) 2020-2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibCore/ArgsParser.h>
  7. #include <LibCore/System.h>
  8. #include <LibMain/Main.h>
  9. ErrorOr<int> serenity_main(Main::Arguments arguments)
  10. {
  11. Optional<size_t> tone;
  12. Optional<size_t> milliseconds_duration;
  13. Core::ArgsParser args_parser;
  14. args_parser.add_option(tone, "Beep tone", "beep-tone", 'f', "Beep tone (frequency in Hz)");
  15. args_parser.add_option(milliseconds_duration, "Duration", "duration", 'n', "Duration (in milliseconds)");
  16. args_parser.parse(arguments);
  17. TRY(Core::System::beep(tone.value_or(440), milliseconds_duration.value_or(200)));
  18. return 0;
  19. }