123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/OS.xml.
- .. _class_OS:
- OS
- ==
- **Inherits:** :ref:`Object<class_Object>`
- Provides access to common operating system functionalities.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- The **OS** class wraps the most common functionalities for communicating with the host operating system, such as the video driver, delays, environment variables, execution of binaries, command line, etc.
- \ **Note:** In Godot 4, **OS** functions related to window management, clipboard, and TTS were moved to the :ref:`DisplayServer<class_DisplayServer>` singleton (and the :ref:`Window<class_Window>` class). Functions related to time were removed and are only available in the :ref:`Time<class_Time>` class.
- .. rst-class:: classref-introduction-group
- Tutorials
- ---------
- - `Operating System Testing Demo <https://godotengine.org/asset-library/asset/2789>`__
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
- | :ref:`bool<class_bool>` | :ref:`delta_smoothing<class_OS_property_delta_smoothing>` | ``true`` |
- +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
- | :ref:`bool<class_bool>` | :ref:`low_processor_usage_mode<class_OS_property_low_processor_usage_mode>` | ``false`` |
- +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
- | :ref:`int<class_int>` | :ref:`low_processor_usage_mode_sleep_usec<class_OS_property_low_processor_usage_mode_sleep_usec>` | ``6900`` |
- +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`alert<class_OS_method_alert>`\ (\ text\: :ref:`String<class_String>`, title\: :ref:`String<class_String>` = "Alert!"\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`crash<class_OS_method_crash>`\ (\ message\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`create_instance<class_OS_method_create_instance>`\ (\ arguments\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`create_process<class_OS_method_create_process>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, open_console\: :ref:`bool<class_bool>` = false\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`delay_msec<class_OS_method_delay_msec>`\ (\ msec\: :ref:`int<class_int>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`delay_usec<class_OS_method_delay_usec>`\ (\ usec\: :ref:`int<class_int>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`execute<class_OS_method_execute>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, output\: :ref:`Array<class_Array>` = [], read_stderr\: :ref:`bool<class_bool>` = false, open_console\: :ref:`bool<class_bool>` = false\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Dictionary<class_Dictionary>` | :ref:`execute_with_pipe<class_OS_method_execute_with_pipe>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, blocking\: :ref:`bool<class_bool>` = true\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Key<enum_@GlobalScope_Key>` | :ref:`find_keycode_from_string<class_OS_method_find_keycode_from_string>`\ (\ string\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_cache_dir<class_OS_method_get_cache_dir>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_config_dir<class_OS_method_get_config_dir>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_data_dir<class_OS_method_get_data_dir>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_distribution_name<class_OS_method_get_distribution_name>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_entropy<class_OS_method_get_entropy>`\ (\ size\: :ref:`int<class_int>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_environment<class_OS_method_get_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_executable_path<class_OS_method_get_executable_path>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_granted_permissions<class_OS_method_get_granted_permissions>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_keycode_string<class_OS_method_get_keycode_string>`\ (\ code\: :ref:`Key<enum_@GlobalScope_Key>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_locale<class_OS_method_get_locale>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_locale_language<class_OS_method_get_locale_language>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_main_thread_id<class_OS_method_get_main_thread_id>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Dictionary<class_Dictionary>` | :ref:`get_memory_info<class_OS_method_get_memory_info>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_model_name<class_OS_method_get_model_name>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_name<class_OS_method_get_name>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_process_exit_code<class_OS_method_get_process_exit_code>`\ (\ pid\: :ref:`int<class_int>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_process_id<class_OS_method_get_process_id>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_processor_count<class_OS_method_get_processor_count>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_processor_name<class_OS_method_get_processor_name>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_static_memory_peak_usage<class_OS_method_get_static_memory_peak_usage>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_static_memory_usage<class_OS_method_get_static_memory_usage>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stderr_type<class_OS_method_get_stderr_type>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stdin_type<class_OS_method_get_stdin_type>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stdout_type<class_OS_method_get_stdout_type>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_system_ca_certificates<class_OS_method_get_system_ca_certificates>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_system_dir<class_OS_method_get_system_dir>`\ (\ dir\: :ref:`SystemDir<enum_OS_SystemDir>`, shared_storage\: :ref:`bool<class_bool>` = true\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_system_font_path<class_OS_method_get_system_font_path>`\ (\ font_name\: :ref:`String<class_String>`, weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_font_path_for_text<class_OS_method_get_system_font_path_for_text>`\ (\ font_name\: :ref:`String<class_String>`, text\: :ref:`String<class_String>`, locale\: :ref:`String<class_String>` = "", script\: :ref:`String<class_String>` = "", weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_fonts<class_OS_method_get_system_fonts>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_temp_dir<class_OS_method_get_temp_dir>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_unique_id<class_OS_method_get_unique_id>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_version<class_OS_method_get_version>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_version_alias<class_OS_method_get_version_alias>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_video_adapter_driver_info<class_OS_method_get_video_adapter_driver_info>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`has_environment<class_OS_method_has_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`has_feature<class_OS_method_has_feature>`\ (\ tag_name\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_debug_build<class_OS_method_is_debug_build>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_keycode_unicode<class_OS_method_is_keycode_unicode>`\ (\ code\: :ref:`int<class_int>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_process_running<class_OS_method_is_process_running>`\ (\ pid\: :ref:`int<class_int>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_sandboxed<class_OS_method_is_sandboxed>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_stdout_verbose<class_OS_method_is_stdout_verbose>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_userfs_persistent<class_OS_method_is_userfs_persistent>`\ (\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`kill<class_OS_method_kill>`\ (\ pid\: :ref:`int<class_int>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`move_to_trash<class_OS_method_move_to_trash>`\ (\ path\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`read_buffer_from_stdin<class_OS_method_read_buffer_from_stdin>`\ (\ buffer_size\: :ref:`int<class_int>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>`\ (\ buffer_size\: :ref:`int<class_int>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`request_permission<class_OS_method_request_permission>`\ (\ name\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`request_permissions<class_OS_method_request_permissions>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`revoke_granted_permissions<class_OS_method_revoke_granted_permissions>`\ (\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_environment<class_OS_method_set_environment>`\ (\ variable\: :ref:`String<class_String>`, value\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>`\ (\ restart\: :ref:`bool<class_bool>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>` = PackedStringArray()\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`set_thread_name<class_OS_method_set_thread_name>`\ (\ name\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_use_file_access_save_and_swap<class_OS_method_set_use_file_access_save_and_swap>`\ (\ enabled\: :ref:`bool<class_bool>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_open<class_OS_method_shell_open>`\ (\ uri\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_show_in_file_manager<class_OS_method_shell_show_in_file_manager>`\ (\ file_or_dir_path\: :ref:`String<class_String>`, open_folder\: :ref:`bool<class_bool>` = true\ ) |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`unset_environment<class_OS_method_unset_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Enumerations
- ------------
- .. _enum_OS_RenderingDriver:
- .. rst-class:: classref-enumeration
- enum **RenderingDriver**: :ref:`๐<enum_OS_RenderingDriver>`
- .. _class_OS_constant_RENDERING_DRIVER_VULKAN:
- .. rst-class:: classref-enumeration-constant
- :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_VULKAN** = ``0``
- The Vulkan rendering driver. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
- .. _class_OS_constant_RENDERING_DRIVER_OPENGL3:
- .. rst-class:: classref-enumeration-constant
- :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_OPENGL3** = ``1``
- The OpenGL 3 rendering driver. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on Web.
- .. _class_OS_constant_RENDERING_DRIVER_D3D12:
- .. rst-class:: classref-enumeration-constant
- :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_D3D12** = ``2``
- The Direct3D 12 rendering driver.
- .. _class_OS_constant_RENDERING_DRIVER_METAL:
- .. rst-class:: classref-enumeration-constant
- :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_METAL** = ``3``
- The Metal rendering driver.
- .. rst-class:: classref-item-separator
- ----
- .. _enum_OS_SystemDir:
- .. rst-class:: classref-enumeration
- enum **SystemDir**: :ref:`๐<enum_OS_SystemDir>`
- .. _class_OS_constant_SYSTEM_DIR_DESKTOP:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DESKTOP** = ``0``
- Refers to the Desktop directory path.
- .. _class_OS_constant_SYSTEM_DIR_DCIM:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DCIM** = ``1``
- Refers to the DCIM (Digital Camera Images) directory path.
- .. _class_OS_constant_SYSTEM_DIR_DOCUMENTS:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOCUMENTS** = ``2``
- Refers to the Documents directory path.
- .. _class_OS_constant_SYSTEM_DIR_DOWNLOADS:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOWNLOADS** = ``3``
- Refers to the Downloads directory path.
- .. _class_OS_constant_SYSTEM_DIR_MOVIES:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MOVIES** = ``4``
- Refers to the Movies (or Videos) directory path.
- .. _class_OS_constant_SYSTEM_DIR_MUSIC:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MUSIC** = ``5``
- Refers to the Music directory path.
- .. _class_OS_constant_SYSTEM_DIR_PICTURES:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_PICTURES** = ``6``
- Refers to the Pictures directory path.
- .. _class_OS_constant_SYSTEM_DIR_RINGTONES:
- .. rst-class:: classref-enumeration-constant
- :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_RINGTONES** = ``7``
- Refers to the Ringtones directory path.
- .. rst-class:: classref-item-separator
- ----
- .. _enum_OS_StdHandleType:
- .. rst-class:: classref-enumeration
- enum **StdHandleType**: :ref:`๐<enum_OS_StdHandleType>`
- .. _class_OS_constant_STD_HANDLE_INVALID:
- .. rst-class:: classref-enumeration-constant
- :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_INVALID** = ``0``
- Standard I/O device is invalid. No data can be received from or sent to these standard I/O devices.
- .. _class_OS_constant_STD_HANDLE_CONSOLE:
- .. rst-class:: classref-enumeration-constant
- :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_CONSOLE** = ``1``
- Standard I/O device is a console. This typically occurs when Godot is run from a terminal with no redirection. This is also used for all standard I/O devices when running Godot from the editor, at least on desktop platforms.
- .. _class_OS_constant_STD_HANDLE_FILE:
- .. rst-class:: classref-enumeration-constant
- :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_FILE** = ``2``
- Standard I/O device is a regular file. This typically occurs with redirection from a terminal, e.g. ``godot > stdout.txt``, ``godot < stdin.txt`` or ``godot > stdout_stderr.txt 2>&1``.
- .. _class_OS_constant_STD_HANDLE_PIPE:
- .. rst-class:: classref-enumeration-constant
- :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_PIPE** = ``3``
- Standard I/O device is a FIFO/pipe. This typically occurs with pipe usage from a terminal, e.g. ``echo "Hello" | godot``.
- .. _class_OS_constant_STD_HANDLE_UNKNOWN:
- .. rst-class:: classref-enumeration-constant
- :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_UNKNOWN** = ``4``
- Standard I/O device type is unknown.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_OS_property_delta_smoothing:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **delta_smoothing** = ``true`` :ref:`๐<class_OS_property_delta_smoothing>`
- .. rst-class:: classref-property-setget
- - |void| **set_delta_smoothing**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **is_delta_smoothing_enabled**\ (\ )
- If ``true``, the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This only works on systems where V-Sync is active.
- \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/delta_smoothing<class_ProjectSettings_property_application/run/delta_smoothing>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_property_low_processor_usage_mode:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **low_processor_usage_mode** = ``false`` :ref:`๐<class_OS_property_low_processor_usage_mode>`
- .. rst-class:: classref-property-setget
- - |void| **set_low_processor_usage_mode**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **is_in_low_processor_usage_mode**\ (\ )
- If ``true``, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.
- \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/low_processor_mode<class_ProjectSettings_property_application/run/low_processor_mode>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_property_low_processor_usage_mode_sleep_usec:
- .. rst-class:: classref-property
- :ref:`int<class_int>` **low_processor_usage_mode_sleep_usec** = ``6900`` :ref:`๐<class_OS_property_low_processor_usage_mode_sleep_usec>`
- .. rst-class:: classref-property-setget
- - |void| **set_low_processor_usage_mode_sleep_usec**\ (\ value\: :ref:`int<class_int>`\ )
- - :ref:`int<class_int>` **get_low_processor_usage_mode_sleep_usec**\ (\ )
- The amount of sleeping between frames when the low-processor usage mode is enabled, in microseconds. Higher values will result in lower CPU usage. See also :ref:`low_processor_usage_mode<class_OS_property_low_processor_usage_mode>`.
- \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/low_processor_mode_sleep_usec<class_ProjectSettings_property_application/run/low_processor_mode_sleep_usec>`.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_OS_method_alert:
- .. rst-class:: classref-method
- |void| **alert**\ (\ text\: :ref:`String<class_String>`, title\: :ref:`String<class_String>` = "Alert!"\ ) :ref:`๐<class_OS_method_alert>`
- Displays a modal dialog box using the host platform's implementation. The engine execution is blocked until the dialog is closed.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_close_midi_inputs:
- .. rst-class:: classref-method
- |void| **close_midi_inputs**\ (\ ) :ref:`๐<class_OS_method_close_midi_inputs>`
- Shuts down the system MIDI driver. Godot will no longer receive :ref:`InputEventMIDI<class_InputEventMIDI>`. See also :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>` and :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>`.
- \ **Note:** This method is implemented on Linux, macOS, Windows, and Web.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_crash:
- .. rst-class:: classref-method
- |void| **crash**\ (\ message\: :ref:`String<class_String>`\ ) :ref:`๐<class_OS_method_crash>`
- Crashes the engine (or the editor if called within a ``@tool`` script). See also :ref:`kill<class_OS_method_kill>`.
- \ **Note:** This method should *only* be used for testing the system's crash handler, not for any other purpose. For general error reporting, use (in order of preference) :ref:`@GDScript.assert<class_@GDScript_method_assert>`, :ref:`@GlobalScope.push_error<class_@GlobalScope_method_push_error>`, or :ref:`alert<class_OS_method_alert>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_create_instance:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **create_instance**\ (\ arguments\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) :ref:`๐<class_OS_method_create_instance>`
- Creates a new instance of Godot that runs independently. The ``arguments`` are used in the given order and separated by a space.
- If the process is successfully created, this method returns the new process' ID, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`). If the process cannot be created, this method returns ``-1``.
- See :ref:`create_process<class_OS_method_create_process>` if you wish to run a different process.
- \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_create_process:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **create_process**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, open_console\: :ref:`bool<class_bool>` = false\ ) :ref:`๐<class_OS_method_create_process>`
- Creates a new process that runs independently of Godot. It will not terminate when Godot terminates. The path specified in ``path`` must exist and be an executable file or macOS ``.app`` bundle. The path is resolved based on the current platform. The ``arguments`` are used in the given order and separated by a space.
- On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window will be opened.
- If the process is successfully created, this method returns its process ID, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`). Otherwise, this method returns ``-1``.
- \ **Example:** Run another instance of the project:
- .. tabs::
- .. code-tab:: gdscript
- var pid = OS.create_process(OS.get_executable_path(), [])
- .. code-tab:: csharp
- var pid = OS.CreateProcess(OS.GetExecutablePath(), []);
- See :ref:`execute<class_OS_method_execute>` if you wish to run an external command and retrieve the results.
- \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
- \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_delay_msec:
- .. rst-class:: classref-method
- |void| **delay_msec**\ (\ msec\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_OS_method_delay_msec>`
- Delays execution of the current thread by ``msec`` milliseconds. ``msec`` must be greater than or equal to ``0``. Otherwise, :ref:`delay_msec<class_OS_method_delay_msec>` does nothing and prints an error message.
- \ **Note:** :ref:`delay_msec<class_OS_method_delay_msec>` is a *blocking* way to delay code execution. To delay code execution in a non-blocking way, you may use :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with :ref:`SceneTreeTimer<class_SceneTreeTimer>` delays the execution of code placed below the ``await`` without affecting the rest of the project (or editor, for :ref:`EditorPlugin<class_EditorPlugin>`\ s and :ref:`EditorScript<class_EditorScript>`\ s).
- \ **Note:** When :ref:`delay_msec<class_OS_method_delay_msec>` is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using :ref:`delay_msec<class_OS_method_delay_msec>` as part of an :ref:`EditorPlugin<class_EditorPlugin>` or :ref:`EditorScript<class_EditorScript>`, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_delay_usec:
- .. rst-class:: classref-method
- |void| **delay_usec**\ (\ usec\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_OS_method_delay_usec>`
- Delays execution of the current thread by ``usec`` microseconds. ``usec`` must be greater than or equal to ``0``. Otherwise, :ref:`delay_usec<class_OS_method_delay_usec>` does nothing and prints an error message.
- \ **Note:** :ref:`delay_usec<class_OS_method_delay_usec>` is a *blocking* way to delay code execution. To delay code execution in a non-blocking way, you may use :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with a :ref:`SceneTreeTimer<class_SceneTreeTimer>` delays the execution of code placed below the ``await`` without affecting the rest of the project (or editor, for :ref:`EditorPlugin<class_EditorPlugin>`\ s and :ref:`EditorScript<class_EditorScript>`\ s).
- \ **Note:** When :ref:`delay_usec<class_OS_method_delay_usec>` is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using :ref:`delay_usec<class_OS_method_delay_usec>` as part of an :ref:`EditorPlugin<class_EditorPlugin>` or :ref:`EditorScript<class_EditorScript>`, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_execute:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **execute**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, output\: :ref:`Array<class_Array>` = [], read_stderr\: :ref:`bool<class_bool>` = false, open_console\: :ref:`bool<class_bool>` = false\ ) :ref:`๐<class_OS_method_execute>`
- Executes the given process in a *blocking* way. The file specified in ``path`` must exist and be executable. The system path resolution will be used. The ``arguments`` are used in the given order, separated by spaces, and wrapped in quotes.
- If an ``output`` array is provided, the complete shell output of the process is appended to ``output`` as a single :ref:`String<class_String>` element. If ``read_stderr`` is ``true``, the output to the standard error stream is also appended to the array.
- On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window is opened.
- This method returns the exit code of the command, or ``-1`` if the process fails to execute.
- \ **Note:** The main thread will be blocked until the executed command terminates. Use :ref:`Thread<class_Thread>` to create a separate thread that will not block the main thread, or use :ref:`create_process<class_OS_method_create_process>` to create a completely independent process.
- For example, to retrieve a list of the working directory's contents:
- .. tabs::
- .. code-tab:: gdscript
- var output = []
- var exit_code = OS.execute("ls", ["-l", "/tmp"], output)
- .. code-tab:: csharp
- Godot.Collections.Array output = [];
- int exitCode = OS.Execute("ls", ["-l", "/tmp"], output);
- If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example:
- .. tabs::
- .. code-tab:: gdscript
- var output = []
- OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output)
- .. code-tab:: csharp
- Godot.Collections.Array output = [];
- OS.Execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output);
- \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
- \ **Note:** To execute a Windows command interpreter built-in command, specify ``cmd.exe`` in ``path``, ``/c`` as the first argument, and the desired command as the second argument.
- \ **Note:** To execute a PowerShell built-in command, specify ``powershell.exe`` in ``path``, ``-Command`` as the first argument, and the desired command as the second argument.
- \ **Note:** To execute a Unix shell built-in command, specify shell executable name in ``path``, ``-c`` as the first argument, and the desired command as the second argument.
- \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
- \ **Note:** On Android, system commands such as ``dumpsys`` can only be run on a rooted device.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_execute_with_pipe:
- .. rst-class:: classref-method
- :ref:`Dictionary<class_Dictionary>` **execute_with_pipe**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, blocking\: :ref:`bool<class_bool>` = true\ ) :ref:`๐<class_OS_method_execute_with_pipe>`
- Creates a new process that runs independently of Godot with redirected IO. It will not terminate when Godot terminates. The path specified in ``path`` must exist and be an executable file or macOS ``.app`` bundle. The path is resolved based on the current platform. The ``arguments`` are used in the given order and separated by a space.
- If ``blocking`` is ``false``, created pipes work in non-blocking mode, i.e. read and write operations will return immediately. Use :ref:`FileAccess.get_error<class_FileAccess_method_get_error>` to check if the last read/write operation was successful.
- If the process cannot be created, this method returns an empty :ref:`Dictionary<class_Dictionary>`. Otherwise, this method returns a :ref:`Dictionary<class_Dictionary>` with the following keys:
- - ``"stdio"`` - :ref:`FileAccess<class_FileAccess>` to access the process stdin and stdout pipes (read/write).
- - ``"stderr"`` - :ref:`FileAccess<class_FileAccess>` to access the process stderr pipe (read only).
- - ``"pid"`` - Process ID as an :ref:`int<class_int>`, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`).
- \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
- \ **Note:** To execute a Windows command interpreter built-in command, specify ``cmd.exe`` in ``path``, ``/c`` as the first argument, and the desired command as the second argument.
- \ **Note:** To execute a PowerShell built-in command, specify ``powershell.exe`` in ``path``, ``-Command`` as the first argument, and the desired command as the second argument.
- \ **Note:** To execute a Unix shell built-in command, specify shell executable name in ``path``, ``-c`` as the first argument, and the desired command as the second argument.
- \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_find_keycode_from_string:
- .. rst-class:: classref-method
- :ref:`Key<enum_@GlobalScope_Key>` **find_keycode_from_string**\ (\ string\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_find_keycode_from_string>`
- Finds the keycode for the given string. The returned values are equivalent to the :ref:`Key<enum_@GlobalScope_Key>` constants.
- .. tabs::
- .. code-tab:: gdscript
- print(OS.find_keycode_from_string("C")) # Prints 67 (KEY_C)
- print(OS.find_keycode_from_string("Escape")) # Prints 4194305 (KEY_ESCAPE)
- print(OS.find_keycode_from_string("Shift+Tab")) # Prints 37748738 (KEY_MASK_SHIFT | KEY_TAB)
- print(OS.find_keycode_from_string("Unknown")) # Prints 0 (KEY_NONE)
- .. code-tab:: csharp
- GD.Print(OS.FindKeycodeFromString("C")); // Prints C (Key.C)
- GD.Print(OS.FindKeycodeFromString("Escape")); // Prints Escape (Key.Escape)
- GD.Print(OS.FindKeycodeFromString("Shift+Tab")); // Prints 37748738 (KeyModifierMask.MaskShift | Key.Tab)
- GD.Print(OS.FindKeycodeFromString("Unknown")); // Prints None (Key.None)
- See also :ref:`get_keycode_string<class_OS_method_get_keycode_string>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_cache_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_cache_dir**\ (\ ) |const| :ref:`๐<class_OS_method_get_cache_dir>`
- Returns the *global* cache data directory according to the operating system's standards.
- On the Linux/BSD platform, this path can be overridden by setting the ``XDG_CACHE_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_config_dir<class_OS_method_get_config_dir>` and :ref:`get_data_dir<class_OS_method_get_data_dir>`.
- Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_cmdline_args:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_args**\ (\ ) :ref:`๐<class_OS_method_get_cmdline_args>`
- Returns the command-line arguments passed to the engine.
- Command-line arguments can be written in any form, including both ``--key value`` and ``--key=value`` forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.
- You can also incorporate environment variables using the :ref:`get_environment<class_OS_method_get_environment>` method.
- You can set :ref:`ProjectSettings.editor/run/main_run_args<class_ProjectSettings_property_editor/run/main_run_args>` to define command-line arguments to be passed by the editor when running the project.
- \ **Example:** Parse command-line arguments into a :ref:`Dictionary<class_Dictionary>` using the ``--key=value`` form for arguments:
- .. tabs::
- .. code-tab:: gdscript
- var arguments = {}
- for argument in OS.get_cmdline_args():
- if argument.contains("="):
- var key_value = argument.split("=")
- arguments[key_value[0].trim_prefix("--")] = key_value[1]
- else:
- # Options without an argument will be present in the dictionary,
- # with the value set to an empty string.
- arguments[argument.trim_prefix("--")] = ""
- .. code-tab:: csharp
- var arguments = new Dictionary<string, string>();
- foreach (var argument in OS.GetCmdlineArgs())
- {
- if (argument.Contains('='))
- {
- string[] keyValue = argument.Split("=");
- arguments[keyValue[0].TrimPrefix("--")] = keyValue[1];
- }
- else
- {
- // Options without an argument will be present in the dictionary,
- // with the value set to an empty string.
- arguments[argument.TrimPrefix("--")] = "";
- }
- }
- \ **Note:** Passing custom user arguments directly is not recommended, as the engine may discard or modify them. Instead, pass the standard UNIX double dash (``--``) and then the custom arguments, which the engine will ignore by design. These can be read via :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_cmdline_user_args:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_user_args**\ (\ ) :ref:`๐<class_OS_method_get_cmdline_user_args>`
- Returns the command-line user arguments passed to the engine. User arguments are ignored by the engine and reserved for the user. They are passed after the double dash ``--`` argument. ``++`` may be used when ``--`` is intercepted by another program (such as ``startx``).
- ::
- # Godot has been executed with the following command:
- # godot --fullscreen -- --level=2 --hardcore
-
- OS.get_cmdline_args() # Returns ["--fullscreen", "--level=2", "--hardcore"]
- OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"]
- To get all passed arguments, use :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_config_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_config_dir**\ (\ ) |const| :ref:`๐<class_OS_method_get_config_dir>`
- Returns the *global* user configuration directory according to the operating system's standards.
- On the Linux/BSD platform, this path can be overridden by setting the ``XDG_CONFIG_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_cache_dir<class_OS_method_get_cache_dir>` and :ref:`get_data_dir<class_OS_method_get_data_dir>`.
- Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_connected_midi_inputs:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_connected_midi_inputs**\ (\ ) :ref:`๐<class_OS_method_get_connected_midi_inputs>`
- Returns an array of connected MIDI device names, if they exist. Returns an empty array if the system MIDI driver has not previously been initialized with :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`. See also :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`.
- \ **Note:** This method is implemented on Linux, macOS, Windows, and Web.
- \ **Note:** On the Web platform, Web MIDI needs to be supported by the browser. `For the time being <https://caniuse.com/midi>`__, it is currently supported by all major browsers, except Safari.
- \ **Note:** On the Web platform, using MIDI input requires a browser permission to be granted first. This permission request is performed when calling :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`. The browser will refrain from processing MIDI input until the user accepts the permission request.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_data_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_data_dir**\ (\ ) |const| :ref:`๐<class_OS_method_get_data_dir>`
- Returns the *global* user data directory according to the operating system's standards.
- On the Linux/BSD platform, this path can be overridden by setting the ``XDG_DATA_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_cache_dir<class_OS_method_get_cache_dir>` and :ref:`get_config_dir<class_OS_method_get_config_dir>`.
- Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_distribution_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_distribution_name**\ (\ ) |const| :ref:`๐<class_OS_method_get_distribution_name>`
- Returns the name of the distribution for Linux and BSD platforms (e.g. "Ubuntu", "Manjaro", "OpenBSD", etc.).
- Returns the same value as :ref:`get_name<class_OS_method_get_name>` for stock Android ROMs, but attempts to return the custom ROM name for popular Android derivatives such as "LineageOS".
- Returns the same value as :ref:`get_name<class_OS_method_get_name>` for other platforms.
- \ **Note:** This method is not supported on the Web platform. It returns an empty string.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_entropy:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **get_entropy**\ (\ size\: :ref:`int<class_int>`\ ) :ref:`๐<class_OS_method_get_entropy>`
- Generates a :ref:`PackedByteArray<class_PackedByteArray>` of cryptographically secure random bytes with given ``size``.
- \ **Note:** Generating large quantities of bytes using this method can result in locking and entropy of lower quality on most platforms. Using :ref:`Crypto.generate_random_bytes<class_Crypto_method_generate_random_bytes>` is preferred in most cases.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_environment:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_get_environment>`
- Returns the value of the given environment variable, or an empty string if ``variable`` doesn't exist.
- \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
- \ **Note:** On macOS, applications do not have access to shell environment variables.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_executable_path:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_executable_path**\ (\ ) |const| :ref:`๐<class_OS_method_get_executable_path>`
- Returns the file path to the current engine executable.
- \ **Note:** On macOS, if you want to launch another instance of Godot, always use :ref:`create_instance<class_OS_method_create_instance>` instead of relying on the executable path.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_granted_permissions:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_granted_permissions**\ (\ ) |const| :ref:`๐<class_OS_method_get_granted_permissions>`
- On Android devices: Returns the list of dangerous permissions that have been granted.
- On macOS: Returns the list of user selected folders accessible to the application (sandboxed applications only). Use the native file dialog to request folder access permission.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_keycode_string:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_keycode_string**\ (\ code\: :ref:`Key<enum_@GlobalScope_Key>`\ ) |const| :ref:`๐<class_OS_method_get_keycode_string>`
- Returns the given keycode as a :ref:`String<class_String>`.
- .. tabs::
- .. code-tab:: gdscript
- print(OS.get_keycode_string(KEY_C)) # Prints "C"
- print(OS.get_keycode_string(KEY_ESCAPE)) # Prints "Escape"
- print(OS.get_keycode_string(KEY_MASK_SHIFT | KEY_TAB)) # Prints "Shift+Tab"
- .. code-tab:: csharp
- GD.Print(OS.GetKeycodeString(Key.C)); // Prints "C"
- GD.Print(OS.GetKeycodeString(Key.Escape)); // Prints "Escape"
- GD.Print(OS.GetKeycodeString((Key)KeyModifierMask.MaskShift | Key.Tab)); // Prints "Shift+Tab"
- See also :ref:`find_keycode_from_string<class_OS_method_find_keycode_from_string>`, :ref:`InputEventKey.keycode<class_InputEventKey_property_keycode>`, and :ref:`InputEventKey.get_keycode_with_modifiers<class_InputEventKey_method_get_keycode_with_modifiers>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_locale:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_locale**\ (\ ) |const| :ref:`๐<class_OS_method_get_locale>`
- Returns the host OS locale as a :ref:`String<class_String>` of the form ``language_Script_COUNTRY_VARIANT@extra``. Every substring after ``language`` is optional and may not exist.
- - ``language`` - 2 or 3-letter `language code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__, in lower case.
- - ``Script`` - 4-letter `script code <https://en.wikipedia.org/wiki/ISO_15924>`__, in title case.
- - ``COUNTRY`` - 2 or 3-letter `country code <https://en.wikipedia.org/wiki/ISO_3166-1>`__, in upper case.
- - ``VARIANT`` - language variant, region and sort order. The variant can have any number of underscored keywords.
- - ``extra`` - semicolon separated list of additional key words. This may include currency, calendar, sort order and numbering system information.
- If you want only the language code and not the fully specified locale from the OS, you can use :ref:`get_locale_language<class_OS_method_get_locale_language>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_locale_language:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_locale_language**\ (\ ) |const| :ref:`๐<class_OS_method_get_locale_language>`
- Returns the host OS locale's 2 or 3-letter `language code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__ as a string which should be consistent on all platforms. This is equivalent to extracting the ``language`` part of the :ref:`get_locale<class_OS_method_get_locale>` string.
- This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with ``fr_CA`` locale, this would return ``fr``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_main_thread_id:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_main_thread_id**\ (\ ) |const| :ref:`๐<class_OS_method_get_main_thread_id>`
- Returns the ID of the main thread. See :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>`.
- \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_memory_info:
- .. rst-class:: classref-method
- :ref:`Dictionary<class_Dictionary>` **get_memory_info**\ (\ ) |const| :ref:`๐<class_OS_method_get_memory_info>`
- Returns a :ref:`Dictionary<class_Dictionary>` containing information about the current memory with the following entries:
- - ``"physical"`` - total amount of usable physical memory in bytes. This value can be slightly less than the actual physical memory amount, since it does not include memory reserved by the kernel and devices.
- - ``"free"`` - amount of physical memory, that can be immediately allocated without disk access or other costly operations, in bytes. The process might be able to allocate more physical memory, but this action will require moving inactive pages to disk, which can be expensive.
- - ``"available"`` - amount of memory that can be allocated without extending the swap file(s), in bytes. This value includes both physical memory and swap.
- - ``"stack"`` - size of the current thread stack in bytes.
- \ **Note:** Each entry's value may be ``-1`` if it is unknown.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_model_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_model_name**\ (\ ) |const| :ref:`๐<class_OS_method_get_model_name>`
- Returns the model name of the current device.
- \ **Note:** This method is implemented on Android, iOS, macOS, and Windows. Returns ``"GenericDevice"`` on unsupported platforms.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_name**\ (\ ) |const| :ref:`๐<class_OS_method_get_name>`
- Returns the name of the host platform.
- - On Windows, this is ``"Windows"``.
- - On macOS, this is ``"macOS"``.
- - On Linux-based operating systems, this is ``"Linux"``.
- - On BSD-based operating systems, this is ``"FreeBSD"``, ``"NetBSD"``, ``"OpenBSD"``, or ``"BSD"`` as a fallback.
- - On Android, this is ``"Android"``.
- - On iOS, this is ``"iOS"``.
- - On Web, this is ``"Web"``.
- \ **Note:** Custom builds of the engine may support additional platforms, such as consoles, possibly returning other names.
- .. tabs::
- .. code-tab:: gdscript
- match OS.get_name():
- "Windows":
- print("Welcome to Windows!")
- "macOS":
- print("Welcome to macOS!")
- "Linux", "FreeBSD", "NetBSD", "OpenBSD", "BSD":
- print("Welcome to Linux/BSD!")
- "Android":
- print("Welcome to Android!")
- "iOS":
- print("Welcome to iOS!")
- "Web":
- print("Welcome to the Web!")
- .. code-tab:: csharp
- switch (OS.GetName())
- {
- case "Windows":
- GD.Print("Welcome to Windows");
- break;
- case "macOS":
- GD.Print("Welcome to macOS!");
- break;
- case "Linux":
- case "FreeBSD":
- case "NetBSD":
- case "OpenBSD":
- case "BSD":
- GD.Print("Welcome to Linux/BSD!");
- break;
- case "Android":
- GD.Print("Welcome to Android!");
- break;
- case "iOS":
- GD.Print("Welcome to iOS!");
- break;
- case "Web":
- GD.Print("Welcome to the Web!");
- break;
- }
- \ **Note:** On Web platforms, it is still possible to determine the host platform's OS with feature tags. See :ref:`has_feature<class_OS_method_has_feature>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_process_exit_code:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_process_exit_code**\ (\ pid\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_OS_method_get_process_exit_code>`
- Returns the exit code of a spawned process once it has finished running (see :ref:`is_process_running<class_OS_method_is_process_running>`).
- Returns ``-1`` if the ``pid`` is not a PID of a spawned child process, the process is still running, or the method is not implemented for the current platform.
- \ **Note:** Returns ``-1`` if the ``pid`` is a macOS bundled app process.
- \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_process_id:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_process_id**\ (\ ) |const| :ref:`๐<class_OS_method_get_process_id>`
- Returns the number used by the host machine to uniquely identify this application.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS, and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_processor_count:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_processor_count**\ (\ ) |const| :ref:`๐<class_OS_method_get_processor_count>`
- Returns the number of *logical* CPU cores available on the host machine. On CPUs with HyperThreading enabled, this number will be greater than the number of *physical* CPU cores.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_processor_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_processor_name**\ (\ ) |const| :ref:`๐<class_OS_method_get_processor_name>`
- Returns the full name of the CPU model on the host machine (e.g. ``"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"``).
- \ **Note:** This method is only implemented on Windows, macOS, Linux and iOS. On Android and Web, :ref:`get_processor_name<class_OS_method_get_processor_name>` returns an empty string.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_restart_on_exit_arguments:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_restart_on_exit_arguments**\ (\ ) |const| :ref:`๐<class_OS_method_get_restart_on_exit_arguments>`
- Returns the list of command line arguments that will be used when the project automatically restarts using :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>`. See also :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_static_memory_peak_usage:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_static_memory_peak_usage**\ (\ ) |const| :ref:`๐<class_OS_method_get_static_memory_peak_usage>`
- Returns the maximum amount of static memory used. Only works in debug builds.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_static_memory_usage:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_static_memory_usage**\ (\ ) |const| :ref:`๐<class_OS_method_get_static_memory_usage>`
- Returns the amount of static memory being used by the program in bytes. Only works in debug builds.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_stderr_type:
- .. rst-class:: classref-method
- :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stderr_type**\ (\ ) |const| :ref:`๐<class_OS_method_get_stderr_type>`
- Returns type of the standard error device.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_stdin_type:
- .. rst-class:: classref-method
- :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stdin_type**\ (\ ) |const| :ref:`๐<class_OS_method_get_stdin_type>`
- Returns type of the standard input device.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_stdout_type:
- .. rst-class:: classref-method
- :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stdout_type**\ (\ ) |const| :ref:`๐<class_OS_method_get_stdout_type>`
- Returns type of the standard output device.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_system_ca_certificates:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_system_ca_certificates**\ (\ ) :ref:`๐<class_OS_method_get_system_ca_certificates>`
- Returns the list of certification authorities trusted by the operating system as a string of concatenated certificates in PEM format.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_system_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_system_dir**\ (\ dir\: :ref:`SystemDir<enum_OS_SystemDir>`, shared_storage\: :ref:`bool<class_bool>` = true\ ) |const| :ref:`๐<class_OS_method_get_system_dir>`
- Returns the path to commonly used folders across different platforms, as defined by ``dir``. See the :ref:`SystemDir<enum_OS_SystemDir>` constants for available locations.
- \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
- \ **Note:** Shared storage is implemented on Android and allows to differentiate between app specific and shared directories, if ``shared_storage`` is ``true``. Shared directories have additional restrictions on Android.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_system_font_path:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_system_font_path**\ (\ font_name\: :ref:`String<class_String>`, weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐<class_OS_method_get_system_font_path>`
- Returns the path to the system font file with ``font_name`` and style. Returns an empty string if no matching fonts found.
- The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
- \ **Note:** Returned font might have different style if the requested style is not available.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_system_font_path_for_text:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_system_font_path_for_text**\ (\ font_name\: :ref:`String<class_String>`, text\: :ref:`String<class_String>`, locale\: :ref:`String<class_String>` = "", script\: :ref:`String<class_String>` = "", weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐<class_OS_method_get_system_font_path_for_text>`
- Returns an array of the system substitute font file paths, which are similar to the font with ``font_name`` and style for the specified text, locale, and script. Returns an empty array if no matching fonts found.
- The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
- \ **Note:** Depending on OS, it's not guaranteed that any of the returned fonts will be suitable for rendering specified text. Fonts should be loaded and checked in the order they are returned, and the first suitable one used.
- \ **Note:** Returned fonts might have different style if the requested style is not available or belong to a different font family.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_system_fonts:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_system_fonts**\ (\ ) |const| :ref:`๐<class_OS_method_get_system_fonts>`
- Returns the list of font family names available.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_temp_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_temp_dir**\ (\ ) |const| :ref:`๐<class_OS_method_get_temp_dir>`
- Returns the *global* temporary data directory according to the operating system's standards.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_thread_caller_id:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_thread_caller_id**\ (\ ) |const| :ref:`๐<class_OS_method_get_thread_caller_id>`
- Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.
- \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_unique_id:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_unique_id**\ (\ ) |const| :ref:`๐<class_OS_method_get_unique_id>`
- Returns a string that is unique to the device.
- \ **Note:** This string may change without notice if the user reinstalls their operating system, upgrades it, or modifies their hardware. This means it should generally not be used to encrypt persistent data, as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by this method for security purposes.
- \ **Note:** On Web, returns an empty string and generates an error, as this method cannot be implemented for security reasons.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_user_data_dir:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_user_data_dir**\ (\ ) |const| :ref:`๐<class_OS_method_get_user_data_dir>`
- Returns the absolute directory path where user data is written (the ``user://`` directory in Godot). The path depends on the project name and :ref:`ProjectSettings.application/config/use_custom_user_dir<class_ProjectSettings_property_application/config/use_custom_user_dir>`.
- - On Windows, this is ``%AppData%\Godot\app_userdata\[project_name]``, or ``%AppData%\[custom_name]`` if ``use_custom_user_dir`` is set. ``%AppData%`` expands to ``%UserProfile%\AppData\Roaming``.
- - On macOS, this is ``~/Library/Application Support/Godot/app_userdata/[project_name]``, or ``~/Library/Application Support/[custom_name]`` if ``use_custom_user_dir`` is set.
- - On Linux and BSD, this is ``~/.local/share/godot/app_userdata/[project_name]``, or ``~/.local/share/[custom_name]`` if ``use_custom_user_dir`` is set.
- - On Android and iOS, this is a sandboxed directory in either internal or external storage, depending on the user's configuration.
- - On Web, this is a virtual directory managed by the browser.
- If the project name is empty, ``[project_name]`` falls back to ``[unnamed project]``.
- Not to be confused with :ref:`get_data_dir<class_OS_method_get_data_dir>`, which returns the *global* (non-project-specific) user home directory.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_version:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_version**\ (\ ) |const| :ref:`๐<class_OS_method_get_version>`
- Returns the exact production and build version of the operating system. This is different from the branded version used in marketing. This helps to distinguish between different releases of operating systems, including minor versions, and insider and custom builds.
- - For Windows, the major and minor version are returned, as well as the build number. For example, the returned string may look like ``10.0.9926`` for a build of Windows 10, and it may look like ``6.1.7601`` for a build of Windows 7 SP1.
- - For rolling distributions, such as Arch Linux, an empty string is returned.
- - For macOS and iOS, the major and minor version are returned, as well as the patch number.
- - For Android, the SDK version and the incremental build number are returned. If it's a custom ROM, it attempts to return its version instead.
- \ **Note:** This method is not supported on the Web platform. It returns an empty string.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_version_alias:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_version_alias**\ (\ ) |const| :ref:`๐<class_OS_method_get_version_alias>`
- Returns the branded version used in marketing, followed by the build number (on Windows) or the version number (on macOS). Examples include ``11 (build 22000)`` and ``Sequoia (15.0.0)``. This value can then be appended to :ref:`get_name<class_OS_method_get_name>` to get a full, human-readable operating system name and version combination for the operating system. Windows feature updates such as 24H2 are not contained in the resulting string, but Windows Server is recognized as such (e.g. ``2025 (build 26100)`` for Windows Server 2025).
- \ **Note:** This method is only supported on Windows and macOS. On other operating systems, it returns the same value as :ref:`get_version<class_OS_method_get_version>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_get_video_adapter_driver_info:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_video_adapter_driver_info**\ (\ ) |const| :ref:`๐<class_OS_method_get_video_adapter_driver_info>`
- Returns the video adapter driver name and version for the user's currently active graphics card, as a :ref:`PackedStringArray<class_PackedStringArray>`. See also :ref:`RenderingServer.get_video_adapter_api_version<class_RenderingServer_method_get_video_adapter_api_version>`.
- The first element holds the driver name, such as ``nvidia``, ``amdgpu``, etc.
- The second element holds the driver version. For example, on the ``nvidia`` driver on a Linux/BSD platform, the version is in the format ``510.85.02``. For Windows, the driver's format is ``31.0.15.1659``.
- \ **Note:** This method is only supported on Linux/BSD and Windows when not running in headless mode. On other platforms, it returns an empty array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_has_environment:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **has_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_has_environment>`
- Returns ``true`` if the environment variable with the name ``variable`` exists.
- \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_has_feature:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **has_feature**\ (\ tag_name\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_has_feature>`
- Returns ``true`` if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build, etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the :doc:`Feature Tags <../tutorials/export/feature_tags>` documentation for more details.
- \ **Note:** Tag names are case-sensitive.
- \ **Note:** On the Web platform, one of the following additional tags is defined to indicate the host platform: ``web_android``, ``web_ios``, ``web_linuxbsd``, ``web_macos``, or ``web_windows``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_debug_build:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_debug_build**\ (\ ) |const| :ref:`๐<class_OS_method_is_debug_build>`
- Returns ``true`` if the Godot binary used to run the project is a *debug* export template, or when running in the editor.
- Returns ``false`` if the Godot binary used to run the project is a *release* export template.
- \ **Note:** To check whether the Godot binary used to run the project is an export template (debug or release), use ``OS.has_feature("template")`` instead.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_keycode_unicode:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_keycode_unicode**\ (\ code\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_OS_method_is_keycode_unicode>`
- Returns ``true`` if the input keycode corresponds to a Unicode character. For a list of codes, see the :ref:`Key<enum_@GlobalScope_Key>` constants.
- .. tabs::
- .. code-tab:: gdscript
- print(OS.is_keycode_unicode(KEY_G)) # Prints true
- print(OS.is_keycode_unicode(KEY_KP_4)) # Prints true
- print(OS.is_keycode_unicode(KEY_TAB)) # Prints false
- print(OS.is_keycode_unicode(KEY_ESCAPE)) # Prints false
- .. code-tab:: csharp
- GD.Print(OS.IsKeycodeUnicode((long)Key.G)); // Prints True
- GD.Print(OS.IsKeycodeUnicode((long)Key.Kp4)); // Prints True
- GD.Print(OS.IsKeycodeUnicode((long)Key.Tab)); // Prints False
- GD.Print(OS.IsKeycodeUnicode((long)Key.Escape)); // Prints False
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_process_running:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_process_running**\ (\ pid\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_OS_method_is_process_running>`
- Returns ``true`` if the child process ID (``pid``) is still running or ``false`` if it has terminated. ``pid`` must be a valid ID generated from :ref:`create_process<class_OS_method_create_process>`.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS, and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_restart_on_exit_set:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_restart_on_exit_set**\ (\ ) |const| :ref:`๐<class_OS_method_is_restart_on_exit_set>`
- Returns ``true`` if the project will automatically restart when it exits for any reason, ``false`` otherwise. See also :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>` and :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_sandboxed:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_sandboxed**\ (\ ) |const| :ref:`๐<class_OS_method_is_sandboxed>`
- Returns ``true`` if the application is running in the sandbox.
- \ **Note:** This method is only implemented on macOS and Linux.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_stdout_verbose:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_stdout_verbose**\ (\ ) |const| :ref:`๐<class_OS_method_is_stdout_verbose>`
- Returns ``true`` if the engine was executed with the ``--verbose`` or ``-v`` command line argument, or if :ref:`ProjectSettings.debug/settings/stdout/verbose_stdout<class_ProjectSettings_property_debug/settings/stdout/verbose_stdout>` is ``true``. See also :ref:`@GlobalScope.print_verbose<class_@GlobalScope_method_print_verbose>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_is_userfs_persistent:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_userfs_persistent**\ (\ ) |const| :ref:`๐<class_OS_method_is_userfs_persistent>`
- Returns ``true`` if the ``user://`` file system is persistent, that is, its state is the same after a player quits and starts the game again. Relevant to the Web platform, where this persistence may be unavailable.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_kill:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **kill**\ (\ pid\: :ref:`int<class_int>`\ ) :ref:`๐<class_OS_method_kill>`
- Kill (terminate) the process identified by the given process ID (``pid``), such as the ID returned by :ref:`execute<class_OS_method_execute>` in non-blocking mode. See also :ref:`crash<class_OS_method_crash>`.
- \ **Note:** This method can also be used to kill processes that were not spawned by the engine.
- \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_move_to_trash:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **move_to_trash**\ (\ path\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_move_to_trash>`
- Moves the file or directory at the given ``path`` to the system's recycle bin. See also :ref:`DirAccess.remove<class_DirAccess_method_remove>`.
- The method takes only global paths, so you may need to use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>`. Do not use it for files in ``res://`` as it will not work in exported projects.
- Returns :ref:`@GlobalScope.FAILED<class_@GlobalScope_constant_FAILED>` if the file or directory cannot be found, or the system does not support this method.
- .. tabs::
- .. code-tab:: gdscript
- var file_to_remove = "user://slot1.save"
- OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
- .. code-tab:: csharp
- var fileToRemove = "user://slot1.save";
- OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
- \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
- \ **Note:** If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_open_midi_inputs:
- .. rst-class:: classref-method
- |void| **open_midi_inputs**\ (\ ) :ref:`๐<class_OS_method_open_midi_inputs>`
- Initializes the singleton for the system MIDI driver, allowing Godot to receive :ref:`InputEventMIDI<class_InputEventMIDI>`. See also :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>` and :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`.
- \ **Note:** This method is implemented on Linux, macOS, Windows, and Web.
- \ **Note:** On the Web platform, Web MIDI needs to be supported by the browser. `For the time being <https://caniuse.com/midi>`__, it is currently supported by all major browsers, except Safari.
- \ **Note:** On the Web platform, using MIDI input requires a browser permission to be granted first. This permission request is performed when calling :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`. The browser will refrain from processing MIDI input until the user accepts the permission request.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_read_buffer_from_stdin:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **read_buffer_from_stdin**\ (\ buffer_size\: :ref:`int<class_int>`\ ) :ref:`๐<class_OS_method_read_buffer_from_stdin>`
- Reads a user input as raw data from the standard input. This operation can be *blocking*, which causes the window to freeze if :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` is called on the main thread.
- - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing :kbd:`Enter`).
- - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
- - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
- \ **Note:** This method is implemented on Linux, macOS, and Windows.
- \ **Note:** On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the ``windows_subsystem=console`` flag.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_read_string_from_stdin:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **read_string_from_stdin**\ (\ buffer_size\: :ref:`int<class_int>`\ ) :ref:`๐<class_OS_method_read_string_from_stdin>`
- Reads a user input as a UTF-8 encoded string from the standard input. This operation can be *blocking*, which causes the window to freeze if :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` is called on the main thread.
- - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing :kbd:`Enter`).
- - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
- - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
- \ **Note:** This method automatically replaces ``\r\n`` line breaks with ``\n`` and removes them from the end of the string. Use :ref:`read_buffer_from_stdin<class_OS_method_read_buffer_from_stdin>` to read the unprocessed data.
- \ **Note:** This method is implemented on Linux, macOS, and Windows.
- \ **Note:** On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the ``windows_subsystem=console`` flag.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_request_permission:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **request_permission**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`๐<class_OS_method_request_permission>`
- Requests permission from the OS for the given ``name``. Returns ``true`` if the permission has already been granted. See also :ref:`MainLoop.on_request_permissions_result<class_MainLoop_signal_on_request_permissions_result>`.
- The ``name`` must be the full permission name. For example:
- - ``OS.request_permission("android.permission.READ_EXTERNAL_STORAGE")``\
- - ``OS.request_permission("android.permission.POST_NOTIFICATIONS")``\
- \ **Note:** Permission must be checked during export.
- \ **Note:** This method is only implemented on Android.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_request_permissions:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **request_permissions**\ (\ ) :ref:`๐<class_OS_method_request_permissions>`
- Requests *dangerous* permissions from the OS. Returns ``true`` if permissions have already been granted. See also :ref:`MainLoop.on_request_permissions_result<class_MainLoop_signal_on_request_permissions_result>`.
- \ **Note:** Permissions must be checked during export.
- \ **Note:** This method is only implemented on Android. Normal permissions are automatically granted at install time in Android applications.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_revoke_granted_permissions:
- .. rst-class:: classref-method
- |void| **revoke_granted_permissions**\ (\ ) :ref:`๐<class_OS_method_revoke_granted_permissions>`
- On macOS (sandboxed applications only), this function clears list of user selected folders accessible to the application.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_set_environment:
- .. rst-class:: classref-method
- |void| **set_environment**\ (\ variable\: :ref:`String<class_String>`, value\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_set_environment>`
- Sets the value of the environment variable ``variable`` to ``value``. The environment variable will be set for the Godot process and any process executed with :ref:`execute<class_OS_method_execute>` after running :ref:`set_environment<class_OS_method_set_environment>`. The environment variable will *not* persist to processes run after the Godot process was terminated.
- \ **Note:** Environment variable names are case-sensitive on all platforms except Windows. The ``variable`` name cannot be empty or include the ``=`` character. On Windows, there is a 32767 characters limit for the combined length of ``variable``, ``value``, and the ``=`` and null terminator characters that will be registered in the environment block.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_set_restart_on_exit:
- .. rst-class:: classref-method
- |void| **set_restart_on_exit**\ (\ restart\: :ref:`bool<class_bool>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>` = PackedStringArray()\ ) :ref:`๐<class_OS_method_set_restart_on_exit>`
- If ``restart`` is ``true``, restarts the project automatically when it is exited with :ref:`SceneTree.quit<class_SceneTree_method_quit>` or :ref:`Node.NOTIFICATION_WM_CLOSE_REQUEST<class_Node_constant_NOTIFICATION_WM_CLOSE_REQUEST>`. Command-line ``arguments`` can be supplied. To restart the project with the same command line arguments as originally used to run the project, pass :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>` as the value for ``arguments``.
- This method can be used to apply setting changes that require a restart. See also :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>` and :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`.
- \ **Note:** This method is only effective on desktop platforms, and only when the project isn't started from the editor. It will have no effect on mobile and Web platforms, or when the project is started from the editor.
- \ **Note:** If the project process crashes or is *killed* by the user (by sending ``SIGKILL`` instead of the usual ``SIGTERM``), the project won't restart automatically.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_set_thread_name:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **set_thread_name**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`๐<class_OS_method_set_thread_name>`
- Assigns the given name to the current thread. Returns :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if unavailable on the current platform.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_set_use_file_access_save_and_swap:
- .. rst-class:: classref-method
- |void| **set_use_file_access_save_and_swap**\ (\ enabled\: :ref:`bool<class_bool>`\ ) :ref:`๐<class_OS_method_set_use_file_access_save_and_swap>`
- If ``enabled`` is ``true``, when opening a file for writing, a temporary file is used in its place. When closed, it is automatically applied to the target file.
- This can useful when files may be opened by other applications, such as antiviruses, text editors, or even the Godot editor itself.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_shell_open:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **shell_open**\ (\ uri\: :ref:`String<class_String>`\ ) :ref:`๐<class_OS_method_shell_open>`
- Requests the OS to open a resource identified by ``uri`` with the most appropriate program. For example:
- - ``OS.shell_open("C:\\Users\\name\\Downloads")`` on Windows opens the file explorer at the user's Downloads folder.
- - ``OS.shell_open("C:/Users/name/Downloads")`` also works on Windows and opens the file explorer at the user's Downloads folder.
- - ``OS.shell_open("https://godotengine.org")`` opens the default web browser on the official Godot website.
- - ``OS.shell_open("mailto:example@example.com")`` opens the default email client with the "To" field set to ``example@example.com``. See `RFC 2368 - The [code]mailto[/code] URL scheme <https://datatracker.ietf.org/doc/html/rfc2368>`__ for a list of fields that can be added.
- Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` project path into a system path for use with this method.
- \ **Note:** Use :ref:`String.uri_encode<class_String_method_uri_encode>` to encode characters within URLs in a URL-safe, portable way. This is especially required for line breaks. Otherwise, :ref:`shell_open<class_OS_method_shell_open>` may not work correctly in a project exported to the Web platform.
- \ **Note:** This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_shell_show_in_file_manager:
- .. rst-class:: classref-method
- :ref:`Error<enum_@GlobalScope_Error>` **shell_show_in_file_manager**\ (\ file_or_dir_path\: :ref:`String<class_String>`, open_folder\: :ref:`bool<class_bool>` = true\ ) :ref:`๐<class_OS_method_shell_show_in_file_manager>`
- Requests the OS to open the file manager, navigate to the given ``file_or_dir_path`` and select the target file or folder.
- If ``open_folder`` is ``true`` and ``file_or_dir_path`` is a valid directory path, the OS will open the file manager and navigate to the target folder without selecting anything.
- Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` project path into a system path to use with this method.
- \ **Note:** This method is currently only implemented on Windows and macOS. On other platforms, it will fallback to :ref:`shell_open<class_OS_method_shell_open>` with a directory path of ``file_or_dir_path`` prefixed with ``file://``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_OS_method_unset_environment:
- .. rst-class:: classref-method
- |void| **unset_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐<class_OS_method_unset_environment>`
- Removes the given environment variable from the current environment, if it exists. The ``variable`` name cannot be empty or include the ``=`` character. The environment variable will be removed for the Godot process and any process executed with :ref:`execute<class_OS_method_execute>` after running :ref:`unset_environment<class_OS_method_unset_environment>`. The removal of the environment variable will *not* persist to processes run after the Godot process was terminated.
- \ **Note:** Environment variable names are case-sensitive on all platforms except Windows.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
- .. |void| replace:: :abbr:`void (No return value.)`
|