class_os.rst 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/OS.xml.
  6. .. _class_OS:
  7. OS
  8. ==
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Provides access to common operating system functionalities.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This 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.
  15. \ **Note:** In Godot 4, **OS** functions related to window management were moved to the :ref:`DisplayServer<class_DisplayServer>` singleton.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `OS Test Demo <https://godotengine.org/asset-library/asset/677>`__
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`delta_smoothing<class_OS_property_delta_smoothing>` | ``true`` |
  27. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`bool<class_bool>` | :ref:`low_processor_usage_mode<class_OS_property_low_processor_usage_mode>` | ``false`` |
  29. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`int<class_int>` | :ref:`low_processor_usage_mode_sleep_usec<class_OS_property_low_processor_usage_mode_sleep_usec>` | ``6900`` |
  31. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  32. .. rst-class:: classref-reftable-group
  33. Methods
  34. -------
  35. .. table::
  36. :widths: auto
  37. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`alert<class_OS_method_alert>` **(** :ref:`String<class_String>` text, :ref:`String<class_String>` title="Alert!" **)** |
  39. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>` **(** **)** |
  41. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`crash<class_OS_method_crash>` **(** :ref:`String<class_String>` message **)** |
  43. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`create_instance<class_OS_method_create_instance>` **(** :ref:`PackedStringArray<class_PackedStringArray>` arguments **)** |
  45. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`create_process<class_OS_method_create_process>` **(** :ref:`String<class_String>` path, :ref:`PackedStringArray<class_PackedStringArray>` arguments, :ref:`bool<class_bool>` open_console=false **)** |
  47. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`delay_msec<class_OS_method_delay_msec>` **(** :ref:`int<class_int>` msec **)** |const| |
  49. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`delay_usec<class_OS_method_delay_usec>` **(** :ref:`int<class_int>` usec **)** |const| |
  51. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`execute<class_OS_method_execute>` **(** :ref:`String<class_String>` path, :ref:`PackedStringArray<class_PackedStringArray>` arguments, :ref:`Array<class_Array>` output=[], :ref:`bool<class_bool>` read_stderr=false, :ref:`bool<class_bool>` open_console=false **)** |
  53. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Key<enum_@GlobalScope_Key>` | :ref:`find_keycode_from_string<class_OS_method_find_keycode_from_string>` **(** :ref:`String<class_String>` string **)** |const| |
  55. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`String<class_String>` | :ref:`get_cache_dir<class_OS_method_get_cache_dir>` **(** **)** |const| |
  57. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>` **(** **)** |
  59. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>` **(** **)** |
  61. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`String<class_String>` | :ref:`get_config_dir<class_OS_method_get_config_dir>` **(** **)** |const| |
  63. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>` **(** **)** |
  65. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`String<class_String>` | :ref:`get_data_dir<class_OS_method_get_data_dir>` **(** **)** |const| |
  67. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`String<class_String>` | :ref:`get_distribution_name<class_OS_method_get_distribution_name>` **(** **)** |const| |
  69. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`String<class_String>` | :ref:`get_environment<class_OS_method_get_environment>` **(** :ref:`String<class_String>` variable **)** |const| |
  71. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`String<class_String>` | :ref:`get_executable_path<class_OS_method_get_executable_path>` **(** **)** |const| |
  73. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_granted_permissions<class_OS_method_get_granted_permissions>` **(** **)** |const| |
  75. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`String<class_String>` | :ref:`get_keycode_string<class_OS_method_get_keycode_string>` **(** :ref:`Key<enum_@GlobalScope_Key>` code **)** |const| |
  77. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`String<class_String>` | :ref:`get_locale<class_OS_method_get_locale>` **(** **)** |const| |
  79. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`String<class_String>` | :ref:`get_locale_language<class_OS_method_get_locale_language>` **(** **)** |const| |
  81. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`int<class_int>` | :ref:`get_main_thread_id<class_OS_method_get_main_thread_id>` **(** **)** |const| |
  83. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_memory_info<class_OS_method_get_memory_info>` **(** **)** |const| |
  85. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`String<class_String>` | :ref:`get_model_name<class_OS_method_get_model_name>` **(** **)** |const| |
  87. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`String<class_String>` | :ref:`get_name<class_OS_method_get_name>` **(** **)** |const| |
  89. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`int<class_int>` | :ref:`get_process_id<class_OS_method_get_process_id>` **(** **)** |const| |
  91. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`int<class_int>` | :ref:`get_processor_count<class_OS_method_get_processor_count>` **(** **)** |const| |
  93. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`String<class_String>` | :ref:`get_processor_name<class_OS_method_get_processor_name>` **(** **)** |const| |
  95. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>` **(** **)** |const| |
  97. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`int<class_int>` | :ref:`get_static_memory_peak_usage<class_OS_method_get_static_memory_peak_usage>` **(** **)** |const| |
  99. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`int<class_int>` | :ref:`get_static_memory_usage<class_OS_method_get_static_memory_usage>` **(** **)** |const| |
  101. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`String<class_String>` | :ref:`get_system_dir<class_OS_method_get_system_dir>` **(** :ref:`SystemDir<enum_OS_SystemDir>` dir, :ref:`bool<class_bool>` shared_storage=true **)** |const| |
  103. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`String<class_String>` | :ref:`get_system_font_path<class_OS_method_get_system_font_path>` **(** :ref:`String<class_String>` font_name, :ref:`int<class_int>` weight=400, :ref:`int<class_int>` stretch=100, :ref:`bool<class_bool>` italic=false **)** |const| |
  105. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_font_path_for_text<class_OS_method_get_system_font_path_for_text>` **(** :ref:`String<class_String>` font_name, :ref:`String<class_String>` text, :ref:`String<class_String>` locale="", :ref:`String<class_String>` script="", :ref:`int<class_int>` weight=400, :ref:`int<class_int>` stretch=100, :ref:`bool<class_bool>` italic=false **)** |const| |
  107. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_fonts<class_OS_method_get_system_fonts>` **(** **)** |const| |
  109. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`int<class_int>` | :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>` **(** **)** |const| |
  111. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`String<class_String>` | :ref:`get_unique_id<class_OS_method_get_unique_id>` **(** **)** |const| |
  113. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`String<class_String>` | :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>` **(** **)** |const| |
  115. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`String<class_String>` | :ref:`get_version<class_OS_method_get_version>` **(** **)** |const| |
  117. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_video_adapter_driver_info<class_OS_method_get_video_adapter_driver_info>` **(** **)** |const| |
  119. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`has_environment<class_OS_method_has_environment>` **(** :ref:`String<class_String>` variable **)** |const| |
  121. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`bool<class_bool>` | :ref:`has_feature<class_OS_method_has_feature>` **(** :ref:`String<class_String>` tag_name **)** |const| |
  123. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`bool<class_bool>` | :ref:`is_debug_build<class_OS_method_is_debug_build>` **(** **)** |const| |
  125. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`bool<class_bool>` | :ref:`is_keycode_unicode<class_OS_method_is_keycode_unicode>` **(** :ref:`int<class_int>` code **)** |const| |
  127. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`bool<class_bool>` | :ref:`is_process_running<class_OS_method_is_process_running>` **(** :ref:`int<class_int>` pid **)** |const| |
  129. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`bool<class_bool>` | :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>` **(** **)** |const| |
  131. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`bool<class_bool>` | :ref:`is_sandboxed<class_OS_method_is_sandboxed>` **(** **)** |const| |
  133. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`bool<class_bool>` | :ref:`is_stdout_verbose<class_OS_method_is_stdout_verbose>` **(** **)** |const| |
  135. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`bool<class_bool>` | :ref:`is_userfs_persistent<class_OS_method_is_userfs_persistent>` **(** **)** |const| |
  137. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`kill<class_OS_method_kill>` **(** :ref:`int<class_int>` pid **)** |
  139. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`move_to_trash<class_OS_method_move_to_trash>` **(** :ref:`String<class_String>` path **)** |const| |
  141. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | void | :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>` **(** **)** |
  143. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`String<class_String>` | :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` **(** **)** |
  145. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`bool<class_bool>` | :ref:`request_permission<class_OS_method_request_permission>` **(** :ref:`String<class_String>` name **)** |
  147. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`bool<class_bool>` | :ref:`request_permissions<class_OS_method_request_permissions>` **(** **)** |
  149. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | void | :ref:`revoke_granted_permissions<class_OS_method_revoke_granted_permissions>` **(** **)** |
  151. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | void | :ref:`set_environment<class_OS_method_set_environment>` **(** :ref:`String<class_String>` variable, :ref:`String<class_String>` value **)** |const| |
  153. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | void | :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>` **(** :ref:`bool<class_bool>` restart, :ref:`PackedStringArray<class_PackedStringArray>` arguments=PackedStringArray() **)** |
  155. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`set_thread_name<class_OS_method_set_thread_name>` **(** :ref:`String<class_String>` name **)** |
  157. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | void | :ref:`set_use_file_access_save_and_swap<class_OS_method_set_use_file_access_save_and_swap>` **(** :ref:`bool<class_bool>` enabled **)** |
  159. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_open<class_OS_method_shell_open>` **(** :ref:`String<class_String>` uri **)** |
  161. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_show_in_file_manager<class_OS_method_shell_show_in_file_manager>` **(** :ref:`String<class_String>` file_or_dir_path, :ref:`bool<class_bool>` open_folder=true **)** |
  163. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | void | :ref:`unset_environment<class_OS_method_unset_environment>` **(** :ref:`String<class_String>` variable **)** |const| |
  165. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Enumerations
  170. ------------
  171. .. _enum_OS_RenderingDriver:
  172. .. rst-class:: classref-enumeration
  173. enum **RenderingDriver**:
  174. .. _class_OS_constant_RENDERING_DRIVER_VULKAN:
  175. .. rst-class:: classref-enumeration-constant
  176. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_VULKAN** = ``0``
  177. The Vulkan rendering driver. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
  178. .. _class_OS_constant_RENDERING_DRIVER_OPENGL3:
  179. .. rst-class:: classref-enumeration-constant
  180. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_OPENGL3** = ``1``
  181. 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.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _enum_OS_SystemDir:
  185. .. rst-class:: classref-enumeration
  186. enum **SystemDir**:
  187. .. _class_OS_constant_SYSTEM_DIR_DESKTOP:
  188. .. rst-class:: classref-enumeration-constant
  189. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DESKTOP** = ``0``
  190. Desktop directory path.
  191. .. _class_OS_constant_SYSTEM_DIR_DCIM:
  192. .. rst-class:: classref-enumeration-constant
  193. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DCIM** = ``1``
  194. DCIM (Digital Camera Images) directory path.
  195. .. _class_OS_constant_SYSTEM_DIR_DOCUMENTS:
  196. .. rst-class:: classref-enumeration-constant
  197. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOCUMENTS** = ``2``
  198. Documents directory path.
  199. .. _class_OS_constant_SYSTEM_DIR_DOWNLOADS:
  200. .. rst-class:: classref-enumeration-constant
  201. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOWNLOADS** = ``3``
  202. Downloads directory path.
  203. .. _class_OS_constant_SYSTEM_DIR_MOVIES:
  204. .. rst-class:: classref-enumeration-constant
  205. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MOVIES** = ``4``
  206. Movies directory path.
  207. .. _class_OS_constant_SYSTEM_DIR_MUSIC:
  208. .. rst-class:: classref-enumeration-constant
  209. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MUSIC** = ``5``
  210. Music directory path.
  211. .. _class_OS_constant_SYSTEM_DIR_PICTURES:
  212. .. rst-class:: classref-enumeration-constant
  213. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_PICTURES** = ``6``
  214. Pictures directory path.
  215. .. _class_OS_constant_SYSTEM_DIR_RINGTONES:
  216. .. rst-class:: classref-enumeration-constant
  217. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_RINGTONES** = ``7``
  218. Ringtones directory path.
  219. .. rst-class:: classref-section-separator
  220. ----
  221. .. rst-class:: classref-descriptions-group
  222. Property Descriptions
  223. ---------------------
  224. .. _class_OS_property_delta_smoothing:
  225. .. rst-class:: classref-property
  226. :ref:`bool<class_bool>` **delta_smoothing** = ``true``
  227. .. rst-class:: classref-property-setget
  228. - void **set_delta_smoothing** **(** :ref:`bool<class_bool>` value **)**
  229. - :ref:`bool<class_bool>` **is_delta_smoothing_enabled** **(** **)**
  230. If ``true``, the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This will only operate on systems where V-Sync is active.
  231. .. rst-class:: classref-item-separator
  232. ----
  233. .. _class_OS_property_low_processor_usage_mode:
  234. .. rst-class:: classref-property
  235. :ref:`bool<class_bool>` **low_processor_usage_mode** = ``false``
  236. .. rst-class:: classref-property-setget
  237. - void **set_low_processor_usage_mode** **(** :ref:`bool<class_bool>` value **)**
  238. - :ref:`bool<class_bool>` **is_in_low_processor_usage_mode** **(** **)**
  239. If ``true``, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_OS_property_low_processor_usage_mode_sleep_usec:
  243. .. rst-class:: classref-property
  244. :ref:`int<class_int>` **low_processor_usage_mode_sleep_usec** = ``6900``
  245. .. rst-class:: classref-property-setget
  246. - void **set_low_processor_usage_mode_sleep_usec** **(** :ref:`int<class_int>` value **)**
  247. - :ref:`int<class_int>` **get_low_processor_usage_mode_sleep_usec** **(** **)**
  248. The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage.
  249. .. rst-class:: classref-section-separator
  250. ----
  251. .. rst-class:: classref-descriptions-group
  252. Method Descriptions
  253. -------------------
  254. .. _class_OS_method_alert:
  255. .. rst-class:: classref-method
  256. void **alert** **(** :ref:`String<class_String>` text, :ref:`String<class_String>` title="Alert!" **)**
  257. Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_OS_method_close_midi_inputs:
  261. .. rst-class:: classref-method
  262. void **close_midi_inputs** **(** **)**
  263. Shuts down system MIDI driver.
  264. \ **Note:** This method is implemented on Linux, macOS and Windows.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_OS_method_crash:
  268. .. rst-class:: classref-method
  269. void **crash** **(** :ref:`String<class_String>` message **)**
  270. Crashes the engine (or the editor if called within a ``@tool`` script). This 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>`. See also :ref:`kill<class_OS_method_kill>`.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_OS_method_create_instance:
  274. .. rst-class:: classref-method
  275. :ref:`int<class_int>` **create_instance** **(** :ref:`PackedStringArray<class_PackedStringArray>` arguments **)**
  276. Creates a new instance of Godot that runs independently. The ``arguments`` are used in the given order and separated by a space.
  277. If the process creation succeeds, the method will return 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 creation fails, the method will return ``-1``.
  278. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_OS_method_create_process:
  282. .. rst-class:: classref-method
  283. :ref:`int<class_int>` **create_process** **(** :ref:`String<class_String>` path, :ref:`PackedStringArray<class_PackedStringArray>` arguments, :ref:`bool<class_bool>` open_console=false **)**
  284. Creates a new process that runs independently of Godot. It will not terminate if Godot terminates. The path specified in ``path`` must exist and be executable file or macOS .app bundle. Platform path resolution will be used. The ``arguments`` are used in the given order and separated by a space.
  285. On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window will be opened. This is ignored on other platforms.
  286. If the process creation succeeds, the method will return 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 creation fails, the method will return ``-1``.
  287. For example, running another instance of the project:
  288. .. tabs::
  289. .. code-tab:: gdscript
  290. var pid = OS.create_process(OS.get_executable_path(), [])
  291. .. code-tab:: csharp
  292. var pid = OS.CreateProcess(OS.GetExecutablePath(), new string[] {});
  293. See :ref:`execute<class_OS_method_execute>` if you wish to run an external command and retrieve the results.
  294. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  295. \ **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.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_OS_method_delay_msec:
  299. .. rst-class:: classref-method
  300. void **delay_msec** **(** :ref:`int<class_int>` msec **)** |const|
  301. 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>` will do nothing and will print an error message.
  302. \ **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, see :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>` will delay 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).
  303. \ **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).
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_OS_method_delay_usec:
  307. .. rst-class:: classref-method
  308. void **delay_usec** **(** :ref:`int<class_int>` usec **)** |const|
  309. 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>` will do nothing and will print an error message.
  310. \ **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, see :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>` will delay 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).
  311. \ **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).
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_OS_method_execute:
  315. .. rst-class:: classref-method
  316. :ref:`int<class_int>` **execute** **(** :ref:`String<class_String>` path, :ref:`PackedStringArray<class_PackedStringArray>` arguments, :ref:`Array<class_Array>` output=[], :ref:`bool<class_bool>` read_stderr=false, :ref:`bool<class_bool>` open_console=false **)**
  317. Executes a command. The file specified in ``path`` must exist and be executable. Platform path resolution will be used. The ``arguments`` are used in the given order, separated by spaces, and wrapped in quotes. If an ``output`` :ref:`Array<class_Array>` is provided, the complete shell output of the process will be appended as a single :ref:`String<class_String>` element in ``output``. If ``read_stderr`` is ``true``, the output to the standard error stream will be included too.
  318. On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window will be opened. This is ignored on other platforms.
  319. If the command is successfully executed, the method will return the exit code of the command, or ``-1`` if it fails.
  320. \ **Note:** The Godot thread will pause its execution until the executed command terminates. Use :ref:`Thread<class_Thread>` to create a separate thread that will not pause the Godot thread, or use :ref:`create_process<class_OS_method_create_process>` to create a completely independent process.
  321. For example, to retrieve a list of the working directory's contents:
  322. .. tabs::
  323. .. code-tab:: gdscript
  324. var output = []
  325. var exit_code = OS.execute("ls", ["-l", "/tmp"], output)
  326. .. code-tab:: csharp
  327. var output = new Godot.Collections.Array();
  328. int exitCode = OS.Execute("ls", new string[] {"-l", "/tmp"}, output);
  329. If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example:
  330. .. tabs::
  331. .. code-tab:: gdscript
  332. var output = []
  333. OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output)
  334. .. code-tab:: csharp
  335. var output = new Godot.Collections.Array();
  336. OS.Execute("CMD.exe", new string[] {"/C", "cd %TEMP% && dir"}, output);
  337. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  338. \ **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.
  339. \ **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.
  340. \ **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.
  341. \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
  342. \ **Note:** On Android, system commands such as ``dumpsys`` can only be run on a rooted device.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_OS_method_find_keycode_from_string:
  346. .. rst-class:: classref-method
  347. :ref:`Key<enum_@GlobalScope_Key>` **find_keycode_from_string** **(** :ref:`String<class_String>` string **)** |const|
  348. Returns the keycode of the given string (e.g. "Escape").
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_OS_method_get_cache_dir:
  352. .. rst-class:: classref-method
  353. :ref:`String<class_String>` **get_cache_dir** **(** **)** |const|
  354. 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>`.
  355. 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.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_OS_method_get_cmdline_args:
  359. .. rst-class:: classref-method
  360. :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_args** **(** **)**
  361. Returns the command-line arguments passed to the engine.
  362. 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.
  363. You can also incorporate environment variables using the :ref:`get_environment<class_OS_method_get_environment>` method.
  364. 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.
  365. Here's a minimal example on how to parse command-line arguments into a dictionary using the ``--key=value`` form for arguments:
  366. .. tabs::
  367. .. code-tab:: gdscript
  368. var arguments = {}
  369. for argument in OS.get_cmdline_args():
  370. if argument.find("=") > -1:
  371. var key_value = argument.split("=")
  372. arguments[key_value[0].lstrip("--")] = key_value[1]
  373. else:
  374. # Options without an argument will be present in the dictionary,
  375. # with the value set to an empty string.
  376. arguments[argument.lstrip("--")] = ""
  377. .. code-tab:: csharp
  378. var arguments = new Godot.Collections.Dictionary();
  379. foreach (var argument in OS.GetCmdlineArgs())
  380. {
  381. if (argument.Find("=") > -1)
  382. {
  383. string[] keyValue = argument.Split("=");
  384. arguments[keyValue[0].LStrip("--")] = keyValue[1];
  385. }
  386. else
  387. {
  388. // Options without an argument will be present in the dictionary,
  389. // with the value set to an empty string.
  390. arguments[keyValue[0].LStrip("--")] = "";
  391. }
  392. }
  393. \ **Note:** Passing custom user arguments directly is not recommended, as the engine may discard or modify them. Instead, the best way is to use the standard UNIX double dash (``--``) and then pass custom arguments, which the engine itself will ignore. These can be read via :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_OS_method_get_cmdline_user_args:
  397. .. rst-class:: classref-method
  398. :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_user_args** **(** **)**
  399. Similar to :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`, but this returns the user arguments (any argument passed after the double dash ``--`` or double plus ``++`` argument). These are left untouched by Godot for the user. ``++`` can be used in situations where ``--`` is intercepted by another program (such as ``startx``).
  400. For example, in the command line below, ``--fullscreen`` will not be returned in :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>` and ``--level 1`` will only be returned in :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`:
  401. ::
  402. # Godot has been executed with the following command:
  403. # godot --fullscreen -- --level=2 --hardcore
  404. OS.get_cmdline_args() # Returns ["--fullscreen", "--level=2", "--hardcore"]
  405. OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"]
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_OS_method_get_config_dir:
  409. .. rst-class:: classref-method
  410. :ref:`String<class_String>` **get_config_dir** **(** **)** |const|
  411. 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>`.
  412. 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.
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_OS_method_get_connected_midi_inputs:
  416. .. rst-class:: classref-method
  417. :ref:`PackedStringArray<class_PackedStringArray>` **get_connected_midi_inputs** **(** **)**
  418. Returns an array of MIDI device names.
  419. The returned array will be empty if the system MIDI driver has not previously been initialized with :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`.
  420. \ **Note:** This method is implemented on Linux, macOS and Windows.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_OS_method_get_data_dir:
  424. .. rst-class:: classref-method
  425. :ref:`String<class_String>` **get_data_dir** **(** **)** |const|
  426. 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>`.
  427. 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.
  428. .. rst-class:: classref-item-separator
  429. ----
  430. .. _class_OS_method_get_distribution_name:
  431. .. rst-class:: classref-method
  432. :ref:`String<class_String>` **get_distribution_name** **(** **)** |const|
  433. Returns the name of the distribution for Linux and BSD platforms (e.g. Ubuntu, Manjaro, OpenBSD, etc.).
  434. 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.
  435. Returns the same value as :ref:`get_name<class_OS_method_get_name>` for other platforms.
  436. \ **Note:** This method is not supported on the web platform. It returns an empty string.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _class_OS_method_get_environment:
  440. .. rst-class:: classref-method
  441. :ref:`String<class_String>` **get_environment** **(** :ref:`String<class_String>` variable **)** |const|
  442. Returns the value of an environment variable. Returns an empty string if the environment variable doesn't exist.
  443. \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
  444. .. rst-class:: classref-item-separator
  445. ----
  446. .. _class_OS_method_get_executable_path:
  447. .. rst-class:: classref-method
  448. :ref:`String<class_String>` **get_executable_path** **(** **)** |const|
  449. Returns the path to the current engine executable.
  450. \ **Note:** On macOS, always use :ref:`create_instance<class_OS_method_create_instance>` instead of relying on executable path.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_OS_method_get_granted_permissions:
  454. .. rst-class:: classref-method
  455. :ref:`PackedStringArray<class_PackedStringArray>` **get_granted_permissions** **(** **)** |const|
  456. On Android devices: With this function, you can get the list of dangerous permissions that have been granted.
  457. On macOS (sandboxed applications only): This function returns the list of user selected folders accessible to the application. Use native file dialog to request folder access permission.
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_OS_method_get_keycode_string:
  461. .. rst-class:: classref-method
  462. :ref:`String<class_String>` **get_keycode_string** **(** :ref:`Key<enum_@GlobalScope_Key>` code **)** |const|
  463. Returns the given keycode as a string (e.g. Return values: ``"Escape"``, ``"Shift+Escape"``).
  464. See also :ref:`InputEventKey.keycode<class_InputEventKey_property_keycode>` and :ref:`InputEventKey.get_keycode_with_modifiers<class_InputEventKey_method_get_keycode_with_modifiers>`.
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_OS_method_get_locale:
  468. .. rst-class:: classref-method
  469. :ref:`String<class_String>` **get_locale** **(** **)** |const|
  470. Returns the host OS locale as a string of the form ``language_Script_COUNTRY_VARIANT@extra``. 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>`.
  471. \ ``language`` - 2 or 3-letter `language code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__, in lower case.
  472. \ ``Script`` - optional, 4-letter `script code <https://en.wikipedia.org/wiki/ISO_15924>`__, in title case.
  473. \ ``COUNTRY`` - optional, 2 or 3-letter `country code <https://en.wikipedia.org/wiki/ISO_3166-1>`__, in upper case.
  474. \ ``VARIANT`` - optional, language variant, region and sort order. Variant can have any number of underscored keywords.
  475. \ ``extra`` - optional, semicolon separated list of additional key words. Currency, calendar, sort order and numbering system information.
  476. .. rst-class:: classref-item-separator
  477. ----
  478. .. _class_OS_method_get_locale_language:
  479. .. rst-class:: classref-method
  480. :ref:`String<class_String>` **get_locale_language** **(** **)** |const|
  481. 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.
  482. 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``.
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _class_OS_method_get_main_thread_id:
  486. .. rst-class:: classref-method
  487. :ref:`int<class_int>` **get_main_thread_id** **(** **)** |const|
  488. Returns the ID of the main thread. See :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>`.
  489. \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_OS_method_get_memory_info:
  493. .. rst-class:: classref-method
  494. :ref:`Dictionary<class_Dictionary>` **get_memory_info** **(** **)** |const|
  495. Returns the :ref:`Dictionary<class_Dictionary>` with the following keys:
  496. \ ``"physical"`` - total amount of usable physical memory, in bytes or ``-1`` if unknown. This value can be slightly less than the actual physical memory amount, since it does not include memory reserved by kernel and devices.
  497. \ ``"free"`` - amount of physical memory, that can be immediately allocated without disk access or other costly operation, in bytes or ``-1`` if unknown. The process might be able to allocate more physical memory, but such allocation will require moving inactive pages to disk and can take some time.
  498. \ ``"available"`` - amount of memory, that can be allocated without extending the swap file(s), in bytes or ``-1`` if unknown. This value include both physical memory and swap.
  499. \ ``"stack"`` - size of the current thread stack, in bytes or ``-1`` if unknown.
  500. .. rst-class:: classref-item-separator
  501. ----
  502. .. _class_OS_method_get_model_name:
  503. .. rst-class:: classref-method
  504. :ref:`String<class_String>` **get_model_name** **(** **)** |const|
  505. Returns the model name of the current device.
  506. \ **Note:** This method is implemented on Android and iOS. Returns ``"GenericDevice"`` on unsupported platforms.
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_OS_method_get_name:
  510. .. rst-class:: classref-method
  511. :ref:`String<class_String>` **get_name** **(** **)** |const|
  512. Returns the name of the host OS.
  513. On Windows, this is ``"Windows"``.
  514. On macOS, this is ``"macOS"``.
  515. On Linux-based operating systems, this is ``"Linux"``.
  516. On BSD-based operating systems, this is ``"FreeBSD"``, ``"NetBSD"``, ``"OpenBSD"``, or ``"BSD"`` as a fallback.
  517. On Android, this is ``"Android"``.
  518. On iOS, this is ``"iOS"``.
  519. On the web, this is ``"Web"``.
  520. \ **Note:** Custom builds of the engine may support additional platforms, such as consoles, yielding other return values.
  521. .. tabs::
  522. .. code-tab:: gdscript
  523. match OS.get_name():
  524. "Windows":
  525. print("Windows")
  526. "macOS":
  527. print("macOS")
  528. "Linux", "FreeBSD", "NetBSD", "OpenBSD", "BSD":
  529. print("Linux/BSD")
  530. "Android":
  531. print("Android")
  532. "iOS":
  533. print("iOS")
  534. "Web":
  535. print("Web")
  536. .. code-tab:: csharp
  537. switch (OS.GetName())
  538. {
  539. case "Windows":
  540. GD.Print("Windows");
  541. break;
  542. case "macOS":
  543. GD.Print("macOS");
  544. break;
  545. case "Linux":
  546. case "FreeBSD":
  547. case "NetBSD":
  548. case "OpenBSD":
  549. case "BSD":
  550. GD.Print("Linux/BSD");
  551. break;
  552. case "Android":
  553. GD.Print("Android");
  554. break;
  555. case "iOS":
  556. GD.Print("iOS");
  557. break;
  558. case "Web":
  559. GD.Print("Web");
  560. break;
  561. }
  562. .. rst-class:: classref-item-separator
  563. ----
  564. .. _class_OS_method_get_process_id:
  565. .. rst-class:: classref-method
  566. :ref:`int<class_int>` **get_process_id** **(** **)** |const|
  567. Returns the project's process ID.
  568. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  569. .. rst-class:: classref-item-separator
  570. ----
  571. .. _class_OS_method_get_processor_count:
  572. .. rst-class:: classref-method
  573. :ref:`int<class_int>` **get_processor_count** **(** **)** |const|
  574. 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.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_OS_method_get_processor_name:
  578. .. rst-class:: classref-method
  579. :ref:`String<class_String>` **get_processor_name** **(** **)** |const|
  580. Returns the name of the CPU model on the host machine (e.g. "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz").
  581. \ **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.
  582. .. rst-class:: classref-item-separator
  583. ----
  584. .. _class_OS_method_get_restart_on_exit_arguments:
  585. .. rst-class:: classref-method
  586. :ref:`PackedStringArray<class_PackedStringArray>` **get_restart_on_exit_arguments** **(** **)** |const|
  587. 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>`.
  588. .. rst-class:: classref-item-separator
  589. ----
  590. .. _class_OS_method_get_static_memory_peak_usage:
  591. .. rst-class:: classref-method
  592. :ref:`int<class_int>` **get_static_memory_peak_usage** **(** **)** |const|
  593. Returns the maximum amount of static memory used (only works in debug).
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _class_OS_method_get_static_memory_usage:
  597. .. rst-class:: classref-method
  598. :ref:`int<class_int>` **get_static_memory_usage** **(** **)** |const|
  599. Returns the amount of static memory being used by the program in bytes (only works in debug).
  600. .. rst-class:: classref-item-separator
  601. ----
  602. .. _class_OS_method_get_system_dir:
  603. .. rst-class:: classref-method
  604. :ref:`String<class_String>` **get_system_dir** **(** :ref:`SystemDir<enum_OS_SystemDir>` dir, :ref:`bool<class_bool>` shared_storage=true **)** |const|
  605. Returns the actual path to commonly used folders across different platforms. Available locations are specified in :ref:`SystemDir<enum_OS_SystemDir>`.
  606. \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
  607. \ **Note:** Shared storage is implemented on Android and allows to differentiate between app specific and shared directories. Shared directories have additional restrictions on Android.
  608. .. rst-class:: classref-item-separator
  609. ----
  610. .. _class_OS_method_get_system_font_path:
  611. .. rst-class:: classref-method
  612. :ref:`String<class_String>` **get_system_font_path** **(** :ref:`String<class_String>` font_name, :ref:`int<class_int>` weight=400, :ref:`int<class_int>` stretch=100, :ref:`bool<class_bool>` italic=false **)** |const|
  613. Returns path to the system font file with ``font_name`` and style. Returns empty string if no matching fonts found.
  614. The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
  615. \ **Note:** Returned font might have different style if the requested style is not available.
  616. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  617. .. rst-class:: classref-item-separator
  618. ----
  619. .. _class_OS_method_get_system_font_path_for_text:
  620. .. rst-class:: classref-method
  621. :ref:`PackedStringArray<class_PackedStringArray>` **get_system_font_path_for_text** **(** :ref:`String<class_String>` font_name, :ref:`String<class_String>` text, :ref:`String<class_String>` locale="", :ref:`String<class_String>` script="", :ref:`int<class_int>` weight=400, :ref:`int<class_int>` stretch=100, :ref:`bool<class_bool>` italic=false **)** |const|
  622. 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 empty array if no matching fonts found.
  623. The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
  624. \ **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.
  625. \ **Note:** Returned fonts might have different style if the requested style is not available or belong to a different font family.
  626. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  627. .. rst-class:: classref-item-separator
  628. ----
  629. .. _class_OS_method_get_system_fonts:
  630. .. rst-class:: classref-method
  631. :ref:`PackedStringArray<class_PackedStringArray>` **get_system_fonts** **(** **)** |const|
  632. Returns list of font family names available.
  633. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  634. .. rst-class:: classref-item-separator
  635. ----
  636. .. _class_OS_method_get_thread_caller_id:
  637. .. rst-class:: classref-method
  638. :ref:`int<class_int>` **get_thread_caller_id** **(** **)** |const|
  639. Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.
  640. \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
  641. .. rst-class:: classref-item-separator
  642. ----
  643. .. _class_OS_method_get_unique_id:
  644. .. rst-class:: classref-method
  645. :ref:`String<class_String>` **get_unique_id** **(** **)** |const|
  646. Returns a string that is unique to the device.
  647. \ **Note:** This string may change without notice if the user reinstalls/upgrades their operating system or changes 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 :ref:`get_unique_id<class_OS_method_get_unique_id>` for security purposes.
  648. \ **Note:** Returns an empty string and prints an error on Web, as this method cannot be implemented on this platform.
  649. .. rst-class:: classref-item-separator
  650. ----
  651. .. _class_OS_method_get_user_data_dir:
  652. .. rst-class:: classref-method
  653. :ref:`String<class_String>` **get_user_data_dir** **(** **)** |const|
  654. Returns the absolute directory path where user data is written (``user://``).
  655. 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``.
  656. 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.
  657. 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.
  658. On Android and iOS, this is a sandboxed directory in either internal or external storage, depending on the user's configuration.
  659. On the web, this is a virtual directory managed by the browser.
  660. If the project name is empty, ``[project_name]`` falls back to ``[unnamed project]``.
  661. 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.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_OS_method_get_version:
  665. .. rst-class:: classref-method
  666. :ref:`String<class_String>` **get_version** **(** **)** |const|
  667. 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.
  668. For Windows, the major and minor version are returned, as well as the build number. For example, the returned string can look like ``10.0.9926`` for a build of Windows 10, and it can look like ``6.1.7601`` for a build of Windows 7 SP1.
  669. For rolling distributions, such as Arch Linux, an empty string is returned.
  670. For macOS and iOS, the major and minor version are returned, as well as the patch number.
  671. 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.
  672. \ **Note:** This method is not supported on the web platform. It returns an empty string.
  673. .. rst-class:: classref-item-separator
  674. ----
  675. .. _class_OS_method_get_video_adapter_driver_info:
  676. .. rst-class:: classref-method
  677. :ref:`PackedStringArray<class_PackedStringArray>` **get_video_adapter_driver_info** **(** **)** |const|
  678. Returns the video adapter driver name and version for the user's currently active graphics card. See also :ref:`RenderingServer.get_video_adapter_api_version<class_RenderingServer_method_get_video_adapter_api_version>`.
  679. The first element holds the driver name, such as ``nvidia``, ``amdgpu``, etc.
  680. The second element holds the driver version. For e.g. 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``.
  681. \ **Note:** This method is only supported on the platforms Linux/BSD and Windows when not running in headless mode. It returns an empty array on other platforms.
  682. .. rst-class:: classref-item-separator
  683. ----
  684. .. _class_OS_method_has_environment:
  685. .. rst-class:: classref-method
  686. :ref:`bool<class_bool>` **has_environment** **(** :ref:`String<class_String>` variable **)** |const|
  687. Returns ``true`` if the environment variable with the name ``variable`` exists.
  688. \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
  689. .. rst-class:: classref-item-separator
  690. ----
  691. .. _class_OS_method_has_feature:
  692. .. rst-class:: classref-method
  693. :ref:`bool<class_bool>` **has_feature** **(** :ref:`String<class_String>` tag_name **)** |const|
  694. 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.
  695. \ **Note:** Tag names are case-sensitive.
  696. \ **Note:** On the web platform, one of the following additional tags is defined to indicate host platform: ``web_android``, ``web_ios``, ``web_linuxbsd``, ``web_macos``, or ``web_windows``.
  697. \ **Note:** On the iOS simulator, the additional ``simulator`` tag is defined.
  698. .. rst-class:: classref-item-separator
  699. ----
  700. .. _class_OS_method_is_debug_build:
  701. .. rst-class:: classref-method
  702. :ref:`bool<class_bool>` **is_debug_build** **(** **)** |const|
  703. Returns ``true`` if the Godot binary used to run the project is a *debug* export template, or when running in the editor.
  704. Returns ``false`` if the Godot binary used to run the project is a *release* export template.
  705. To check whether the Godot binary used to run the project is an export template (debug or release), use ``OS.has_feature("template")`` instead.
  706. .. rst-class:: classref-item-separator
  707. ----
  708. .. _class_OS_method_is_keycode_unicode:
  709. .. rst-class:: classref-method
  710. :ref:`bool<class_bool>` **is_keycode_unicode** **(** :ref:`int<class_int>` code **)** |const|
  711. Returns ``true`` if the input keycode corresponds to a Unicode character.
  712. .. rst-class:: classref-item-separator
  713. ----
  714. .. _class_OS_method_is_process_running:
  715. .. rst-class:: classref-method
  716. :ref:`bool<class_bool>` **is_process_running** **(** :ref:`int<class_int>` pid **)** |const|
  717. Returns ``true`` if the child process ID (``pid``) is still running or ``false`` if it has terminated.
  718. Must be a valid ID generated from :ref:`create_process<class_OS_method_create_process>`.
  719. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  720. .. rst-class:: classref-item-separator
  721. ----
  722. .. _class_OS_method_is_restart_on_exit_set:
  723. .. rst-class:: classref-method
  724. :ref:`bool<class_bool>` **is_restart_on_exit_set** **(** **)** |const|
  725. 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>`.
  726. .. rst-class:: classref-item-separator
  727. ----
  728. .. _class_OS_method_is_sandboxed:
  729. .. rst-class:: classref-method
  730. :ref:`bool<class_bool>` **is_sandboxed** **(** **)** |const|
  731. Returns ``true`` if application is running in the sandbox.
  732. \ **Note:** This method is implemented on macOS and Linux.
  733. .. rst-class:: classref-item-separator
  734. ----
  735. .. _class_OS_method_is_stdout_verbose:
  736. .. rst-class:: classref-method
  737. :ref:`bool<class_bool>` **is_stdout_verbose** **(** **)** |const|
  738. 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>`.
  739. .. rst-class:: classref-item-separator
  740. ----
  741. .. _class_OS_method_is_userfs_persistent:
  742. .. rst-class:: classref-method
  743. :ref:`bool<class_bool>` **is_userfs_persistent** **(** **)** |const|
  744. If ``true``, the ``user://`` file system is persistent, so that 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.
  745. .. rst-class:: classref-item-separator
  746. ----
  747. .. _class_OS_method_kill:
  748. .. rst-class:: classref-method
  749. :ref:`Error<enum_@GlobalScope_Error>` **kill** **(** :ref:`int<class_int>` pid **)**
  750. Kill (terminate) the process identified by the given process ID (``pid``), e.g. the one returned by :ref:`execute<class_OS_method_execute>` in non-blocking mode. See also :ref:`crash<class_OS_method_crash>`.
  751. \ **Note:** This method can also be used to kill processes that were not spawned by the game.
  752. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  753. .. rst-class:: classref-item-separator
  754. ----
  755. .. _class_OS_method_move_to_trash:
  756. .. rst-class:: classref-method
  757. :ref:`Error<enum_@GlobalScope_Error>` **move_to_trash** **(** :ref:`String<class_String>` path **)** |const|
  758. Moves the file or directory to the system's recycle bin. See also :ref:`DirAccess.remove<class_DirAccess_method_remove>`.
  759. 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.
  760. \ **Note:** If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
  761. .. tabs::
  762. .. code-tab:: gdscript
  763. var file_to_remove = "user://slot1.save"
  764. OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
  765. .. code-tab:: csharp
  766. var fileToRemove = "user://slot1.save";
  767. OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
  768. .. rst-class:: classref-item-separator
  769. ----
  770. .. _class_OS_method_open_midi_inputs:
  771. .. rst-class:: classref-method
  772. void **open_midi_inputs** **(** **)**
  773. Initializes the singleton for the system MIDI driver.
  774. \ **Note:** This method is implemented on Linux, macOS and Windows.
  775. .. rst-class:: classref-item-separator
  776. ----
  777. .. _class_OS_method_read_string_from_stdin:
  778. .. rst-class:: classref-method
  779. :ref:`String<class_String>` **read_string_from_stdin** **(** **)**
  780. Reads a user input string from the standard input (usually the terminal). This operation is *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. The thread calling :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` will block until the program receives a line break in standard input (usually by the user pressing :kbd:`Enter`).
  781. \ **Note:** This method is implemented on Linux, macOS and Windows.
  782. .. rst-class:: classref-item-separator
  783. ----
  784. .. _class_OS_method_request_permission:
  785. .. rst-class:: classref-method
  786. :ref:`bool<class_bool>` **request_permission** **(** :ref:`String<class_String>` name **)**
  787. At the moment this function is only used by ``AudioDriverOpenSL`` to request permission for ``RECORD_AUDIO`` on Android.
  788. .. rst-class:: classref-item-separator
  789. ----
  790. .. _class_OS_method_request_permissions:
  791. .. rst-class:: classref-method
  792. :ref:`bool<class_bool>` **request_permissions** **(** **)**
  793. With this function, you can request dangerous permissions since normal permissions are automatically granted at install time in Android applications.
  794. \ **Note:** This method is implemented only on Android.
  795. .. rst-class:: classref-item-separator
  796. ----
  797. .. _class_OS_method_revoke_granted_permissions:
  798. .. rst-class:: classref-method
  799. void **revoke_granted_permissions** **(** **)**
  800. On macOS (sandboxed applications only), this function clears list of user selected folders accessible to the application.
  801. .. rst-class:: classref-item-separator
  802. ----
  803. .. _class_OS_method_set_environment:
  804. .. rst-class:: classref-method
  805. void **set_environment** **(** :ref:`String<class_String>` variable, :ref:`String<class_String>` value **)** |const|
  806. 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.
  807. \ **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.
  808. .. rst-class:: classref-item-separator
  809. ----
  810. .. _class_OS_method_set_restart_on_exit:
  811. .. rst-class:: classref-method
  812. void **set_restart_on_exit** **(** :ref:`bool<class_bool>` restart, :ref:`PackedStringArray<class_PackedStringArray>` arguments=PackedStringArray() **)**
  813. 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``.
  814. \ :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>` 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>`.
  815. \ **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.
  816. \ **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.
  817. .. rst-class:: classref-item-separator
  818. ----
  819. .. _class_OS_method_set_thread_name:
  820. .. rst-class:: classref-method
  821. :ref:`Error<enum_@GlobalScope_Error>` **set_thread_name** **(** :ref:`String<class_String>` name **)**
  822. Sets the name of the current thread.
  823. .. rst-class:: classref-item-separator
  824. ----
  825. .. _class_OS_method_set_use_file_access_save_and_swap:
  826. .. rst-class:: classref-method
  827. void **set_use_file_access_save_and_swap** **(** :ref:`bool<class_bool>` enabled **)**
  828. Enables backup saves if ``enabled`` is ``true``.
  829. .. rst-class:: classref-item-separator
  830. ----
  831. .. _class_OS_method_shell_open:
  832. .. rst-class:: classref-method
  833. :ref:`Error<enum_@GlobalScope_Error>` **shell_open** **(** :ref:`String<class_String>` uri **)**
  834. Requests the OS to open a resource with the most appropriate program. For example:
  835. - ``OS.shell_open("C:\\Users\name\Downloads")`` on Windows opens the file explorer at the user's Downloads folder.
  836. - ``OS.shell_open("https://godotengine.org")`` opens the default web browser on the official Godot website.
  837. - ``OS.shell_open("mailto:[email protected]")`` opens the default email client with the "To" field set to ``[email protected]``. 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.
  838. Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` path into a system path for use with this method.
  839. \ **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.
  840. \ **Note:** This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
  841. .. rst-class:: classref-item-separator
  842. ----
  843. .. _class_OS_method_shell_show_in_file_manager:
  844. .. rst-class:: classref-method
  845. :ref:`Error<enum_@GlobalScope_Error>` **shell_show_in_file_manager** **(** :ref:`String<class_String>` file_or_dir_path, :ref:`bool<class_bool>` open_folder=true **)**
  846. Requests the OS to open the file manager, then navigate to the given ``file_or_dir_path`` and select the target file or folder.
  847. If ``file_or_dir_path`` is a valid directory path, and ``open_folder`` is ``true``, the method will open the file manager and enter the target folder without selecting anything.
  848. Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` path into a system path for use with this method.
  849. \ **Note:** Currently this method is 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`` with prefix ``file://``.
  850. .. rst-class:: classref-item-separator
  851. ----
  852. .. _class_OS_method_unset_environment:
  853. .. rst-class:: classref-method
  854. void **unset_environment** **(** :ref:`String<class_String>` variable **)** |const|
  855. Removes the environment ``variable`` from the current environment, if it exists. 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.
  856. \ **Note:** Environment variable names are case-sensitive on all platforms except Windows. The ``variable`` name cannot be empty or include the ``=`` character.
  857. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  858. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  859. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  860. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  861. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  862. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  863. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`