[
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\r\n                       Version 3, 29 June 2007\r\n\r\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\r\n Everyone is permitted to copy and distribute verbatim copies\r\n of this license document, but changing it is not allowed.\r\n\r\n                            Preamble\r\n\r\n  The GNU General Public License is a free, copyleft license for\r\nsoftware and other kinds of works.\r\n\r\n  The licenses for most software and other practical works are designed\r\nto take away your freedom to share and change the works.  By contrast,\r\nthe GNU General Public License is intended to guarantee your freedom to\r\nshare and change all versions of a program--to make sure it remains free\r\nsoftware for all its users.  We, the Free Software Foundation, use the\r\nGNU General Public License for most of our software; it applies also to\r\nany other work released this way by its authors.  You can apply it to\r\nyour programs, too.\r\n\r\n  When we speak of free software, we are referring to freedom, not\r\nprice.  Our General Public Licenses are designed to make sure that you\r\nhave the freedom to distribute copies of free software (and charge for\r\nthem if you wish), that you receive source code or can get it if you\r\nwant it, that you can change the software or use pieces of it in new\r\nfree programs, and that you know you can do these things.\r\n\r\n  To protect your rights, we need to prevent others from denying you\r\nthese rights or asking you to surrender the rights.  Therefore, you have\r\ncertain responsibilities if you distribute copies of the software, or if\r\nyou modify it: responsibilities to respect the freedom of others.\r\n\r\n  For example, if you distribute copies of such a program, whether\r\ngratis or for a fee, you must pass on to the recipients the same\r\nfreedoms that you received.  You must make sure that they, too, receive\r\nor can get the source code.  And you must show them these terms so they\r\nknow their rights.\r\n\r\n  Developers that use the GNU GPL protect your rights with two steps:\r\n(1) assert copyright on the software, and (2) offer you this License\r\ngiving you legal permission to copy, distribute and/or modify it.\r\n\r\n  For the developers' and authors' protection, the GPL clearly explains\r\nthat there is no warranty for this free software.  For both users' and\r\nauthors' sake, the GPL requires that modified versions be marked as\r\nchanged, so that their problems will not be attributed erroneously to\r\nauthors of previous versions.\r\n\r\n  Some devices are designed to deny users access to install or run\r\nmodified versions of the software inside them, although the manufacturer\r\ncan do so.  This is fundamentally incompatible with the aim of\r\nprotecting users' freedom to change the software.  The systematic\r\npattern of such abuse occurs in the area of products for individuals to\r\nuse, which is precisely where it is most unacceptable.  Therefore, we\r\nhave designed this version of the GPL to prohibit the practice for those\r\nproducts.  If such problems arise substantially in other domains, we\r\nstand ready to extend this provision to those domains in future versions\r\nof the GPL, as needed to protect the freedom of users.\r\n\r\n  Finally, every program is threatened constantly by software patents.\r\nStates should not allow patents to restrict development and use of\r\nsoftware on general-purpose computers, but in those that do, we wish to\r\navoid the special danger that patents applied to a free program could\r\nmake it effectively proprietary.  To prevent this, the GPL assures that\r\npatents cannot be used to render the program non-free.\r\n\r\n  The precise terms and conditions for copying, distribution and\r\nmodification follow.\r\n\r\n                       TERMS AND CONDITIONS\r\n\r\n  0. Definitions.\r\n\r\n  \"This License\" refers to version 3 of the GNU General Public License.\r\n\r\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\r\nworks, such as semiconductor masks.\r\n\r\n  \"The Program\" refers to any copyrightable work licensed under this\r\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\r\n\"recipients\" may be individuals or organizations.\r\n\r\n  To \"modify\" a work means to copy from or adapt all or part of the work\r\nin a fashion requiring copyright permission, other than the making of an\r\nexact copy.  The resulting work is called a \"modified version\" of the\r\nearlier work or a work \"based on\" the earlier work.\r\n\r\n  A \"covered work\" means either the unmodified Program or a work based\r\non the Program.\r\n\r\n  To \"propagate\" a work means to do anything with it that, without\r\npermission, would make you directly or secondarily liable for\r\ninfringement under applicable copyright law, except executing it on a\r\ncomputer or modifying a private copy.  Propagation includes copying,\r\ndistribution (with or without modification), making available to the\r\npublic, and in some countries other activities as well.\r\n\r\n  To \"convey\" a work means any kind of propagation that enables other\r\nparties to make or receive copies.  Mere interaction with a user through\r\na computer network, with no transfer of a copy, is not conveying.\r\n\r\n  An interactive user interface displays \"Appropriate Legal Notices\"\r\nto the extent that it includes a convenient and prominently visible\r\nfeature that (1) displays an appropriate copyright notice, and (2)\r\ntells the user that there is no warranty for the work (except to the\r\nextent that warranties are provided), that licensees may convey the\r\nwork under this License, and how to view a copy of this License.  If\r\nthe interface presents a list of user commands or options, such as a\r\nmenu, a prominent item in the list meets this criterion.\r\n\r\n  1. Source Code.\r\n\r\n  The \"source code\" for a work means the preferred form of the work\r\nfor making modifications to it.  \"Object code\" means any non-source\r\nform of a work.\r\n\r\n  A \"Standard Interface\" means an interface that either is an official\r\nstandard defined by a recognized standards body, or, in the case of\r\ninterfaces specified for a particular programming language, one that\r\nis widely used among developers working in that language.\r\n\r\n  The \"System Libraries\" of an executable work include anything, other\r\nthan the work as a whole, that (a) is included in the normal form of\r\npackaging a Major Component, but which is not part of that Major\r\nComponent, and (b) serves only to enable use of the work with that\r\nMajor Component, or to implement a Standard Interface for which an\r\nimplementation is available to the public in source code form.  A\r\n\"Major Component\", in this context, means a major essential component\r\n(kernel, window system, and so on) of the specific operating system\r\n(if any) on which the executable work runs, or a compiler used to\r\nproduce the work, or an object code interpreter used to run it.\r\n\r\n  The \"Corresponding Source\" for a work in object code form means all\r\nthe source code needed to generate, install, and (for an executable\r\nwork) run the object code and to modify the work, including scripts to\r\ncontrol those activities.  However, it does not include the work's\r\nSystem Libraries, or general-purpose tools or generally available free\r\nprograms which are used unmodified in performing those activities but\r\nwhich are not part of the work.  For example, Corresponding Source\r\nincludes interface definition files associated with source files for\r\nthe work, and the source code for shared libraries and dynamically\r\nlinked subprograms that the work is specifically designed to require,\r\nsuch as by intimate data communication or control flow between those\r\nsubprograms and other parts of the work.\r\n\r\n  The Corresponding Source need not include anything that users\r\ncan regenerate automatically from other parts of the Corresponding\r\nSource.\r\n\r\n  The Corresponding Source for a work in source code form is that\r\nsame work.\r\n\r\n  2. Basic Permissions.\r\n\r\n  All rights granted under this License are granted for the term of\r\ncopyright on the Program, and are irrevocable provided the stated\r\nconditions are met.  This License explicitly affirms your unlimited\r\npermission to run the unmodified Program.  The output from running a\r\ncovered work is covered by this License only if the output, given its\r\ncontent, constitutes a covered work.  This License acknowledges your\r\nrights of fair use or other equivalent, as provided by copyright law.\r\n\r\n  You may make, run and propagate covered works that you do not\r\nconvey, without conditions so long as your license otherwise remains\r\nin force.  You may convey covered works to others for the sole purpose\r\nof having them make modifications exclusively for you, or provide you\r\nwith facilities for running those works, provided that you comply with\r\nthe terms of this License in conveying all material for which you do\r\nnot control copyright.  Those thus making or running the covered works\r\nfor you must do so exclusively on your behalf, under your direction\r\nand control, on terms that prohibit them from making any copies of\r\nyour copyrighted material outside their relationship with you.\r\n\r\n  Conveying under any other circumstances is permitted solely under\r\nthe conditions stated below.  Sublicensing is not allowed; section 10\r\nmakes it unnecessary.\r\n\r\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\r\n\r\n  No covered work shall be deemed part of an effective technological\r\nmeasure under any applicable law fulfilling obligations under article\r\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\r\nsimilar laws prohibiting or restricting circumvention of such\r\nmeasures.\r\n\r\n  When you convey a covered work, you waive any legal power to forbid\r\ncircumvention of technological measures to the extent such circumvention\r\nis effected by exercising rights under this License with respect to\r\nthe covered work, and you disclaim any intention to limit operation or\r\nmodification of the work as a means of enforcing, against the work's\r\nusers, your or third parties' legal rights to forbid circumvention of\r\ntechnological measures.\r\n\r\n  4. Conveying Verbatim Copies.\r\n\r\n  You may convey verbatim copies of the Program's source code as you\r\nreceive it, in any medium, provided that you conspicuously and\r\nappropriately publish on each copy an appropriate copyright notice;\r\nkeep intact all notices stating that this License and any\r\nnon-permissive terms added in accord with section 7 apply to the code;\r\nkeep intact all notices of the absence of any warranty; and give all\r\nrecipients a copy of this License along with the Program.\r\n\r\n  You may charge any price or no price for each copy that you convey,\r\nand you may offer support or warranty protection for a fee.\r\n\r\n  5. Conveying Modified Source Versions.\r\n\r\n  You may convey a work based on the Program, or the modifications to\r\nproduce it from the Program, in the form of source code under the\r\nterms of section 4, provided that you also meet all of these conditions:\r\n\r\n    a) The work must carry prominent notices stating that you modified\r\n    it, and giving a relevant date.\r\n\r\n    b) The work must carry prominent notices stating that it is\r\n    released under this License and any conditions added under section\r\n    7.  This requirement modifies the requirement in section 4 to\r\n    \"keep intact all notices\".\r\n\r\n    c) You must license the entire work, as a whole, under this\r\n    License to anyone who comes into possession of a copy.  This\r\n    License will therefore apply, along with any applicable section 7\r\n    additional terms, to the whole of the work, and all its parts,\r\n    regardless of how they are packaged.  This License gives no\r\n    permission to license the work in any other way, but it does not\r\n    invalidate such permission if you have separately received it.\r\n\r\n    d) If the work has interactive user interfaces, each must display\r\n    Appropriate Legal Notices; however, if the Program has interactive\r\n    interfaces that do not display Appropriate Legal Notices, your\r\n    work need not make them do so.\r\n\r\n  A compilation of a covered work with other separate and independent\r\nworks, which are not by their nature extensions of the covered work,\r\nand which are not combined with it such as to form a larger program,\r\nin or on a volume of a storage or distribution medium, is called an\r\n\"aggregate\" if the compilation and its resulting copyright are not\r\nused to limit the access or legal rights of the compilation's users\r\nbeyond what the individual works permit.  Inclusion of a covered work\r\nin an aggregate does not cause this License to apply to the other\r\nparts of the aggregate.\r\n\r\n  6. Conveying Non-Source Forms.\r\n\r\n  You may convey a covered work in object code form under the terms\r\nof sections 4 and 5, provided that you also convey the\r\nmachine-readable Corresponding Source under the terms of this License,\r\nin one of these ways:\r\n\r\n    a) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by the\r\n    Corresponding Source fixed on a durable physical medium\r\n    customarily used for software interchange.\r\n\r\n    b) Convey the object code in, or embodied in, a physical product\r\n    (including a physical distribution medium), accompanied by a\r\n    written offer, valid for at least three years and valid for as\r\n    long as you offer spare parts or customer support for that product\r\n    model, to give anyone who possesses the object code either (1) a\r\n    copy of the Corresponding Source for all the software in the\r\n    product that is covered by this License, on a durable physical\r\n    medium customarily used for software interchange, for a price no\r\n    more than your reasonable cost of physically performing this\r\n    conveying of source, or (2) access to copy the\r\n    Corresponding Source from a network server at no charge.\r\n\r\n    c) Convey individual copies of the object code with a copy of the\r\n    written offer to provide the Corresponding Source.  This\r\n    alternative is allowed only occasionally and noncommercially, and\r\n    only if you received the object code with such an offer, in accord\r\n    with subsection 6b.\r\n\r\n    d) Convey the object code by offering access from a designated\r\n    place (gratis or for a charge), and offer equivalent access to the\r\n    Corresponding Source in the same way through the same place at no\r\n    further charge.  You need not require recipients to copy the\r\n    Corresponding Source along with the object code.  If the place to\r\n    copy the object code is a network server, the Corresponding Source\r\n    may be on a different server (operated by you or a third party)\r\n    that supports equivalent copying facilities, provided you maintain\r\n    clear directions next to the object code saying where to find the\r\n    Corresponding Source.  Regardless of what server hosts the\r\n    Corresponding Source, you remain obligated to ensure that it is\r\n    available for as long as needed to satisfy these requirements.\r\n\r\n    e) Convey the object code using peer-to-peer transmission, provided\r\n    you inform other peers where the object code and Corresponding\r\n    Source of the work are being offered to the general public at no\r\n    charge under subsection 6d.\r\n\r\n  A separable portion of the object code, whose source code is excluded\r\nfrom the Corresponding Source as a System Library, need not be\r\nincluded in conveying the object code work.\r\n\r\n  A \"User Product\" is either (1) a \"consumer product\", which means any\r\ntangible personal property which is normally used for personal, family,\r\nor household purposes, or (2) anything designed or sold for incorporation\r\ninto a dwelling.  In determining whether a product is a consumer product,\r\ndoubtful cases shall be resolved in favor of coverage.  For a particular\r\nproduct received by a particular user, \"normally used\" refers to a\r\ntypical or common use of that class of product, regardless of the status\r\nof the particular user or of the way in which the particular user\r\nactually uses, or expects or is expected to use, the product.  A product\r\nis a consumer product regardless of whether the product has substantial\r\ncommercial, industrial or non-consumer uses, unless such uses represent\r\nthe only significant mode of use of the product.\r\n\r\n  \"Installation Information\" for a User Product means any methods,\r\nprocedures, authorization keys, or other information required to install\r\nand execute modified versions of a covered work in that User Product from\r\na modified version of its Corresponding Source.  The information must\r\nsuffice to ensure that the continued functioning of the modified object\r\ncode is in no case prevented or interfered with solely because\r\nmodification has been made.\r\n\r\n  If you convey an object code work under this section in, or with, or\r\nspecifically for use in, a User Product, and the conveying occurs as\r\npart of a transaction in which the right of possession and use of the\r\nUser Product is transferred to the recipient in perpetuity or for a\r\nfixed term (regardless of how the transaction is characterized), the\r\nCorresponding Source conveyed under this section must be accompanied\r\nby the Installation Information.  But this requirement does not apply\r\nif neither you nor any third party retains the ability to install\r\nmodified object code on the User Product (for example, the work has\r\nbeen installed in ROM).\r\n\r\n  The requirement to provide Installation Information does not include a\r\nrequirement to continue to provide support service, warranty, or updates\r\nfor a work that has been modified or installed by the recipient, or for\r\nthe User Product in which it has been modified or installed.  Access to a\r\nnetwork may be denied when the modification itself materially and\r\nadversely affects the operation of the network or violates the rules and\r\nprotocols for communication across the network.\r\n\r\n  Corresponding Source conveyed, and Installation Information provided,\r\nin accord with this section must be in a format that is publicly\r\ndocumented (and with an implementation available to the public in\r\nsource code form), and must require no special password or key for\r\nunpacking, reading or copying.\r\n\r\n  7. Additional Terms.\r\n\r\n  \"Additional permissions\" are terms that supplement the terms of this\r\nLicense by making exceptions from one or more of its conditions.\r\nAdditional permissions that are applicable to the entire Program shall\r\nbe treated as though they were included in this License, to the extent\r\nthat they are valid under applicable law.  If additional permissions\r\napply only to part of the Program, that part may be used separately\r\nunder those permissions, but the entire Program remains governed by\r\nthis License without regard to the additional permissions.\r\n\r\n  When you convey a copy of a covered work, you may at your option\r\nremove any additional permissions from that copy, or from any part of\r\nit.  (Additional permissions may be written to require their own\r\nremoval in certain cases when you modify the work.)  You may place\r\nadditional permissions on material, added by you to a covered work,\r\nfor which you have or can give appropriate copyright permission.\r\n\r\n  Notwithstanding any other provision of this License, for material you\r\nadd to a covered work, you may (if authorized by the copyright holders of\r\nthat material) supplement the terms of this License with terms:\r\n\r\n    a) Disclaiming warranty or limiting liability differently from the\r\n    terms of sections 15 and 16 of this License; or\r\n\r\n    b) Requiring preservation of specified reasonable legal notices or\r\n    author attributions in that material or in the Appropriate Legal\r\n    Notices displayed by works containing it; or\r\n\r\n    c) Prohibiting misrepresentation of the origin of that material, or\r\n    requiring that modified versions of such material be marked in\r\n    reasonable ways as different from the original version; or\r\n\r\n    d) Limiting the use for publicity purposes of names of licensors or\r\n    authors of the material; or\r\n\r\n    e) Declining to grant rights under trademark law for use of some\r\n    trade names, trademarks, or service marks; or\r\n\r\n    f) Requiring indemnification of licensors and authors of that\r\n    material by anyone who conveys the material (or modified versions of\r\n    it) with contractual assumptions of liability to the recipient, for\r\n    any liability that these contractual assumptions directly impose on\r\n    those licensors and authors.\r\n\r\n  All other non-permissive additional terms are considered \"further\r\nrestrictions\" within the meaning of section 10.  If the Program as you\r\nreceived it, or any part of it, contains a notice stating that it is\r\ngoverned by this License along with a term that is a further\r\nrestriction, you may remove that term.  If a license document contains\r\na further restriction but permits relicensing or conveying under this\r\nLicense, you may add to a covered work material governed by the terms\r\nof that license document, provided that the further restriction does\r\nnot survive such relicensing or conveying.\r\n\r\n  If you add terms to a covered work in accord with this section, you\r\nmust place, in the relevant source files, a statement of the\r\nadditional terms that apply to those files, or a notice indicating\r\nwhere to find the applicable terms.\r\n\r\n  Additional terms, permissive or non-permissive, may be stated in the\r\nform of a separately written license, or stated as exceptions;\r\nthe above requirements apply either way.\r\n\r\n  8. Termination.\r\n\r\n  You may not propagate or modify a covered work except as expressly\r\nprovided under this License.  Any attempt otherwise to propagate or\r\nmodify it is void, and will automatically terminate your rights under\r\nthis License (including any patent licenses granted under the third\r\nparagraph of section 11).\r\n\r\n  However, if you cease all violation of this License, then your\r\nlicense from a particular copyright holder is reinstated (a)\r\nprovisionally, unless and until the copyright holder explicitly and\r\nfinally terminates your license, and (b) permanently, if the copyright\r\nholder fails to notify you of the violation by some reasonable means\r\nprior to 60 days after the cessation.\r\n\r\n  Moreover, your license from a particular copyright holder is\r\nreinstated permanently if the copyright holder notifies you of the\r\nviolation by some reasonable means, this is the first time you have\r\nreceived notice of violation of this License (for any work) from that\r\ncopyright holder, and you cure the violation prior to 30 days after\r\nyour receipt of the notice.\r\n\r\n  Termination of your rights under this section does not terminate the\r\nlicenses of parties who have received copies or rights from you under\r\nthis License.  If your rights have been terminated and not permanently\r\nreinstated, you do not qualify to receive new licenses for the same\r\nmaterial under section 10.\r\n\r\n  9. Acceptance Not Required for Having Copies.\r\n\r\n  You are not required to accept this License in order to receive or\r\nrun a copy of the Program.  Ancillary propagation of a covered work\r\noccurring solely as a consequence of using peer-to-peer transmission\r\nto receive a copy likewise does not require acceptance.  However,\r\nnothing other than this License grants you permission to propagate or\r\nmodify any covered work.  These actions infringe copyright if you do\r\nnot accept this License.  Therefore, by modifying or propagating a\r\ncovered work, you indicate your acceptance of this License to do so.\r\n\r\n  10. Automatic Licensing of Downstream Recipients.\r\n\r\n  Each time you convey a covered work, the recipient automatically\r\nreceives a license from the original licensors, to run, modify and\r\npropagate that work, subject to this License.  You are not responsible\r\nfor enforcing compliance by third parties with this License.\r\n\r\n  An \"entity transaction\" is a transaction transferring control of an\r\norganization, or substantially all assets of one, or subdividing an\r\norganization, or merging organizations.  If propagation of a covered\r\nwork results from an entity transaction, each party to that\r\ntransaction who receives a copy of the work also receives whatever\r\nlicenses to the work the party's predecessor in interest had or could\r\ngive under the previous paragraph, plus a right to possession of the\r\nCorresponding Source of the work from the predecessor in interest, if\r\nthe predecessor has it or can get it with reasonable efforts.\r\n\r\n  You may not impose any further restrictions on the exercise of the\r\nrights granted or affirmed under this License.  For example, you may\r\nnot impose a license fee, royalty, or other charge for exercise of\r\nrights granted under this License, and you may not initiate litigation\r\n(including a cross-claim or counterclaim in a lawsuit) alleging that\r\nany patent claim is infringed by making, using, selling, offering for\r\nsale, or importing the Program or any portion of it.\r\n\r\n  11. Patents.\r\n\r\n  A \"contributor\" is a copyright holder who authorizes use under this\r\nLicense of the Program or a work on which the Program is based.  The\r\nwork thus licensed is called the contributor's \"contributor version\".\r\n\r\n  A contributor's \"essential patent claims\" are all patent claims\r\nowned or controlled by the contributor, whether already acquired or\r\nhereafter acquired, that would be infringed by some manner, permitted\r\nby this License, of making, using, or selling its contributor version,\r\nbut do not include claims that would be infringed only as a\r\nconsequence of further modification of the contributor version.  For\r\npurposes of this definition, \"control\" includes the right to grant\r\npatent sublicenses in a manner consistent with the requirements of\r\nthis License.\r\n\r\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\r\npatent license under the contributor's essential patent claims, to\r\nmake, use, sell, offer for sale, import and otherwise run, modify and\r\npropagate the contents of its contributor version.\r\n\r\n  In the following three paragraphs, a \"patent license\" is any express\r\nagreement or commitment, however denominated, not to enforce a patent\r\n(such as an express permission to practice a patent or covenant not to\r\nsue for patent infringement).  To \"grant\" such a patent license to a\r\nparty means to make such an agreement or commitment not to enforce a\r\npatent against the party.\r\n\r\n  If you convey a covered work, knowingly relying on a patent license,\r\nand the Corresponding Source of the work is not available for anyone\r\nto copy, free of charge and under the terms of this License, through a\r\npublicly available network server or other readily accessible means,\r\nthen you must either (1) cause the Corresponding Source to be so\r\navailable, or (2) arrange to deprive yourself of the benefit of the\r\npatent license for this particular work, or (3) arrange, in a manner\r\nconsistent with the requirements of this License, to extend the patent\r\nlicense to downstream recipients.  \"Knowingly relying\" means you have\r\nactual knowledge that, but for the patent license, your conveying the\r\ncovered work in a country, or your recipient's use of the covered work\r\nin a country, would infringe one or more identifiable patents in that\r\ncountry that you have reason to believe are valid.\r\n\r\n  If, pursuant to or in connection with a single transaction or\r\narrangement, you convey, or propagate by procuring conveyance of, a\r\ncovered work, and grant a patent license to some of the parties\r\nreceiving the covered work authorizing them to use, propagate, modify\r\nor convey a specific copy of the covered work, then the patent license\r\nyou grant is automatically extended to all recipients of the covered\r\nwork and works based on it.\r\n\r\n  A patent license is \"discriminatory\" if it does not include within\r\nthe scope of its coverage, prohibits the exercise of, or is\r\nconditioned on the non-exercise of one or more of the rights that are\r\nspecifically granted under this License.  You may not convey a covered\r\nwork if you are a party to an arrangement with a third party that is\r\nin the business of distributing software, under which you make payment\r\nto the third party based on the extent of your activity of conveying\r\nthe work, and under which the third party grants, to any of the\r\nparties who would receive the covered work from you, a discriminatory\r\npatent license (a) in connection with copies of the covered work\r\nconveyed by you (or copies made from those copies), or (b) primarily\r\nfor and in connection with specific products or compilations that\r\ncontain the covered work, unless you entered into that arrangement,\r\nor that patent license was granted, prior to 28 March 2007.\r\n\r\n  Nothing in this License shall be construed as excluding or limiting\r\nany implied license or other defenses to infringement that may\r\notherwise be available to you under applicable patent law.\r\n\r\n  12. No Surrender of Others' Freedom.\r\n\r\n  If conditions are imposed on you (whether by court order, agreement or\r\notherwise) that contradict the conditions of this License, they do not\r\nexcuse you from the conditions of this License.  If you cannot convey a\r\ncovered work so as to satisfy simultaneously your obligations under this\r\nLicense and any other pertinent obligations, then as a consequence you may\r\nnot convey it at all.  For example, if you agree to terms that obligate you\r\nto collect a royalty for further conveying from those to whom you convey\r\nthe Program, the only way you could satisfy both those terms and this\r\nLicense would be to refrain entirely from conveying the Program.\r\n\r\n  13. Use with the GNU Affero General Public License.\r\n\r\n  Notwithstanding any other provision of this License, you have\r\npermission to link or combine any covered work with a work licensed\r\nunder version 3 of the GNU Affero General Public License into a single\r\ncombined work, and to convey the resulting work.  The terms of this\r\nLicense will continue to apply to the part which is the covered work,\r\nbut the special requirements of the GNU Affero General Public License,\r\nsection 13, concerning interaction through a network will apply to the\r\ncombination as such.\r\n\r\n  14. Revised Versions of this License.\r\n\r\n  The Free Software Foundation may publish revised and/or new versions of\r\nthe GNU General Public License from time to time.  Such new versions will\r\nbe similar in spirit to the present version, but may differ in detail to\r\naddress new problems or concerns.\r\n\r\n  Each version is given a distinguishing version number.  If the\r\nProgram specifies that a certain numbered version of the GNU General\r\nPublic License \"or any later version\" applies to it, you have the\r\noption of following the terms and conditions either of that numbered\r\nversion or of any later version published by the Free Software\r\nFoundation.  If the Program does not specify a version number of the\r\nGNU General Public License, you may choose any version ever published\r\nby the Free Software Foundation.\r\n\r\n  If the Program specifies that a proxy can decide which future\r\nversions of the GNU General Public License can be used, that proxy's\r\npublic statement of acceptance of a version permanently authorizes you\r\nto choose that version for the Program.\r\n\r\n  Later license versions may give you additional or different\r\npermissions.  However, no additional obligations are imposed on any\r\nauthor or copyright holder as a result of your choosing to follow a\r\nlater version.\r\n\r\n  15. Disclaimer of Warranty.\r\n\r\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\r\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\r\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\r\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\r\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\r\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r\n\r\n  16. Limitation of Liability.\r\n\r\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\r\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\r\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\r\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\r\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\r\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\r\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\r\nSUCH DAMAGES.\r\n\r\n  17. Interpretation of Sections 15 and 16.\r\n\r\n  If the disclaimer of warranty and limitation of liability provided\r\nabove cannot be given local legal effect according to their terms,\r\nreviewing courts shall apply local law that most closely approximates\r\nan absolute waiver of all civil liability in connection with the\r\nProgram, unless a warranty or assumption of liability accompanies a\r\ncopy of the Program in return for a fee.\r\n\r\n                     END OF TERMS AND CONDITIONS\r\n\r\n            How to Apply These Terms to Your New Programs\r\n\r\n  If you develop a new program, and you want it to be of the greatest\r\npossible use to the public, the best way to achieve this is to make it\r\nfree software which everyone can redistribute and change under these terms.\r\n\r\n  To do so, attach the following notices to the program.  It is safest\r\nto attach them to the start of each source file to most effectively\r\nstate the exclusion of warranty; and each file should have at least\r\nthe \"copyright\" line and a pointer to where the full notice is found.\r\n\r\n    <one line to give the program's name and a brief idea of what it does.>\r\n    Copyright (C) <year>  <name of author>\r\n\r\n    This program is free software: you can redistribute it and/or modify\r\n    it under the terms of the GNU General Public License as published by\r\n    the Free Software Foundation, either version 3 of the License, or\r\n    (at your option) any later version.\r\n\r\n    This program is distributed in the hope that it will be useful,\r\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n    GNU General Public License for more details.\r\n\r\n    You should have received a copy of the GNU General Public License\r\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\r\n\r\nAlso add information on how to contact you by electronic and paper mail.\r\n\r\n  If the program does terminal interaction, make it output a short\r\nnotice like this when it starts in an interactive mode:\r\n\r\n    <program>  Copyright (C) <year>  <name of author>\r\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n    This is free software, and you are welcome to redistribute it\r\n    under certain conditions; type `show c' for details.\r\n\r\nThe hypothetical commands `show w' and `show c' should show the appropriate\r\nparts of the General Public License.  Of course, your program's commands\r\nmight be different; for a GUI interface, you would use an \"about box\".\r\n\r\n  You should also get your employer (if you work as a programmer) or school,\r\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\r\nFor more information on this, and how to apply and follow the GNU GPL, see\r\n<https://www.gnu.org/licenses/>.\r\n\r\n  The GNU General Public License does not permit incorporating your program\r\ninto proprietary programs.  If your program is a subroutine library, you\r\nmay consider it more useful to permit linking proprietary applications with\r\nthe library.  If this is what you want to do, use the GNU Lesser General\r\nPublic License instead of this License.  But first, please read\r\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\r\n"
  },
  {
    "path": "README.md",
    "content": "![logo](img/logo.png \"logo\")\r\n\r\n**Darkos** is a project designed to run Windows x86_64 applications and games in [Termux](https://github.com/termux/termux-app) native GLIBC.\r\nIt utilizes [Box86](https://github.com/ptitSeb/box86)\r\nand [Box64](https://github.com/ptitSeb/box86)\r\nto run [Wine](https://www.winehq.org/) on android.\r\n\r\n# Installation:\r\n1. Install\r\n[Termux](https://github.com/termux/termux-app),\r\n[Termux-X11](https://github.com/ahmad1abbadi/extra/releases/download/apps/termux-x11.apk) and\r\n[Input Bridge v0.1.9.9](https://github.com/ahmad1abbadi/extra/releases/download/apps/InputBridge_v0.1.9.9.apk) or [Input Bridge v0.0.7](https://github.com/ahmad1abbadi/extra/releases/download/apps/input+bridge+0.0.7.apk)\r\nor \r\n[X input Bridge](https://github.com/ahmad1abbadi/extra/releases/download/apps/XinputBridge.apk)\r\nfor using game controller (Bluetooth/ usb) inside wine.\r\n\r\n1. Open Termux and paste the following command:\r\n```bash\r\ncurl -o install https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/installOS.sh && chmod +x install && ./install\r\n```\r\n\r\n3. **Darkos** will automatically start after installation is complete.\r\n   Remember each time you open Termux, Darkos will auto-start.\r\n   \r\n   To exit **Darkos** and use Termux normally, press '1' within the first 4 seconds. Otherwise, Darkos will start and run Wine + Termux-X11.\r\n   \r\n# Features:\r\n1. Native Gstreamer support, which is required for games like:\r\n* resident evil 7\r\n* devil may cry 5\r\n* amid evil\r\n2. Dedicated configuration app\r\n3. Many games will work without altering box64 dynarec settings\r\n\r\n  And many more, you can discover by your self.\r\n  \r\n# Configuration:\r\n\r\n## Box64/Box86 Configuration + Dynarec\r\nThe configuration can be easily done from the Darkos configuration app. Simply modify the Box options, click \"Apply,\" and then \"Reboot\" to apply the changes.\r\n\r\nFor more information about dynarec variables see [Box64 usage](https://github.com/ptitSeb/box64/blob/main/docs/USAGE.md) and [Box86 usage](https://github.com/ptitSeb/box86/blob/master/docs/USAGE.md)\r\n\r\n## Update OS\r\nThis option updates Darkos to the latest version.\r\n\r\n## Wine Manager \r\nWine can be installed or uninstalled from the Darkos configuration embedded within Wine. Simply select the \"Wine manager\" option.\r\n\r\nTo select a Wine container, use the container dropdown menu from the Darkos configuration and then click \"Change container.\"\r\n\r\n\r\n## Debug Mode\r\nThis mode enables printing Wine and Box64 debug information to a log file located at /sdcard/darkos/darkos.log. You can share this file to our Telegram group.\r\n\r\n## Toggle Mangohud\r\nMangohud is an on-screen display (OSD) that shows useful information like FPS, CPU usage, GPU load, and GPU temperature.\r\n\r\nCurrently, to see GPU load and temperature stats, you need to disable SELinux by running the following command in Termux(root is required):\r\n```\r\nsu -c setenforce 0\r\n```\r\nTo re-enable SELinux:\r\n\r\n```\r\nsu -c setenforce 1\r\n```\r\n\r\n## GPU Driver Changer\r\nThis option allows you to change the GPU driver.\r\n\r\n## Switch IB\r\nThis toggle lets you switch the input bridge between version 0.1.9.9 and version 0.0.7. Choose the version that works best for you.\r\n\r\n## Kill Services\r\nUse this toggle to kill services.exe without needing to open the task manager.\r\n\r\n## Hit F5 key\r\nThis will open the task manager.\r\n\r\n## DXVK changer \r\nThis option lets you choose the DXVK version, allowing you to select the one that works best for a specific game.\r\n\r\n## Install Tweaks\r\nThis option lets you install Wine tricks like apps, DLLs, and fonts.\r\n\r\n## Personalize\r\nYou can change the theme, background, or resolution of the Wine desktop.\r\n\r\n## Termux-X11 resolution \r\nThe fallback resolution is only used when the X11 resolution cannot be detected automatically. The default fallback resolution is 800x600.\r\n\r\n## Termux and termux-x11 preferences\r\n### recommend setup for termux:\r\n* `Allow apps to open new windows while running in the background`\r\n* `Allow apps to display pop-up windows`\r\n\r\n### recommend setup for termux-x11:\r\n* `Display resolution mode` exact\r\n* `Display resolution` 1280x720\r\n* `Reseed Screen While Soft Keyboard is open` OFF\r\n* `Fullscreen on device display` ON\r\n* `Force Landscape orientation` ON\r\n* `Hide display cutout` ON\r\n* `Show additional keyboard` OFF\r\n* `Prefer scancodes when possible` ON\r\n* `Enable Accessibility service for intercepting\r\nsystem shortcuts manually.` enable termux-x11 from android accessibility menu so you can use external keyboard (wired/wireless) without issues.\r\n* `Enable Accessibility service for intercepting system shortcuts automatically.` ON\r\n\r\n## Controls\r\nFor touch controls Input Bridge app is required.\r\n\r\n## Support status\r\n**Android 10 or higher is recommended.\r\n\r\n### Device\r\n* Most Android phones equipped with a Mali GPU can run DirectX 9 games using [Mesa VirGL](https://github.com/alexvorxx/Mesa-VirGL) . It is recommended to use a Snapdragon device with Adreno 6xx or Adreno 7xx for optimal performance and compatibility with Turnip and [DXVK](https://github.com/doitsujin/dxvk).\r\n\r\n### Root\r\n* Root is not required.\r\n\r\n## Known issues\r\n* termux app can show signal 9 when using wine or while compiling box64, in this case you have to disable android phantom process killer.\r\n  \r\n## Support Darkos\r\n[buy me a coffee](https://www.buymeacoffee.com/AZabbadi)\r\n#\r\n\r\n## Darkos Developers \r\n\r\n[AZ](https://github.com/ahmad1abbadi) \r\n\r\n[Hisham](https://github.com/hisham2630)\r\n\r\n[Md arif](https://github.com/sabamdarif)\r\n\r\n[zhongerxll](https://github.com/zhongerxll) \r\n\r\n[Ilan12346-maya](https://github.com/Ilan12346-maya)\r\n  \r\n[GabiAle97](https://github.com/GabiAle97)\r\n\r\n#\r\n\r\nthanks to our testers:\r\n\r\nGhostDz36, caoji080\r\n\r\n#\r\nHuge thanks to:\r\n\r\n[airidosas252](https://github.com/airidosas252) for his turnip and wine builds.\r\n#\r\nSpecial thanks to ptitSeb, Maxython, glibc-runner, hardray, Tωaik, zhongerxll , hugo, .[jeezdisreez](https://github.com/Pipetto-crypto), olegos2 and others for help.\r\n\r\n[Darkos telegram group](https://t.me/DARKOS4android)\r\n\r\n## Third party applications\r\n\r\n[glibc-packages](https://github.com/termux-pacman/glibc-packages)\r\n\r\n[Box64](https://github.com/ptitSeb/box64)\r\n\r\n[Box86](https://github.com/ptitSeb/box86)\r\n\r\n[DXVK](https://github.com/doitsujin/dxvk)\r\n\r\n[DXVK-ASYNC](https://github.com/Sporif/dxvk-async)\r\n\r\n[DXVK-GPLASYNC](https://gitlab.com/Ph42oN/dxvk-gplasync)\r\n\r\n[VKD3D](https://github.com/lutris/vkd3d)\r\n\r\n[D8VK](https://github.com/AlpyneDreams/d8vk)\r\n\r\n[Termux-app](https://github.com/termux/termux-app)\r\n\r\n[Termux-x11](https://github.com/termux/termux-x11)\r\n\r\n[Wine](https://wiki.winehq.org/Licensing)\r\n\r\n[wine-ge-custom](https://github.com/GloriousEggroll/wine-ge-custom)\r\n\r\n[Mesa](https://docs.mesa3d.org/license.html)\r\n\r\n[Mangohud](https://github.com/flightlessmango/MangoHud)\r\n"
  },
  {
    "path": "boost_launcher",
    "content": "#!/bin/bash\n\nsu -c /data/data/com.termux/files/usr/bin/python /data/data/com.termux/files/usr/bin/cpu_boost.py"
  },
  {
    "path": "cpu_boost.py",
    "content": "import psutil\r\nimport time\r\nimport gc\r\nfrom concurrent.futures import ThreadPoolExecutor\r\nfrom blessings import Terminal\r\nimport concurrent.futures\r\nimport os\r\nfrom threading import Lock\r\nimport multiprocessing\r\nfrom multiprocessing import Process, Queue\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\n# Initialize blessings terminal\r\nterm = Terminal()\r\n\r\ndef get_cpu_core_count():\r\n    core_count = psutil.cpu_count(logical=False)\r\n    return core_count\r\n\r\ndef get_cpu_info():\r\n    cpu_info = {\r\n        \"CPU Count\": psutil.cpu_count(logical=False),\r\n        \"Logical CPU Count\": psutil.cpu_count(logical=True),\r\n        \"CPU Frequency\": psutil.cpu_freq().current,\r\n        \"Max CPU Frequency\": psutil.cpu_freq().max,\r\n        \"Memory Usage\": psutil.virtual_memory().percent,\r\n        \"Available Memory\": psutil.virtual_memory().available,\r\n        \"Total Memory\": psutil.virtual_memory().total,\r\n    }\r\n\r\n    cpu_freqs = psutil.cpu_freq(percpu=True)\r\n    for core, freq_info in enumerate(cpu_freqs):\r\n        cpu_info[f\"Core {core + 1} Frequency\"] = freq_info.current\r\n        cpu_info[f\"Core {core + 1} Max Frequency\"] = freq_info.max\r\n\r\n    return cpu_info, cpu_freqs\r\n\r\ndef get_cpu_usage(process):\r\n    return process.info['pid'], process.info['cpu_percent'], len(process.info['cpu_affinity'])\r\n\r\ndef get_file_descriptor_info(pid):\r\n    try:\r\n        files = psutil.Process(pid).open_files()\r\n        file_names = [file.path for file in files]\r\n        return file_names\r\n    except (psutil.NoSuchProcess, psutil.AccessDenied) as e:\r\n        print(f\"{R} Error getting file descriptor info for PID {pid}: {e} {W}\")\r\n        return []\r\n\r\ndef get_shared_memory_info(pid):\r\n    try:\r\n        process = psutil.Process(pid)\r\n        shared_memory_info = []\r\n\r\n        for mmap in process.memory_maps(grouped=True):\r\n            if mmap[0] == '[heap]':\r\n                continue  # Skip heap memory\r\n            if mmap[0].startswith('/dev/shm'):\r\n                shared_memory_info.append({\r\n                    'path': mmap[0],\r\n                    'size': mmap[1].rss,  # Get the size from the RSS (Resident Set Size)\r\n                })\r\n\r\n        return shared_memory_info\r\n    except (psutil.NoSuchProcess, psutil.AccessDenied) as e:\r\n        print(f\"{R} Error getting shared memory info for PID {pid}: {e} {W}\")\r\n        return []\r\n\r\ndef get_idle_cores():\r\n    # Get the list of logical CPU cores\r\n    logical_cores = list(range(psutil.cpu_count(logical=True)))\r\n\r\n    # Get the list of currently busy cores\r\n    busy_cores = set(psutil.cpu_percent(percpu=True, interval=0.1))\r\n\r\n    # Find idle cores (not in busy_cores)\r\n    idle_cores = [core for core in logical_cores if core not in busy_cores]\r\n\r\n    return idle_cores\r\n\r\ndef get_core_score(core, current_cpu_load, cpu_freqs):\r\n    # Calculate a score for the core based on current CPU load and frequency\r\n    freq_score = cpu_freqs[core].current / max(cpu_freqs[core].max, 1)  # Normalize frequency\r\n    load_score = 1 - current_cpu_load / 100  # Invert load for higher load to have a lower score\r\n    return freq_score * load_score\r\n\r\ndef get_high_frequency_cores(cpu_freqs, num_cores=4):\r\n    # Get the list of cores sorted by frequency in descending order\r\n    sorted_cores = sorted(range(len(cpu_freqs)), key=lambda x: cpu_freqs[x].current, reverse=True)\r\n    return sorted_cores[:num_cores]\r\n\r\ndef adjust_cpu_and_priority(process, num_cores_to_assign, cpu_freqs):\r\n    try:\r\n        # Get the current CPU load for the process\r\n        current_cpu_load = process.cpu_percent(interval=0.1)\r\n\r\n        # Remember the previous affinity\r\n        previous_affinity = process.cpu_affinity()\r\n\r\n        # Get idle cores\r\n        idle_cores = get_idle_cores()\r\n\r\n        # Get high-frequency cores\r\n        high_frequency_cores = get_high_frequency_cores(cpu_freqs, num_cores_to_assign)\r\n\r\n        # Prioritize high-frequency cores with low current CPU load\r\n        sorted_cores = sorted(high_frequency_cores, key=lambda core: get_core_score(core, current_cpu_load, cpu_freqs), reverse=True)\r\n\r\n        # Assign the first num_cores_to_assign cores to the process only if the affinity has changed\r\n        if set(sorted_cores) != set(previous_affinity):\r\n            process.cpu_affinity(sorted_cores)\r\n\r\n            # Set the priority of the process to a higher value\r\n            process.nice(-10)  # Adjust the nice value as needed\r\n\r\n            print(f\"{G} Adjusted CPU affinity and priority for PID {process.info['pid']} {W}\")\r\n        else:\r\n            print(f\"{C} No need to adjust CPU affinity for PID {process.info['pid']} {W}\")\r\n    except (psutil.NoSuchProcess, IndexError, psutil.AccessDenied) as e:\r\n        print(f\"{R} Error adjusting CPU affinity and priority: {e} {W}\")\r\n\r\ndef optimize_memory_for_high_cpu_process(process, recommended_memory_gb=6):\r\n    try:\r\n        # Get detailed memory information\r\n        mem_info = process.memory_full_info()\r\n\r\n        # Convert recommended_memory_gb to kilobytes\r\n        recommended_memory_kb = recommended_memory_gb * 1024 * 1024\r\n\r\n        # Calculate dynamically adjusted release amount based on current memory usage\r\n        release_amount_gb = max((mem_info.rss - recommended_memory_kb) / (1024 * 1024), 0)\r\n\r\n        if release_amount_gb > 0:\r\n            # Example: Release dynamically calculated amount of memory\r\n            process.memory_info().rss -= int(release_amount_gb * 1024 * 1024)\r\n            print(f\"{G} Released {C} {release_amount_gb:.2f} GB {G} of memory for PID {C} {process.info['pid']} {W}\")\r\n\r\n            # Trigger garbage collection to handle remaining cleanup\r\n            gc.collect()\r\n\r\n        else:\r\n            print(f\"{G} No unnecessary memory to release for PID {C}{process.info['pid']} {W}\")\r\n    except (psutil.NoSuchProcess, psutil.AccessDenied) as e:\r\n        print(f\"{R} Error optimizing memory for process: {C}{e} {W}\")\r\n\r\nclass ProcessInfo:\r\n    def __init__(self, pid, cpu_usage, file_descriptors):\r\n        self.pid = pid\r\n        self.cpu_usage = cpu_usage\r\n        self.file_descriptors = file_descriptors\r\n\r\nclass SharedMemory:\r\n    def __init__(self, size):\r\n        self.data = bytearray(size)\r\n        self.lock = Lock()\r\n\r\n    def set_value(self, offset, value):\r\n        with self.lock:\r\n            self.data[offset:offset+len(value)] = value.encode()\r\n\r\n    def get_value(self, offset, size):\r\n        with self.lock:\r\n            return self.data[offset:offset+size].decode()\r\n\r\ndef get_c_process_file_info(process_to_check):\r\n    # Replace with your platform-specific logic to identify C processes\r\n    for process in psutil.process_iter():\r\n        if process.info['pid'] == process_to_check.info['pid']:\r\n            # Extract file information from the process (e.g., file descriptors, paths)\r\n            file_info = get_file_descriptor_info(process.info['pid'])\r\n            shared_memory_info = get_shared_memory_info(process.info['pid'])\r\n            return file_info, shared_memory_info  # Replace with actual file information\r\n    return None\r\n\r\ndef io_operation(shared_memory_segment, process_to_check, pid, result_queue):\r\n    try:\r\n        # Obtain file information and shared memory info from the specified process\r\n        file_info, shared_memory_info = get_c_process_file_info(process_to_check)\r\n\r\n        with shared_memory_segment.lock:\r\n            # Assuming shared_memory_info is a dictionary containing relevant information\r\n            serialized_process_info = pickle.dumps(ProcessInfo(process_to_check.info['pid'],\r\n                                                              process_to_check.info['cpu_percent'],\r\n                                                              file_info))\r\n            \r\n            # Assuming shared_memory_info contains necessary metadata, adjust the offsets accordingly\r\n            shared_memory_segment.set_value(0, f\"pid:{process_to_check.info['pid']}\")\r\n            shared_memory_segment.set_value(4, len(serialized_process_info).to_bytes(4, byteorder=\"big\"))\r\n            shared_memory_segment.set_value(8, serialized_process_info)\r\n\r\n            # Continue with the rest of the function logic\r\n            data = shared_memory_segment.read().decode()\r\n\r\n            if data.startswith(\"pid:\"):\r\n                offset = 4\r\n                pid_value = int(data[4:offset])\r\n                offset += 4\r\n                cpu_usage_size = int(data[offset:offset+4])\r\n                offset += 4\r\n                cpu_usage = data[offset:offset+cpu_usage_size]\r\n                offset += cpu_usage_size\r\n                file_descriptors_size = int(data[offset:offset+4])\r\n                offset += 4\r\n                file_descriptors = data[offset:offset+file_descriptors_size]\r\n                process_info = pickle.loads(cpu_usage + file_descriptors)\r\n\r\n                # Use pid_value as needed in the function\r\n                # ...\r\n\r\n                # I/O processing logic with process_info\r\n                processed_data = \"Processed result\"\r\n\r\n                # Put the processed data into the result_queue\r\n                result_queue.put(processed_data)\r\n\r\n            else:\r\n                data = json.loads(data)\r\n                file_paths = data[\"file_paths\"]\r\n                results = multiprocessing.Pool().map(read_file_async, file_paths)\r\n                for result in results:\r\n                    process_data(result)\r\n\r\n    except Exception as e:\r\n        logger.error(f\"Error in I/O operation: {e}\")\r\n\r\ndef cpu_memory():\r\n    try:\r\n        # Create a Queue for communication within the same process\r\n        result_queue = Queue()\r\n\r\n        with ThreadPoolExecutor() as executor:\r\n            while True:\r\n                cpu_info_future = executor.submit(get_cpu_info)\r\n                processes = psutil.process_iter(['pid', 'name', 'cpu_percent', 'cpu_affinity'])\r\n                cpu_usage_futures = list(executor.map(get_cpu_usage, processes))\r\n\r\n                cpu_info, cpu_freqs = cpu_info_future.result()\r\n\r\n                cpu_core_count = get_cpu_core_count()\r\n\r\n                high_usage_process = max(processes, key=lambda process: process.info['cpu_percent'], default=None)\r\n\r\n                if high_usage_process:\r\n                    adjust_cpu_and_priority(high_usage_process, num_cores_to_assign, cpu_freqs)\r\n\r\n                if high_usage_process and high_usage_process.info['cpu_percent'] > 50:\r\n                    optimize_memory_for_high_cpu_process(high_usage_process, recommended_memory_gb=5)\r\n\r\n                    # Check if the process has more than 10 files for I/O parallelization\r\n\r\n                    shared_memory.set_value(0, pid.to_bytes(4, byteorder=\"big\"))\r\n                    shared_memory.set_value(4, len(serialized_process_info).to_bytes(4, byteorder=\"big\"))\r\n                    shared_memory.set_value(8, serialized_process_info)\r\n\r\n                    # Call io_operation with the result_queue and high_usage_process\r\n                    io_operation(shared_memory, high_usage_process, pid, result_queue)\r\n\r\n                    # Retrieve the processed data from the result_queue\r\n                    processed_data = result_queue.get()\r\n\r\n                    # Get file information for the high CPU process\r\n                    file_info = get_file_descriptor_info(high_usage_process.info['pid'])\r\n                    num_files = len(file_info)\r\n                    print(f\"{G} Number of files in use by PID {C} {high_usage_process.info['pid']}: {num_files} {W}\")\r\n\r\n                low_usage_processes = [process for process in processes\r\n                                       if process.info['cpu_percent'] < 5 and process.info['create_time'] < time.time() - 10]\r\n\r\n                for process in low_usage_processes:\r\n                    idle_cores = get_idle_cores()\r\n                    low_scoring_cores = get_high_frequency_cores(cpu_freqs, num_cores_to_assign)\r\n                    sorted_cores = sorted(low_scoring_cores,\r\n                                          key=lambda core: get_core_score(core, 0, cpu_freqs),\r\n                                          reverse=False)\r\n                    process.cpu_affinity(sorted_cores)\r\n\r\n                    print(f\"{G}Assigned low-scoring cores for PID {C}{process.info['pid']} {W}\")\r\n\r\n                with term.fullscreen():\r\n                    print(term.clear)\r\n                    print(f\"{R}[{W}-{R}]{G}{BOLD} CPU Info: {W}\")\r\n                    for key, value in cpu_info.items():\r\n                        print(f\"{G}{key}: {C}{value} {W}\")\r\n\r\n                    print(f\"{R}[{W}-{R}]{G}{BOLD} \\nCPU Usage: {W}\")\r\n                    for process_pid, process_usage, process_core_count in cpu_usage_futures:\r\n                        print(f\"{G}PID {process_pid}: {C}{process_usage}% {G}(Using {C}{process_core_count} {G}cores) {W}\")\r\n                        num_files = len(get_file_descriptor_info(process_pid))\r\n                        print(f\"{R}[{W}-{R}]{G}{BOLD} Number of files for PID {process_pid}: {C}{num_files} {W}\")\r\n\r\n                    print(f\"{R}[{W}-{R}]{G}{BOLD} \\nMemory Info: {W}\")\r\n                    print(f\"{G} Memory Usage: {C}{cpu_info['Memory Usage']}% {W}\")\r\n                    print(f\"{G} Available Memory: {C}{cpu_info['Available Memory']} bytes {W}\")\r\n                    print(f\"{G} Total Memory: {C}{cpu_info['Total Memory']} bytes {W}\")\r\n\r\n                time.sleep(0.5)\r\n    except KeyboardInterrupt:\r\n        pass\r\n\r\nif __name__ == \"__main__\":\r\n    cpu_memory()\r\n\r\n"
  },
  {
    "path": "currently version.txt",
    "content": "0.971\r\n"
  },
  {
    "path": "darkos",
    "content": "#!/bin/bash\nR=\"$(printf '\\033[1;31m')\"                           \nG=\"$(printf '\\033[1;32m')\"\nY=\"$(printf '\\033[1;33m')\"\nB=\"$(printf '\\033[1;34m')\"\nC=\"$(printf '\\033[1;36m')\"                                       \nW=\"$(printf '\\033[1;37m')\"\nBOLD=\"$(printf '\\033[1m')\"\n\nclear\npython3 $PREFIX/bin/photo.py $@\necho \"${G}${BOLD} PRESS 1 TO ENTER SAFE MODE ....... \"${W}\nread -t 2 -n1 -s key\npkill -9 pulseaudio \nif [[ \"$key\" == \"1\" ]]; then\n    echo \"${G}${BOLD} Safe MODE DARKOS.....STARTING\"${W}\n    termux-x11 :0 &>/dev/null &\n   # pulseaudio --start --load=\"module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\" --exit-idle-time=-1 &>/dev/null\n  \n   if [[ -f \"/system/lib64/libskcodec.so\" ]] ; then\n  LD_PRELOAD=\"/system/lib64/libskcodec.so\" pulseaudio --start --exit-idle-time=-1 &\n  sleep 1\n  pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1 \n\nelse\n   pulseaudio --start --exit-idle-time=-1 &\n   sleep 1\n   pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\nfi\n\n    python3 $PREFIX/bin/darkos.py $@\n    exit 0\nelif [[ \"$key\" == \" \" ]]; then\n    echo \"${G}${BOLD} Booting DARKOS 🖤 \"${W}\nfi\n\nold_version=\"0.971\"\nnew_version=$(curl -s https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/currently%20version.txt)\n\nif ping -q -c 1 -W 1 google.com >/dev/null; then\n    echo \"${G}${BOLD} Welcome 🤗\"${W}\n    if awk 'BEGIN{exit !('$old_version' < '$new_version')}'; then\n        echo \"\"\n        echo \"${G}${BOLD} update available ⏫....to version : ${C}${BOLD}$new_version\"${W}\n        sleep 3\nelse\n        echo \"${G}${BOLD} installed version : ${C}${BOLD}$old_version\"${W}\n        sleep 1\n    fi\nelse\n    echo \"${G}${BOLD} no internet connection 😔🛜\"${W}\nfi\n\nif [[ -v LD_PRELOAD ]]; then\n    unset LD_PRELOAD\nfi\necho \"\"\necho \"${G}${BOLD} Booting DARKOS 🖤\"${W}\n\ntermux-x11 :0 &>/dev/null &\n#pulseaudio --start --load=\"module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\" --exit-idle-time=-1 &>/dev/null\nif [[ -f \"/system/lib64/libskcodec.so\" ]] ; then\n  LD_PRELOAD=\"/system/lib64/libskcodec.so\" pulseaudio --start --exit-idle-time=-1 &\n  sleep 1\n  pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1 \n\nelse\n   pulseaudio --start --exit-idle-time=-1 &\n   sleep 1\n   pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\nfi\n\ncustom_darkos=\"$PREFIX/glibc/opt/darkos/custom_theme.txt\"\n\nif [ -f \"$custom_darkos\" ]; then\n    export DISPLAY=:0\n    startxfce4 &>/dev/null &\n    python3 $PREFIX/glibc/opt/scripts/custom_style.py $@\nelse\n    python3 $PREFIX/bin/run-darkos.py $@\nfi\n"
  },
  {
    "path": "darkos.py",
    "content": "import os\r\nimport re\r\nimport subprocess\r\nimport time\r\nimport threading\r\nimport shutil\r\nimport sys, urllib.request, urllib.error\r\nimport zipfile\r\nimport tarfile\r\nfrom tqdm import tqdm\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\ncurrent_version = \"0.971\"\r\nurl = 'https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/currently%20version.txt'\r\n\r\ndef extract_archive(file_path, extract_to):\r\n    if not os.path.exists(file_path):\r\n        print(f\"{R}File does not exist: {file_path}{W}\")\r\n        return\r\n\r\n    if file_path.endswith('.zip'):\r\n        with zipfile.ZipFile(file_path, 'r') as zip_ref:\r\n            file_size = sum((file.file_size for file in zip_ref.infolist()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in zip_ref.infolist():\r\n                    zip_ref.extract(file, extract_to)\r\n                    pbar.update(file.file_size)\r\n\r\n    elif file_path.endswith('.tar.gz') or file_path.endswith('.tgz') or file_path.endswith('.tar'):\r\n        with tarfile.open(file_path, 'r') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    elif file_path.endswith('.tar.xz') or file_path.endswith('.txz'):\r\n        with tarfile.open(file_path, 'r:xz') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    else:\r\n        print(f\"{R}Unsupported file format{W}\")\r\n        return\r\n\r\n    try:\r\n        os.remove(file_path)\r\n    except Exception as e:\r\n        print(f\"{R}Error deleting archive file: {str(e)}{W}\")\r\n\r\ndef colored_input(prompt):\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} {prompt} {W}\", end=\"\")\r\n    user_input = input()\r\n    return user_input\r\n\r\ndef start_darkos():\r\n    os.system(\"clear\")\r\n    if \"LD_PRELOAD\" in os.environ:\r\n        del os.environ[\"LD_PRELOAD\"]\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Starting {W}\")\r\n    os.system(\"termux-x11 :0 &>/dev/null &\")\r\n    os.system('pulseaudio --start --load=\"module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\" --exit-idle-time=-1 &>/dev/null')\r\ndef wine_container():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Select Wine container: {W}\")\r\n    \r\n    wine_paths = {\r\n        \"1\": \"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\",\r\n        \"2\": \"/data/data/com.termux/files/usr/glibc/opt/wine/2/wine/bin\",\r\n        \"3\": \"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"\r\n    }\r\n    \r\n    for key, path in wine_paths.items():\r\n        if os.path.exists(path):\r\n            if key == \"1\":\r\n                print(f\"{Y}{BOLD} wine 1 {W}\")\r\n            if key == \"2\":\r\n                print(f\"{Y} 2) wine 2 {W}\")\r\n            if key == \"3\":\r\n                print(f\"{Y} 3) wine 3 {W}\")\r\n    \r\n    print(f\"{Y} Else) Back to the main menu 👑 {W}\")\r\n    print(\"\")\r\n    \r\n    prefix_path = colored_input(\"Enter your selection:\")\r\n    \r\n    if prefix_path not in wine_paths.keys():\r\n        print(f\"{R}Incorrect or empty option! {W}\")\r\n        time.sleep(1)\r\n        main_menu()\r\n    else:\r\n        conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/os.conf\"\r\n        wine_prefix = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/.wine\"\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n        os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine\")\r\n        os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine $PREFIX/glibc/bin/wine\")\r\n        if not os.path.exists(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64\"):\r\n            os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine $PREFIX/glibc/bin/wine64\")\r\n            os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64\")\r\n            os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine $PREFIX/glibc/opt/wine/{prefix_path}/wine/bin/wine64\")\r\n        else:\r\n            os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64\")\r\n            os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64 $PREFIX/glibc/bin/wine64\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver $PREFIX/glibc/bin/wineserver\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineboot $PREFIX/glibc/bin/wineboot\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/us/glibc/opt/wine/{prefix_path}/wine/bin/winecfg $PREFIX/glibc/bin/winecfg\")\r\n        #os.system(\"ln -sf /var/lib/dbus/machine-id /etc/machine-id\")\r\n        os.environ.pop('LD_PRELOAD', None)\r\n        ### AZ DARK \r\n        if os.path.exists(conf_path):\r\n            exec(open(conf_path).read())\r\n        if not os.path.exists(wine_prefix):\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} Creating wine prefix 💫 {W}\")\r\n            os.system(f'WINEDLLOVERRIDES=\"mscoree=disabled\" box64 wine64 wineboot &>/dev/null')\r\n            os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n            os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n            os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n            os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n            os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n            print(f\"{G} Installing DXVK+Zink... {W}\")\r\n            os.system(f'box64 wine \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} Done! {W}\")\r\n            #os.system(\"clear\") \r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} prefix done enjoy 🤪 {W}\")\r\n            time.sleep(3)\r\n            os.system(\"box64 wineserver -k &>/dev/null\")\r\n            start_container()\r\n    start_container()\r\ndef recreate_32bit():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} select wine : {W}\")\r\n    \r\n    wine_paths = {\r\n        \"1\": \"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\",\r\n        \"2\": \"/data/data/com.termux/files/usr/glibc/opt/wine/2/wine/bin\",\r\n        \"3\": \"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"\r\n    }\r\n    \r\n    for key, path in wine_paths.items():\r\n        if os.path.exists(path):\r\n            if key == \"1\":\r\n                print(f\"{Y} 1) wine 1 {W}\")\r\n            if key == \"2\":\r\n                print(f\"{Y} 2) wine 2 {W}\")\r\n            if key == \"3\":\r\n                print(f\"{Y} 3) wine 3 {W}\")\r\n    \r\n    print(f\"{Y} Else) Back to the settings menu {W}\")\r\n    print(\"\")\r\n    \r\n    prefix_path = colored_input(\"Enter your selection:\")\r\n    \r\n    if prefix_path not in wine_paths.keys():\r\n        change_setting()\r\n    else:\r\n        conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/os.conf\"\r\n        wine_prefix = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/.wine\"\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n        os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine\")\r\n        os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine $PREFIX/glibc/bin/wine\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64 $PREFIX/glibc/bin/wine64\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver $PREFIX/glibc/bin/wineserver\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineboot $PREFIX/glibc/bin/wineboot\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/us/glibc/opt/wine/{prefix_path}/wine/bin/winecfg $PREFIX/glibc/bin/winecfg\")\r\n        os.environ.pop('LD_PRELOAD', None)\r\n        ### AZ DARK \r\n        exec(open(conf_path).read())\r\n        def prefix_gstreamer():\r\n            os.environ['WINEPREFIX'] = wine_prefix\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} Fixing wine prefix .... {W}\")\r\n            os.system(f'WINEDLLOVERRIDES=\"mscoree=disabled\" box64 wine64 wineboot &>/dev/null')\r\n            os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n            os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n            os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n            os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n            os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n            print(f\"{R}[{W}-{R}]{C}{BOLD} please wait .. {W}\")\r\n            os.system(f'box64 wine \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} done...please restart OS {W}\")\r\n            time.sleep(1)\r\n            os.system(\"box64 wineserver -k &>/dev/null\")\r\n            main_menu()\r\n        if os.path.exists(wine_prefix):\r\n            shutil.rmtree(wine_prefix)\r\n            time.sleep(1)\r\n            prefix_gstreamer()\r\n        if not os.path.exists(wine_prefix):\r\n            prefix_gstreamer()\r\ndef photo():\r\n    os.system(\"python3 $PREFIX/bin/photo.py\")\r\ndef check_network_connection():\r\n    try:\r\n        urllib.request.urlopen(\"http://www.google.com\", timeout=5)\r\n        return True\r\n    except urllib.error.URLError:\r\n        return False\r\ndef main():\r\n    if not check_network_connection():\r\n        print(f\"{R}[{W}-{R}]{R}{BOLD} No network connection available. {W}\")\r\n        return\r\n    try:\r\n        response = urllib.request.urlopen(url)\r\n        latest_version = response.read().decode('utf-8').strip()\r\n        if latest_version < current_version:\r\n            os.system(\"curl -o install https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/installO.sh && chmod +x install && ./install\")\r\n        if latest_version > current_version:\r\n            print(f\"{R}[{W}-{R}]{C}{BOLD} update available....please update DARKOS {W}\")\r\n    except urllib.error.HTTPError as e:\r\n        if e.code == 404:\r\n            print(\"🙅‍♂️🛜\", e)\r\n        else:\r\n            print(f\"{R} something went wrong please send this error to developer {W}\")\r\n\r\ndef mangohud_vulkan():\r\n    os.system(\"apt reinstall vulkan-icd-loader-glibc\")\r\n    print(f\"{R}[{W}-{R}]{Y}{BOLD} working...... please wait {W}\")\r\n    os.system(\"grun -s ldconfig\")\r\ndef winetricks():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} winetricks menu : {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 1) winetricks gui 🖥️ {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 2) winetricks verbs 🧑‍💻 {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} Else) Back to the main menu 👑 {W}\")\r\n    print(\"\")\r\n    choise = input()\r\n    conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/os.conf\"\r\n    if choise != \"1\" and choise != \"2\":\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} backing to main menu {W}\")\r\n        time.sleep(2)\r\n        main_menu()\r\n    elif choise == \"1\":\r\n        exec(open(conf_path).read())\r\n        exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\n        exec(open('/sdcard/darkos/darkos_custom.conf').read())\r\n        os.system(\"clear\")\r\n        photo()\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} loading...... winetrick {W}\")\r\n        print(f\"{R}[{W}-{R}]{Y}{BOLD} winetricks working just wait its take 1 minute to launch menu {W}\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} if you want to close it and back to main menu press control+C {W}\")\r\n        os.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\n        os.system(\"LD_PRELOAD= WINESERVER=$PREFIX/glibc/bin/wineserver WINE=$PREFIX/glibc/bin/wine64 $PREFIX/glibc/bin/box64 $PREFIX/glibc/bin/bash86 $PREFIX/glibc/bin/winetricks &>/dev/null\")\r\n        main_menu()\r\n    elif choise == \"2\":\r\n        exec(open(conf_path).read())\r\n        exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\n        exec(open('/sdcard/darkos/darkos_custom.conf').read())\r\n        os.system(\"clear\")\r\n        photo()\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} winetrick verbs ready to use on chosen container... {W}\")\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} input verbs: {W}\")\r\n        winetrick_verbs = input()\r\n        os.system(f\"LD_PRELOAD= WINESERVER=$PREFIX/glibc/bin/wineserver WINE=$PREFIX/glibc/bin/wine64 $PREFIX/glibc/bin/box64 $PREFIX/glibc/bin/bash86 $PREFIX/glibc/bin/winetricks {winetrick_verbs} \")\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} winetrick packages installed successfully...👍 {W}\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} backing to main menu..... 🔁 {W}\")\r\n        time.sleep(4)\r\n        main_menu()\r\ndef start_container():\r\n    start_darkos()\r\n    exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n    xrandr_output = os.popen('xrandr').read()\r\n    current_resolution_match = re.search(r'current\\s+(\\d+) x (\\d+)', xrandr_output)\r\n\r\n    if current_resolution_match:\r\n        current_resolution = f\"{current_resolution_match.group(1)}x{current_resolution_match.group(2)}\"\r\n    else:\r\n        current_resolution = \"800x600\"\r\n    res = current_resolution\r\n    os.system(\"taskset -c 4-7 box64 wine64 explorer /desktop=shell,\" + res + \" $PREFIX/glibc/opt/apps/run.exe &>/dev/null &\")\r\n    os.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\n    os.system(\"clear\")\r\n    os.system(\"python3 $PREFIX/bin/photo.py\")\r\n    print(f\"{Y}exit 1️⃣ {W}\")\r\n    user_input = colored_input(\"Enter 1 to stop: \")\r\n    if user_input == \"1\":\r\n        os.system(\"box64 wineserver -k\")\r\n        print(f\"{Y} Exiting 👋 {W}\")\r\n        os.system('pkill -f \"app_process / com.termux.x11\"')\r\n        os.system('pkill -f pulseaudio')\r\n        print(f\"{G} see you later {W}\")\r\n        main_menu()\r\n    main_menu()\r\n        \r\ndef uninstall_wine():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Are you sure you want to delete the wine version? {W}\")\r\n    print(\"\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\"):\r\n        print(f\"{Y}1) Delete wine 1 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/2/wine/bin\"):\r\n        print(f\"{Y} 2) Delete wine 2 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"):\r\n        print(f\"{Y} 3) Delete wine 3 {W}\")\r\n    print(f\"{Y} else) main menu ⬅️ {W}\")\r\n    print(\"\")\r\n    choice = input()\r\n    if choice != \"1\" and choice != \"2\" and choice != \"3\":\r\n        print(f\"{R} Incorrect or empty option! {W}\")\r\n        main_menu()\r\n    elif choice == \"1\" and os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"):\r\n        print(f\"{R}[{W}-{R}]{G} Deleting wine 1, please wait... {W}\")\r\n        print(\"\")\r\n        uninstall_wine9()\r\n    elif choice == \"2\" and os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/2/wine/bin\"):\r\n        print(f\"{R}[{W}-{R}]{G} Deleting wine 2, please wait... {W}\")\r\n        print(\"\")\r\n        uninstall_wine8()\r\n    elif choice == \"3\" and os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\"):\r\n        print(f\"{R}[{W}-{R}]{G} Deleting wine 3, please wait... {W}\")\r\n        print(\"\")\r\n        uninstall_wine7()\r\n    main_menu()\r\ndef uninstall_wine9():\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\"):\r\n        os.system(\"rm -r /data/data/com.termux/files/usr/glibc/opt/wine/1/wine\")\r\n        if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine\"):\r\n            shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine')\r\ndef recreate_prefix_wineAZ():\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} select version of wine you want to recreate_prefix: {W}\")\r\n    print(\"\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine\"):\r\n        print(f\"{Y} 1) remove prefix on container 1 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/2/.wine\"):\r\n        print(f\"{Y} 2) remove prefix on container 2 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/.wine\"):\r\n        print(f\"{Y} 3) remove prefix on container 3 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/4/.wine\"):\r\n        print(f\"{Y} 4) remove prefix on container 4 {W}\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/5/.wine\"):\r\n        print(f\"{Y} 5) remove prefix on container 5 {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} else) back to settings menu {W}\")\r\n    print(\"\")\r\n    user_input = input()\r\n    if user_input not in [\"1\", \"2\", \"3\", \"4\", \"5\"]:\r\n        change_setting()\r\n    elif user_input == \"1\":\r\n         shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine')\r\n         print(f\"{G} Done {W}\")\r\n    elif user_input == \"2\":\r\n         shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/2/.wine')\r\n         print(f\"{G} Done {W}\")\r\n    elif user_input == \"3\":\r\n         shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/3/.wine')\r\n         print(f\"{G} Done {W}\")\r\n    elif user_input == \"4\":\r\n         shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/4/.wine')\r\n         print(f\"{G} Done {W}\")\r\n    elif user_input == \"5\":\r\n         shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/5/.wine')\r\n         print(f\"{G} Done {W}\")\r\n    main_menu()\r\ndef xinput_support():\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Select the version of Wine you want to add xinput support for: {W}\")\r\n    print(\"\")\r\n    for i in range(1, 6):\r\n        wine_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{i}/.wine\"\r\n        if os.path.exists(wine_path):\r\n            print(f\"{Y} {i}) Add xinput support on container {i} {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} Else) Back to the settings menu {W}\")\r\n    print(\"\")\r\n    user_input = colored_input(\"Enter your choice: \")\r\n    if user_input not in [\"1\", \"2\", \"3\", \"4\", \"5\"]:\r\n        # Handle invalid input\r\n        change_setting()\r\n    else:\r\n        wine_container = int(user_input)\r\n        wine_lib64_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{wine_container}/wine/lib64\"\r\n        wine_lib_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{wine_container}/wine/lib/wine\"\r\n        if os.path.exists(wine_lib64_path):\r\n            os.system(f\"tar -xJf $PREFIX/glibc/opt/darkos/XinputBridge_ge.tar.xz -C /data/data/com.termux/files/usr/glibc/opt/wine/{wine_container}/wine/ &>/dev/null\")\r\n        else:\r\n            os.system(f\"tar -xJf $PREFIX/glibc/opt/darkos/XinputBridge.tar.xz -C {wine_lib_path} &>/dev/null\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} xinput support added to Wine in container {C}{wine_container} {W}\")\r\n        time.sleep(2)\r\n        change_setting()\r\ndef check_config_wine():\r\n    config_folder = \"/sdcard/darkos\"\r\n    exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\ndef Compile():\r\n    os.system(\"apt install cmake-glibc make-glibc python-glibc\")\r\n    os.system(\"pkg install -y git; unset LD_PRELOAD; export GLIBC_PREFIX=/data/data/com.termux/files/usr/glibc; export PATH=$GLIBC_PREFIX/bin:$PATH; cd ~/; git clone https://github.com/ptitSeb/box64; cd ~/box64; sed -i 's/\\/usr/\\/data\\/data\\/com.termux\\/files\\/usr\\/glibc/g' CMakeLists.txt; sed -i 's/\\/etc/\\/data\\/data\\/com.termux\\/files\\/usr\\/glibc\\/etc/g' CMakeLists.txt; mkdir build; cd build; cmake --install-prefix $PREFIX/glibc .. -DARM_DYNAREC=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBAD_SIGNAL=ON -DSD845=ON; make -j8; make install\")\r\ndef install_wine9():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/wine-default.tar.xz\")\r\n    extract_archive('wine-default.tar.xz','/data/data/com.termux/files/usr/glibc/opt/wine/1/')\r\ndef auto_start():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} select what you refer: {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 1) turn-on auto start os 👍 {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 2) turn-off auto start os 👎 {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} else) back to settings menu {W}\")\r\n    choice = input()\r\n\r\n    if choice != \"1\" and choice != \"2\":\r\n        change_setting()\r\n    elif choice == \"1\":\r\n        command = \"darkos\"\r\n        shell_name = get_shell_name()\r\n        if shell_name:\r\n            activate_auto_start(command, shell_name)\r\n        else:\r\n            print(f\"{R}Unable to determine current shell.{W}\")\r\n    elif choice == \"2\":\r\n        command = \"darkos\"\r\n        shell_name = get_shell_name()\r\n        if shell_name:\r\n            deactivate_auto_start(command, shell_name)\r\n        else:\r\n            print(f\"{R}Unable to determine current shell.{W}\")\r\n\r\ndef get_shell_name():\r\n    shell_path = os.getenv('SHELL')\r\n    if shell_path:\r\n        return os.path.basename(shell_path)\r\n    return None\r\n\r\ndef activate_auto_start(command, shell_name):\r\n    shellrc_files = {\r\n        'bash': '.bashrc',\r\n        'zsh': '.zshrc',\r\n    }\r\n    shellrc_path = os.path.expanduser(f'~/{shellrc_files.get(shell_name, \".bashrc\")}')\r\n    command_exists = False\r\n    if os.path.exists(shellrc_path):\r\n        with open(shellrc_path, 'r') as f:\r\n            for line in f:\r\n                if command in line:\r\n                    command_exists = True\r\n                    print(f\"{G}Auto start os already activated in {C}{shell_name} {G}shell.{W}\")\r\n                    time.sleep(2)\r\n                    change_setting()\r\n    if not command_exists:\r\n        with open(shellrc_path, 'a') as f:\r\n            f.write(command + '\\n')\r\n        print(f\"{G}Auto start os activated successfully in {C}{shell_name} {G}shell.{W}\")\r\n        time.sleep(2)\r\n        change_setting()\r\n\r\ndef deactivate_auto_start(command, shell_name):\r\n    shellrc_files = {\r\n        'bash': '.bashrc',\r\n        'zsh': '.zshrc',\r\n        'fish': 'config.fish'\r\n    }\r\n    shellrc_path = os.path.expanduser(f'~/{shellrc_files.get(shell_name, \".bashrc\")}')\r\n    if os.path.exists(shellrc_path):\r\n        with open(shellrc_path, 'r') as f:\r\n            lines = f.readlines()\r\n        with open(shellrc_path, 'w') as f:\r\n            for line in lines:\r\n                if command not in line:\r\n                    f.write(line)\r\n        print(f\"{G}Auto start os deactivated successfully in {C}{shell_name} {G}shell.{W}\")\r\n        time.sleep(2)\r\n        change_setting()\r\ndef styles():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} are you sure adding style support ? 🏞️ {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 1) YES {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 2) NO {W}\")\r\n    print(\"\")\r\n    choice = input()\r\n    if choice == \"1\":\r\n        os.system(\"chmod +x $PREFIX/glibc/opt/scripts/install_xfce4.sh\")\r\n        os.system(\"bash $PREFIX/glibc/opt/scripts/install_xfce4.sh\")\r\n    elif choice == \"2\":\r\n        change_setting()\r\ndef change_setting():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} SETTINGS ⚙️ {W}\")\r\n    print(f\"{Y} 1) Update OS 👑 {W}\")\r\n    print(f\"{Y} 2) Wine manager 🍷 {W}\")\r\n    print(f\"{Y} 3) Change box86-box64 version 📥 {W}\")\r\n    print(f\"{Y} 4) Delete prefix 🪡 {W}\")\r\n    print(f\"{Y} 5) Change auto start setting 🖱️ {W}\")\r\n    print(f\"{Y} 6) Debug mode 🔧 {W}\")\r\n    print(f\"{Y} 7) Fix prefix for non wow64 wine ♻️ {W}\")\r\n    print(f\"{Y} 8) Boost cpu 🔥 (needed root in some devices) {W}\")\r\n    print(f\"{Y} 9) Add Styles Support For Dark Os 🎭 {W}\")\r\n    print(f\"{Y} 10) winetricks ⛑️ {W}\")\r\n    print(f\"{Y} 11) Add virgl support {W}\")\r\n    print(f\"{Y} else) Back 🔙 {W}\")\r\n    print(\"\")\r\n    choice = input()\r\n    if choice != \"1\" and choice != \"2\" and choice != \"3\" and choice != \"4\" and choice != \"5\" and choice != \"6\" and choice != \"7\" and choice != \"8\" and choice != \"9\" and choice != \"10\" and choice != \"dev\" and choice != \"11\":\r\n        print(f\"{G} ........... {W}\")\r\n        main_menu()\r\n    elif choice == \"3\":\r\n        box_version()\r\n    elif choice == \"11\":\r\n        os.system(\"clear\")\r\n        photo()\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} installing vrigl server please wait {W}\")\r\n        os.system(\"apt install tur-repo\")\r\n        print(\"\")\r\n        time.sleep(2)\r\n        os.system(\"apt install virglrenderer-android virglrenderer-mesa-zink -y\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} vrigl server install successfuly {W}\")  \r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} congratulations virgl now supported {W}\") \r\n        print(\"\")      \r\n        time.sleep(2)\r\n        change_setting()\r\n    elif choice == \"dev\":\r\n        os.system(\"clear\")\r\n        print(f\"{G}{BOLD} share log file on our Telegram group {W}\")\r\n        print(f\"{G} dev mode {W}\")\r\n        os.system(\"BOX86_LOG=1 BOX86_SHOWSEGV=1 BOX86_DYNAREC_LOG=1 BOX86_DYNAREC_MISSING=1 BOX86_DLSYM_ERROR=1 BOX64_LOG=1 BOX64_SHOWSEGV=1 BOX64_DYNAREC_LOG=1 BOX64_DYNAREC_MISSING=1 WINEDEBUG=warn+all BOX64_DLSYM_ERROR=1 WINEDEBUG=+err taskset -c 4-7 box64 wine64 explorer /desktop=shell,800x600 $PREFIX/glibc/opt/apps/pc.ex >/sdcard/darkos.log\")\r\n    elif choice == \"1\":\r\n        print(\"\")\r\n        print(f\"{G} Shutdown OS.... {W}\")\r\n        print(\"\")\r\n        print(f\"{Y} checking 🔎..... {W}\")\r\n        time.sleep(1)\r\n        response = urllib.request.urlopen(url)\r\n        latest_version = response.read().decode('utf-8').strip()\r\n        try:\r\n            if latest_version > current_version:\r\n                print(f\"{R}[{W}-{R}]{C}{BOLD} update available..... updating......📥 {W}\")\r\n                os.system(\"python3 $PREFIX/bin/update-darkos.py\")\r\n                time.sleep(3)\r\n                change_setting()\r\n        except urllib.error.HTTPError as e:\r\n            if e.code == 404:\r\n                os.system(\"clear\")\r\n                print(f\"{R} no internet connection 😵 backing to the settings {W}\")\r\n                time.sleep(3)\r\n                change_setting()\r\n        else:\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} no update available {W}\")\r\n            time.sleep(3)\r\n            change_setting()\r\n    elif choice == \"2\":\r\n        os.system(\"python3 $PREFIX/bin/setting-darkos.py\")\r\n    elif choice == \"6\":\r\n        os.system(\"python3 $PREFIX/bin/debug-darkos.py\")\r\n    elif choice == \"9\":\r\n        print(\"\")\r\n        styles()\r\n    elif choice == \"r\":\r\n        print(f\"{R}[{W}-{R}]{G} to contact developer via telegram channel.... {C}(https://t.me/DARKOS4android) {W}\")\r\n        back = input(\"🔙 = 1\")\r\n        if back == \"1\":\r\n            change_setting()\r\n    elif choice == \"4\":\r\n        recreate_prefix_wineAZ()\r\n    elif choice == \"5\":\r\n        auto_start()\r\n    elif choice == \"7\":\r\n        recreate_32bit()\r\n    elif choice == \"10\":\r\n        winetricks()\r\n    elif choice == \"8\":\r\n        os.system(\"clear\")\r\n        photo()\r\n        pip_fixer_file = \"/data/data/com.termux/files/usr/bin/pip_fixer\"\r\n        boost_launcher_file = \"/data/data/com.termux/files/usr/bin/boost_launcher\"\r\n        if not os.path.exists(pip_fixer_file):\r\n            os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/pip_fixer &>/dev/null\")\r\n            os.system(\"chmod +x pip_fixer\")\r\n            os.system(\"mv pip_fixer $PREFIX/bin/\")\r\n        if not os.path.exists(boost_launcher_file):\r\n            os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/boost_launcher &>/dev/null\")\r\n            os.system(\"chmod +x boost_launcher\")\r\n            os.system(\"mv boost_launcher  $PREFIX/bin/\")\r\n        print(f\"{Y} loading......... {W}\")\r\n        reload()\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} installing python packages {W}\")\r\n        os.system('pkg install python vulkan-tools python-pip coreutils -y &> /dev/null')\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} fixing pip install {W}\")\r\n        os.system('pip_fixer')\r\n        print(\"\")\r\n        os.system('pip install aiofiles psutil blessings &> /dev/null')\r\n        print(f\"{R}[{W}-{R}]{G} python packages.... 100% {W}\")\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} starting boost 💥 {W}\")\r\n        new_sesson()\r\n        time.sleep(3)\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G} check the new session for more info 👀 {W}\")\r\n        time.sleep(5)\r\n        change_setting()\r\ndef box_version():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} select box version: {W}\")\r\n    print(\"\")\r\n    print(f\"{Y} 1) SAFE-BOX {W}\")\r\n    print(f\"{Y} 2) Compile and update BOX64 {W}\")\r\n    print(f\"{Y} 3) BOX86 FOR none-wow64 Wine version {W}\")\r\n    print(f\"{Y} else) CANCEL AND BACK {W}\")\r\n    print(\"\")\r\n    choice = input()\r\n    file_path64 = \"/data/data/com.termux/files/usr/glibc/bin/box64\"\r\n    file_path86 = \"/data/data/com.termux/files/usr/glibc/bin/box86\"\r\n    if choice not in [\"1\", \"2\", \"3\"]:\r\n        change_setting()\r\n    elif choice == \"1\":\r\n        if os.path.exists(file_path64):\r\n            os.remove(file_path64)\r\n        if os.path.exists(file_path86):\r\n            os.remove(file_path86)\r\n        os.system(\"tar -xJf $PREFIX/glibc/opt/box/safe-box.tar.xz -C $PREFIX/glibc/bin/\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box64\") \r\n        change_setting()\r\n    elif choice == \"2\":\r\n        if os.path.exists(file_path64):\r\n            os.remove(file_path64)\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} compiling.... {W}\")\r\n        os.system(\"apt install cmake-glibc make-glibc python-glibc -y &>/dev/null\")\r\n        Compile()\r\n        os.system(\"mv //data/data/com.termux/files/home/box64/build/box64 $PREFIX/glibc/bin/\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n        shutil.rmtree('/data/data/com.termux/files/home/box64')\r\n        print(f\"{G}{BOLD} done {W}\")\r\n        time.sleep(2)\r\n        change_setting()\r\n    elif choice == \"3\":\r\n        os.system(\"wget https://github.com/ahmad1abbadi/darkos/releases/download/beta/box.tar.xz\")\r\n        if os.path.exists(file_path64):\r\n            os.remove(file_path64)\r\n        if os.path.exists(file_path86):\r\n            os.remove(file_path86)\r\n        os.system(\"tar -xJf box.tar.xz -C $PREFIX/glibc/bin/\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n        os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n        change_setting()\r\ndef reload():\r\n    file_path = os.path.expanduser(\"~/.termux/termux.properties\")\r\n    with open(file_path, \"r\") as file:\r\n        lines = file.readlines()\r\n    with open(file_path, \"w\") as file:\r\n        for line in lines:\r\n            if line.startswith(\"# allow-external-apps = true\"):\r\n                line = line.replace(\"# \", \"\")\r\n            file.write(line)\r\n            #print(f\"File updated: {file_path}\")\r\n    os.system(\"termux-reload-settings\")\r\ndef new_sesson():\r\n    os.system(\"am startservice --user 0 -n com.termux/com.termux.app.RunCommandService \\\r\n    -a com.termux.RUN_COMMAND \\\r\n    --es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/bash' \\\r\n    --esa com.termux.RUN_COMMAND_ARGUMENTS '/data/data/com.termux/files/usr/bin/boost_launcher' \\\r\n    --es com.termux.RUN_COMMAND_WORKDIR '/data/data/com.termux/files/home' \\\r\n    --ez com.termux.RUN_COMMAND_BACKGROUND 'false' \\\r\n    --es com.termux.RUN_COMMAND_SESSION_ACTION '1' &> /dev/null \")\r\ndef main_menu():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} welcome to darkos safe mode {W}\")\r\n    print(\"\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Select what you need to do: {W}\")\r\n    print(f\"{Y} 1) START DARK OS IN SAFE MODE 🚑 {W}\")\r\n    print(f\"{Y} 2) SETTINGS ⚙️ {W}\")\r\n    print(f\"{Y} 3) EXIT SAFE MODE 🚪 {W}\")\r\n    print(f\"{Y} 4) KILL DARK OS AND EXIT TO TERMINAL 😭 {W}\")\r\n    print(\"\")\r\n    main()\r\n    choice = input()\r\n    if choice != \"1\" and choice != \"2\" and choice != \"3\" and choice != \"4\":\r\n        print(f\"{R} wrong {W}\")\r\n        main_menu()\r\n    elif choice == \"1\":\r\n        wine_container()\r\n    elif choice == \"2\":\r\n        change_setting()\r\n    elif choice == \"3\":\r\n        print(\"\")\r\n        os.system(\"clear\")\r\n        photo()\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} Restarting..... {W}\")\r\n        time.sleep(1)\r\n        print(\"\")\r\n        subprocess.run([\"bash\", \"darkos\"])\r\n    elif choice == \"4\":\r\n        print(\"\")\r\n        os.system(\"clear\")\r\n        photo()\r\n        print(\"\")\r\n        print(f\"{R}[{W}-{R}]{C}{BOLD} good bye 😭 {W}\")\r\n        os.system('pkill -f \"app_process / com.termux.x11\"')\r\n        os.system('pkill -f pulseaudio')\r\n        os._exit(0)\r\nstart_darkos()\r\nmain_menu()\r\n"
  },
  {
    "path": "debug-darkos.py",
    "content": "import os\r\nimport re\r\nimport subprocess\r\nimport time\r\nimport threading\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\nexec(open('/data/data/com.termux/files/usr/glibc/opt/wine/os.conf').read())\r\nexec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\nexec(open('/sdcard/darkos/darkos_dynarec_box86.conf').read())\r\nexec(open('/sdcard/darkos/darkos_custom.conf').read())\r\nos.environ[\"BOX64_TRACE_FILE\"]=\"/sdcard/darkos/trace/trace-%pid.txt\"\r\nos.system(\"BOX64_LOG=1 BOX64_SHOWSEGV=1 BOX64_DYNAREC_LOG=1 BOX64_DYNAREC_MISSING=1 WINEDEBUG=warn+all BOX64_DLSYM_ERROR=1 WINEDEBUG=+err taskset -c 4-7 box64 wine64 explorer /desktop=shell,800x600 $PREFIX/glibc/opt/apps/DARKOS_configuration.exe >/sdcard/darkos/darkos.log 2>&1 &\")\r\nos.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\nos.system(\"clear\")\r\nos.system(\"python3 $PREFIX/bin/photo.py\")\r\n\r\ndef colored_input(prompt):\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} {prompt} {W}\", end=\"\")\r\n    user_input = input()\r\n    return user_input\r\n\r\ndef recreate_prefix():\r\n    os.system(\"clear\")\r\n    os.system(\"python3 $PREFIX/bin/photo.py\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} select wine to recreate: {W}\")\r\n    \r\n    wine_paths = {\r\n        \"1\": \"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\",\r\n        \"2\": \"/data/data/com.termux/files/usr/glibc/opt/wine/2/wine/bin\",\r\n        \"3\": \"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"\r\n    }\r\n    \r\n    for key, path in wine_paths.items():\r\n        if os.path.exists(path):\r\n            if key == \"1\":\r\n                print(f\"{Y} 1) wine 1 {W}\")\r\n            if key == \"2\":\r\n                print(f\"{Y} 2) wine 2 {W}\")\r\n            if key == \"3\":\r\n                print(f\"{Y} 3) wine 3 {W}\")\r\n    \r\n    print(f\"{Y} Else) Back to the settings menu {W}\")\r\n    print(\"\")\r\n    \r\n    prefix_path = colored_input(\"Enter your selection:\")\r\n    \r\n    if prefix_path not in wine_paths.keys():\r\n      print(f\"{R} no prefix found backing to debug menu {W}\")\r\n      time.sleep(1)\r\n      reboot()\r\n    else:\r\n      conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/os.conf\"\r\n      wine_prefix = f\"/data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/.wine\"\r\n      os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n      os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n      os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine\")\r\n      os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64\")\r\n      os.system(f\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver\")\r\n      os.system(\"patchelf --force-rpath --set-rpath $PREFIX/glibc/lib --set-interpreter $PREFIX/glibc/lib/ld-linux-aarch64.so.1 $PREFIX/glibc/bin/box64\")\r\n      os.system(\"patchelf --force-rpath --set-rpath $PREFIX/glibc/lib32 --set-interpreter $PREFIX/glibc/lib32/ld-linux-armhf.so.3 $PREFIX/glibc/bin/box86\")\r\n      os.system(\"rm -rf $PREFIX/glibc/bin/wine $PREFIX/glibc/bin/wine64 $PREFIX/glibc/bin/wineserver\")\r\n      os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine $PREFIX/glibc/bin/wine\")\r\n      os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wine64 $PREFIX/glibc/bin/wine64\")\r\n      os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineserver $PREFIX/glibc/bin/wineserver\")\r\n      os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{prefix_path}/wine/bin/wineboot $PREFIX/glibc/bin/wineboot\")\r\n      os.system(f\"ln -sf /data/data/com.termux/files/us/glibc/opt/wine/{prefix_path}/wine/bin/winecfg $PREFIX/glibc/bin/winecfg\")\r\n      os.environ.pop('LD_PRELOAD', None)\r\n      def prefix_gstreamer():\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} Creating wine prefix 💫 {W}\")\r\n        os.environ.pop('BOX86_DYNAREC_BIGBLOCK', None)\r\n        os.environ.pop('BOX64_DYNAREC_BIGBLOCK', None)\r\n        os.environ.pop('WINEESYNC', None)\r\n        os.environ.pop('WINEESYNC_TERMUX', None)\r\n        os.environ.pop('BOX86_DYNAREC_CALLRET', None)\r\n        os.environ.pop('BOX64_DYNAREC_CALLRET', None)\r\n        os.system(f'WINEDLLOVERRIDES=\"mscoree=disabled,winegstreamer=disable\" box64 wine64 wineboot &>/dev/null')\r\n        os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n        os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n        os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n        os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n        os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} Installing DXVK+Zink... {W}\")\r\n        os.system(f'box64 wine \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n        print(f\"{G} Done! {W}\") \r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} prefix done enjoy 🤪 {W}\")\r\n        time.sleep(1)\r\n        os.system(\"box64 wineserver -k &>/dev/null\")\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} os will start on debug mode see log file if there any issues {W}\")\r\n        time.sleep(2)\r\n        os.system(\"BOX86_LOG=2 BOX86_SHOWSEGV=1 BOX86_DYNAREC_LOG=1 BOX86_DYNAREC_MISSING=1 BOX86_DLSYM_ERROR=1 BOX64_LOG=3 BOX64_SHOWSEGV=1 BOX64_DYNAREC_LOG=1 BOX64_DYNAREC_MISSING=1 BOX64_DLSYM_ERROR=1 taskset -c 4-7 box64 wine explorer /desktop=shell,800x600 $PREFIX/glibc/opt/apps/pc.ex >/sdcard/darkos.log 2>&1 &\")\r\n        os.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\n        os.system(\"clear\")\r\n        os.system(\"python3 $PREFIX/bin/photo.py\")\r\n        print(f\"{Y} exit 1️⃣ {W}\")\r\n        user_input = colored_input(\"Enter 1 to stop: \")\r\n        if user_input == \"1\":\r\n          os.system(\"box64 wineserver -k\")\r\n          print(f\"{G} Exiting 👋 {w}\")\r\n          os.system('pkill -f \"app_process / com.termux.x11\"')\r\n          os.system('pkill -f pulseaudio')\r\n          reboot()\r\n        if os.path.exists(wine_prefix):\r\n          shutil.rmtree(wine_prefix)\r\n          time.sleep(1)\r\n          prefix_gstreamer()\r\n      if not os.path.exists(wine_prefix):\r\n        prefix_gstreamer()\r\ndef reboot():\r\n  os.system(\"clear\")\r\n  os.system(\"python3 $PREFIX/bin/photo.py\")\r\n  print(f\"{R}[{W}-{R}]{G}{BOLD} you are in debug mode... choose what you need to do : {W}\")\r\n  print(f\"{R}[{W}-{R}]{C}{BOLD} note :- this option available just in safe mode. {W}\")\r\n  print(\"\")\r\n  print(f\"{Y} 1) reboot debug in 32bit mode using box64 and box68 {W}\")\r\n  print(f\"{Y} 2) recreate prefix {W}\")\r\n  print(f\"{Y} 3) restart os {W}\")\r\n  print(f\"{Y} 4) kill all proceeds and exit {W}\")\r\n  choice = input()\r\n  if choice != \"1\" and choice != \"2\" and choice != \"3\" and choice != \"4\":\r\n    reboot()\r\n  elif choice == \"1\":\r\n    exec(open('/data/data/com.termux/files/usr/glibc/opt/wine/os.conf').read())\r\n    exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\n    exec(open('/sdcard/darkos/darkos_custom.conf').read())\r\n    os.system(\"BOX64_LOG=1 BOX64_SHOWSEGV=1 BOX64_DYNAREC_LOG=1 BOX64_DYNAREC_MISSING=1 WINEDEBUG=warn+all BOX64_DLSYM_ERROR=1 WINEDEBUG=+err taskset -c 4-7 box64 wine explorer /desktop=shell,800x600 $PREFIX/glibc/opt/apps/DARKOS_configuration.exe >/sdcard/darkos/darkos.log 2>&1 &\")\r\n    os.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\n    reboot()\r\n  elif choice == \"2\":\r\n    recreate_prefix()\r\n  elif choice == \"3\":\r\n      print(\"\")\r\n      os.system(\"box64 wineserver -k &>/dev/null\")\r\n      print(f\"{R}[{W}-{R}]{G}{BOLD} Rebooting......... {W}\")\r\n      os.system('pkill -f \"app_process / com.termux.x11\"')\r\n      os.system('pkill -f pulseaudio')\r\n      time.sleep(1)\r\n      subprocess.run([\"bash\", \"darkos\"])\r\n  elif choice == \"4\":\r\n      os.system(\"box64 wineserver -k\")\r\n      os.system('pkill -f \"app_process / com.termux.x11\"')\r\n      os.system('pkill -f pulseaudio')\r\n      print(f\"{R}[{W}-{R}]{C}{BOLD} shutdown........ {W}\")\r\n      time.sleep(1)\r\n      os.system(\"am startservice -a com.termux.service_stop com.termux/.app.TermuxService\")\r\nreboot()        \r\n      \r\n    \r\n"
  },
  {
    "path": "installO.sh",
    "content": "#!/bin/bash\r\necho 123\r\n"
  },
  {
    "path": "installOS.sh",
    "content": "#!/data/data/com.termux/files/usr/bin/bash\nR=\"$(printf '\\033[1;31m')\"                           \nG=\"$(printf '\\033[1;32m')\"\nY=\"$(printf '\\033[1;33m')\"\nB=\"$(printf '\\033[1;34m')\"\nC=\"$(printf '\\033[1;36m')\"                                       \nW=\"$(printf '\\033[1;37m')\"\nBOLD=\"$(printf '\\033[1m')\"\n\npackage_install_and_check() {\n\tpacks_list=($@)\n\tfor package_name in \"${packs_list[@]}\"; do\n    echo \"${R}[${W}-${R}]${G}${BOLD} Installing package: ${C}$package_name \"${W}\n    pkg install \"$package_name\" -y &>/dev/null\n\tif [ $? -ne 0 ]; then\n    apt --fix-broken install -y\n\tdpkg --Configuring -a\n    fi\n\tif dpkg -s \"$package_name\" >/dev/null 2>&1; then\n    echo \"${R}[${W}-${R}]${G} $package_name installed successfully \"${W}\n\telse\n\tif\n    type -p \"$package_name\" &>/dev/null || [ -e \"$PREFIX/bin/$package_name\"* ] || [ -e \"$PREFIX/bin/\"*\"$package_name\" ]; then\n        echo \"${R}[${W}-${R}]${C} $package_name ${G}installed successfully \"${W}\n\tfi\n    fi\ndone\n\n}\n\npip_install_and_check() {\n    pip_list=($@)\n    for pip_name in \"${pip_list[@]}\"; do\n        echo -e \"${R}[${W}-${R}]${G}${BOLD} Installing module: ${C}$pip_name ${W}\"\n        pip install \"$pip_name\" &>/dev/null\n\n        # Check if the installation was successful\n        if [ $? -ne 0 ]; then\n            echo -e \"${R}[${W}-${R}]${R}${BOLD} Error installing: ${C}$pip_name ${W}\"\n        else\n            if python3 -c \"import $pip_name\" &>/dev/null; then\n                echo -e \"${R}[${W}-${R}]${G} $pip_name installed successfully ${W}\"\n            else\n                echo -e \"${R}[${W}-${R}]${R}${BOLD} $pip_name installation failed ${W}\"\n            fi\n\tfi\n    done\n}\n\nclear\necho -e \"${G}${BOLD}Updating termux packages list please wait\\n\"${W}\napt update &>/dev/null\nyes 2>/dev/null | apt-get --only-upgrade install termux-tools &>/dev/null\nunlink \"$PREFIX/etc/termux/chosen_mirrors\" &>/dev/null\nln -s \"$PREFIX/etc/termux/mirrors/all\" \"$PREFIX/etc/termux/chosen_mirrors\" &>/dev/null\necho -e \"${G}${BOLD}Selecting best termux packages mirror please wait\\n\"${W}\nTERMUX_APP_PACKAGE_MANAGER=apt pkg --check-mirror update\nclear\necho -e \"${G}${BOLD}Upgrading termux packages...this might take some time\\n\"${W}\nyes 2>/dev/null | apt-get full-upgrade &>/dev/null\necho -e \"${C}${BOLD}please allow storage permission\"${W}\nwhile true; do\n\ttermux-setup-storage\n\tsleep 4\n    if [[ -d ~/storage ]]; then\n        break\n    else\n        echo -e \"${R}${BOLD}Storage permission denied\\n\"${W}\n    fi\n    sleep 2\ndone\necho -e \"${G}${BOLD}be patient\\n\"${W}\npackage_install_and_check \"python3 python-pip\"\npip_install_and_check \"tqdm\"\ncurl -o installglibc.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/installglibc.py && python3 installglibc.py\nexit"
  },
  {
    "path": "installglibc.py",
    "content": "import os, shutil, time\r\nimport subprocess\r\nimport zipfile\r\nimport tarfile\r\nfrom tqdm import tqdm\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\ndef extract_archive(file_path, extract_to):\r\n    if not os.path.exists(file_path):\r\n        print(f\"{R}File does not exist: {file_path}{W}\")\r\n        return\r\n\r\n    if file_path.endswith('.zip'):\r\n        with zipfile.ZipFile(file_path, 'r') as zip_ref:\r\n            file_size = sum((file.file_size for file in zip_ref.infolist()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in zip_ref.infolist():\r\n                    zip_ref.extract(file, extract_to)\r\n                    pbar.update(file.file_size)\r\n\r\n    elif file_path.endswith('.tar.gz') or file_path.endswith('.tgz') or file_path.endswith('.tar'):\r\n        with tarfile.open(file_path, 'r') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    elif file_path.endswith('.tar.xz') or file_path.endswith('.txz'):\r\n        with tarfile.open(file_path, 'r:xz') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    else:\r\n        print(f\"{R}Unsupported file format{W}\")\r\n        return\r\n\r\n    try:\r\n        os.remove(file_path)\r\n    except Exception as e:\r\n        print(f\"{R}Error deleting archive file: {str(e)}{W}\")\r\n\r\ndef package_install_and_check(*packs_list):\r\n    for package_name in packs_list:\r\n        print(f\"{R}[{W}-{R}]{G}{BOLD} Installing package: {C}{package_name} {W}\")\r\n        result = subprocess.run([\"pkg\", \"install\", package_name, \"-y\"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\r\n        if result.returncode != 0:\r\n            subprocess.run([\"apt\", \"--fix-broken\", \"install\", \"-y\", \"--no-install-recommends\"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\r\n            subprocess.run([\"dpkg\", \"--configure\", \"-a\"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\r\n        \r\n        if subprocess.run([\"dpkg\", \"-s\", package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode == 0:\r\n            print(f\"{R}[{W}-{R}]{G}{BOLD} {package_name} installed successfully {W}\")\r\n        else:\r\n            which_output = shutil.which(package_name)\r\n            if which_output:\r\n                print(f\"{R}[{W}-{R}]{G} {package_name} installed successfully {W}\")\r\n            else:\r\n                print(f\"{R}[{W}-{R}]{G} {package_name} installation failed {W}\")\r\n                \r\ndef check_and_backup(file_paths):\r\n\r\n    home_dir = os.path.expanduser(\"~\")\r\n    full_path = os.path.join(home_dir, file_paths)\r\n\r\n    if os.path.exists(full_path):\r\n        backup_path = f\"{full_path}.bak\"\r\n        os.rename(full_path, backup_path)\r\n\r\ndef start_darkos():\r\n    os.system(\"clear\")\r\n    if \"LD_PRELOAD\" in os.environ:\r\n        del os.environ[\"LD_PRELOAD\"]\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Starting {W}\")\r\n    os.system(\"termux-x11 :0 &>/dev/null &\")\r\n    os.system('pulseaudio --start --load=\"module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1\" --exit-idle-time=-1 &>/dev/null')\r\n    \r\ndef termux_pkg():\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} This takes a few minutes it depends on your internet connection {W}\")\r\n    package_install_and_check(\"glibc-repo\", \"x11-repo\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} glibc-repo + x11-repo installed {W}\")\r\n    package_install_and_check(\"pulseaudio\", \"patchelf\", \"xkeyboard-config\", \"freetype\", \"fontconfig\", \"termux-x11-nightly\", \"termux-am\", \"zenity\", \"which\", \"alsa-lib-glibc\", \"bash\", \"curl\", \"sed\", \"cabextract\")\r\n    package_install_and_check(\"wget\", \"make\", \"libpng\", \"xorg-xrandr\", \"cmake\", \"unzip\", \"p7zip\", \"patchelf\", \"tur-repo\", \"tur-repo\", \"traceroute\", \"samba\", \"virglrenderer-android\", \"virglrenderer-mesa-zink\", \"zenity\")\r\n    print(\"\")\r\ndef install_glibc_AZ():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/glibc-darkos.tar.xz\")\r\n    os.system(\"tar -xJf glibc-darkos.tar.xz -C $PREFIX/\")\r\ndef update():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/update.tar.xz\")\r\n    extract_archive('update.tar.xz','/data/data/com.termux/files/home/')\r\ndef alsa():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/alsa.tar.xz\")\r\n    extract_archive('alsa.tar.xz','/data/data/com.termux/files/')\r\n\r\ndef mangohud():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/mangohud.tar.xz\")\r\n    os.system(\"tar -xJvf mangohud.tar.xz -C $PREFIX/glibc &>/dev/null\")\r\n    os.remove(\"mangohud.tar.xz\")\r\ndef install_AZ():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/AZ.tar.xz\")\r\n    extract_archive('AZ.tar.xz','/data/data/com.termux/files/usr/glibc/')\r\ndef install_box():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/box.tar.xz\")\r\n    extract_archive('box.tar.xz','/data/data/com.termux/files/usr/glibc/bin')\r\ndef install_conf():\r\n    folder_path = \"/sdcard/darkos\"\r\n    if os.path.exists(folder_path):\r\n        shutil.rmtree(folder_path)\r\n    os.mkdir(folder_path)\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/darkos.tar.xz\")\r\n    extract_archive('darkos.tar.xz','/sdcard/')\r\n\r\ndef edit_bashrc():\r\n    command = \"darkos\"\r\n    shell_rc_path = None\r\n    current_shell = os.environ.get('SHELL', '').split('/')[-1]\r\n    shell_config_files = {\r\n        'bash': '.bashrc',\r\n        'zsh': '.zshrc',\r\n    }\r\n    \r\n    if current_shell in shell_config_files:\r\n        shell_rc_path = os.path.expanduser(f'~/{shell_config_files[current_shell]}')\r\n\r\n    if shell_rc_path:\r\n        command_exists = False\r\n        if os.path.exists(shell_rc_path):\r\n            with open(shell_rc_path, 'r') as f:\r\n                for line in f:\r\n                    if command in line:\r\n                        command_exists = True\r\n                        print(f\"Command '{command}' already exists in {current_shell} config file.\")\r\n                        print(\"Welcome back again ☺️\")\r\n                        break\r\n        if not command_exists:\r\n            with open(shell_rc_path, 'a') as f:\r\n                f.write(command + '\\n')\r\n            #print(f\"Command '{command}' added to {current_shell} config file.\")\r\n    else:\r\n        print(\"Current shell is not supported or cannot be determined.\")\r\ndef create_prefix():\r\n    conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/1/os.conf\"\r\n    wine_prefix = f\"/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine\"\r\n    os.system(\"ln -s $PREFIX/glibc/opt/wine/1/wine/bin/wine $PREFIX/glibc/bin/wine &>/dev/null\")\r\n    os.system(\"ln -s $PREFIX/glibc/opt/wine/1/wine/bin/wine64 $PREFIX/glibc/bin/wine64 &>/dev/null\")\r\n    os.system(\"ln -s $PREFIX/glibc/opt/wine/1/wine/bin/wineserver $PREFIX/glibc/bin/wineserver &>/dev/null\")\r\n    os.system(\"ln -s $PREFIX/glibc/opt/wine/1/wine/bin/wineboot $PREFIX/glibc/bin/wineboot &>/dev/null\")\r\n    os.system(\"ln -s $PREFIX/glibc/opt/wine/1/wine/bin/winecfg $PREFIX/glibc/bin/winecfg &>/dev/null\")\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\n    os.system(\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin/wine\")\r\n    os.system(\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin/wine64\")\r\n    os.system(\"chmod +x /data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin/wineserver\")\r\n    exec(open(conf_path).read())\r\n    os.environ.pop('LD_PRELOAD', None)\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Creating wine prefix 💫 {W}\")\r\n    os.system(f\"tar -xJf $PREFIX/glibc/opt/darkos/XinputBridge.tar.xz -C /data/data/com.termux/files/usr/glibc/opt/wine/1/wine/lib/wine/ &>/dev/null\")\r\n    os.system(f'WINEUSERNAME=\"DARKOS\" WINEDLLOVERRIDES=\"mscoree=disabled\" box64 wine64 wineboot &>/dev/null')\r\n    os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n    os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n    os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n    os.system(f'ln -s /data/data/com.termux/files/usr/glibc/opt/G_drive \"{wine_prefix}/dosdevices/g:\" &>/dev/null')\r\n    os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n    os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Installing OS stuff... {W}\")\r\n    os.system(f'box64 wine \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Done! {W}\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} prefix done enjoy 🤪 {W}\")\r\n    time.sleep(3)\r\n    os.system(\"box64 wineserver -k &>/dev/null\")\r\n    print(f'{R}[{W}-{R}]{G}{BOLD} done {W}')\r\n    print(\"\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Starting DARK OS {W}\")\r\n    time.sleep(2)\r\n    os.system(\"python3 $PREFIX/bin/run-darkos.py\")\r\ndef install_mono():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/mono.tar.xz\")\r\n    extract_archive('mono.tar.xz','/data/data/com.termux/files/home/')\r\ndef install_wine9():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/wine-default.tar.xz\")\r\n    extract_archive('wine-default.tar.xz','/data/data/com.termux/files/usr/glibc/opt/wine/1/')\r\n    os.system(\"apt reinstall vulkan-icd-loader-glibc -y &>/dev/null\")\r\ndef scripts():\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/update-darkos.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/debug-darkos.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/setting-darkos.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/photo.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/run-darkos.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/cpu_boost.py &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/boost_launcher &>/dev/null\")\r\n    os.system(\"wget https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/pip_fixer &>/dev/null\")\r\n    os.system(\"chmod +x darkos\")\r\n    os.system(\"chmod +x winetricks\")\r\n    os.system(\"chmod +x boost_launcher\")\r\n    os.system(\"chmod +x pip_fixer\")\r\n    os.system(\"chmod +x $PREFIX/glibc/opt/scripts/termux-x11.sh\")\r\n    os.system(\"mv darkos update-darkos.py darkos.py winetricks setting-darkos.py debug-darkos.py run-darkos.py cpu_boost.py photo.py boost_launcher pip_fixer $PREFIX/bin/\")\r\n    check_and_backup(\".termux/colors.properties\")\r\n    os.system(\"wget -O $HOME/.termux/colors.properties https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/terminal_utility/colors.properties &>/dev/null\")\r\n    check_and_backup(os.getenv(\"PREFIX\") + \"/etc/motd-playstore\")\r\n    check_and_backup(os.getenv(\"PREFIX\") + \"/ect/motd\")\r\n    os.system(\"wget -O $PREFIX/etc/darkos-motd.sh https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/terminal_utility/darkos-motd.sh &>/dev/null\")\r\n    os.system(f'echo \"bash {os.getenv(\"PREFIX\")}/etc/darkos-motd.sh\" >> {os.getenv(\"PREFIX\")}/etc/termux-login.sh')\r\n    check_and_backup(\".termux/font.ttf\")\r\n    os.system(\"wget -O $HOME/.termux/font.ttf https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/terminal_utility/ubuntu-mono.ttf &>/dev/null\")\r\ndef remove():\r\n    os.system(\"rm glibc-darkos.tar.xz install installglibc.py\")\r\n    os.system(\"clear\")\r\nos.system(\"clear\")\r\nprint(f\"{R}[{W}-{R}]{G}{BOLD} DarkOS installation is begining 😉 {W}\")\r\nprint(\"\")\r\nedit_bashrc()\r\nprint(\"\")\r\nprint(f\"{R}[{W}-{R}]{G}{BOLD} please wait ....... {W}\")\r\ntermux_pkg()\r\nprint(\" 👣\")\r\ninstall_glibc_AZ()\r\nprint(\" 👣 👣 \")\r\nmangohud()\r\nprint(\" 👣 👣 👣\")\r\ninstall_conf()\r\nprint(\" 👣 👣 👣 👣\")\r\ninstall_AZ()\r\nprint(\" 👣 👣 👣 👣 👣\")\r\ninstall_mono()\r\nprint(\" 👣 👣 👣 👣 👣 👣\")\r\ninstall_wine9()\r\nprint(\" 👣 👣 👣 👣 👣 👣 👣\")\r\ninstall_box()\r\nprint(\" 👣 👣 👣 👣 👣 👣 👣 👣\")\r\nupdate()\r\nprint(\" 👣 👣 👣 👣 👣 👣 👣 👣 👣 \")\r\nalsa()\r\nprint(\" 👣 👣 👣 👣 👣 👣 👣 👣 👣 👣\")\r\nscripts()\r\nprint(\" 👣 👣 👣 👣 👣 👣 👣 👣 👣 👣👣\")\r\nremove()\r\nprint(f\"{R}[{W}-{R}]{G}{BOLD}   Installation finished successfully {W}\")\r\nprint(\"\")\r\nstart_darkos()\r\ncreate_prefix()\r\n"
  },
  {
    "path": "logo",
    "content": "#!/bin/bash\n\nvlc --fullscreen --x11-display=:0.0 --quiet --play-and-exit $PREFIX/glibc/opt/darkos/logo.mp4 && exit\n"
  },
  {
    "path": "new-update.py",
    "content": "import os, time, shutil, sys, subprocess, urllib.request, urllib.error, fnmatch\n\nR = \"\\033[1;31m\"\nG = \"\\033[1;32m\"\nY = \"\\033[1;33m\"\nB = \"\\033[1;34m\"\nC = \"\\033[1;36m\"\nW = \"\\033[1;37m\"\nBOLD = \"\\033[1m\"\n\nfile_path = \"/data/data/com.termux/files/usr/glibc/opt/box/V2.8( 5 june).tar.xz\"\nfile_path2 = \"/data/data/com.termux/files/usr/glibc/opt/box/V2.8( 3 july).tar.xz\"\nfile_path3 = \"/data/data/com.termux/files/usr/glibc/opt/box/V2.7( 3 mar).tar.xz\"\nfile_path4 = \"/data/data/com.termux/files/usr/glibc/opt/box/V2.7( 14 feb).tar.xz\"\ndef update_remove():\n  if os.path.exists(file_path):\n          os.remove(file_path)\n  if os.path.exists(file_path2):\n          os.remove(file_path2)\n  if os.path.exists(file_path3):\n          os.remove(file_path3)\n  if os.path.exists(file_path4):\n          os.remove(file_path4)\ndef pg():\n  os.system(\"apt install traceroute samba -y\")\ndef mangohud():\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/mangohud.tar.xz\")\n    os.system(\"tar -xJvf mangohud.tar.xz -C $PREFIX/glibc &>/dev/null\")\n    os.remove(\"mangohud.tar.xz\")\ndef update():\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/update.tar.xz\")\n    os.system(\"tar -xJf update.tar.xz\")\n    os.remove(\"update.tar.xz\")    \ndef update_files():\n  os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/files.tar.xz\")\n  os.system(\"tar -xJf files.tar.xz -C /data/data/com.termux/files/\")\n  os.remove(\"files.tar.xz\")\n    \ncurrent_version = \"0.971\"\nupdate_remove()\nupdate_files()\npg()\nprint(current_version)\nprint(f\"{Y}update complete\")\ntime.sleep(2)\nexit()\n"
  },
  {
    "path": "photo.py",
    "content": "print(\"\\033[36m\")\r\nprint(\"\"\"\r\n  .+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+. \r\n (     (              (         )    )   (         )\r\n  )    )\\ )    (      )\\ )   ( /( ( /(   )\\ )     ( \r\n (    (()/(    )\\    (()/(   )\\()))\\()) (()/(      )\r\n  )    /(_))((((_)(   /(_))|((_)\\((_)\\   /(_))    ( \r\n (    (_))_  )\\ _ )\\ (_))  |_ ((_) ((_) (_))       )\r\n  )    |   \\ (_)_\\(_)| _ \\ | |/ / / _ \\ / __|     ( \r\n (     | |) | / _ \\  |   /   ' < | (_) |\\__ \\      )\r\n  )    |___/ /_/ \\_\\ |_|_\\  _|\\_\\ \\___/ |___/     ( \r\n (                                                 )\r\n  \"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\"+.+\" \r\n\"\"\")\r\nprint(\"\\033[0m\")"
  },
  {
    "path": "pip_fixer",
    "content": "#!/bin/bash\n\n_file=\"$(find $PREFIX/lib/python3.11 -name \"_sysconfigdata*.py\")\"\nrm -rf $PREFIX/lib/python3.11/_pycache_\ncp $_file \"$_file\".backup\nsed -i 's|-fno-openmp-implicit-rpath||g' \"$_file\""
  },
  {
    "path": "run-darkos.py",
    "content": "import os\r\nimport re\r\nimport subprocess\r\nimport time\r\nimport threading\r\nimport shutil\r\nimport sys, urllib.request, urllib.error\r\n\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\ndef extract_and_delete_tar_files():\r\n    search_paths = [\r\n        \"/data/data/com.termux/files/usr/glibc/opt/temp/box\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/wine/5\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/wine/4\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/wine/2\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/wine/3\"\r\n    ]\r\n    for path in search_paths:\r\n        for filename in os.listdir(path):\r\n            if filename.endswith(\".tar\"):\r\n                tar_file = os.path.join(path, filename)\r\n                if os.path.exists(os.path.join(path, \".wine\")):\r\n                    shutil.rmtree(os.path.join(path, \".wine\"))\r\n                if os.path.exists(os.path.join(path, \"wine\")):\r\n                    shutil.rmtree(os.path.join(path, \"wine\"))\r\n                subprocess.run([\"tar\", \"-xf\", tar_file, \"-C\", path])\r\n                os.remove(tar_file)\r\n                if os.path.exists(os.path.join(path, \"box64\")):\r\n                    destination_path = \"/data/data/com.termux/files/usr/glibc/bin/box64\"\r\n                    if os.path.exists(destination_path):\r\n                        os.remove(destination_path)\r\n                    shutil.move(os.path.join(path, \"box64\"), destination_path)\r\n                    time.sleep(1)\r\ndef load_conf():\r\n    conf_paths = [\r\n        \"/data/data/com.termux/files/usr/glibc/opt/wine/os.conf\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/darkos/res.conf\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/darkos/language.conf\",\r\n        \"/sdcard/darkos/darkos_dynarec.conf\",\r\n        \"/sdcard/darkos/darkos_dynarec_box86.conf\",\r\n        \"/sdcard/darkos/darkos_custom.conf\",\r\n        \"/data/data/com.termux/files/usr/glibc/opt/scripts/hud-settings.conf\"\r\n    ]\r\n    for conf_path in conf_paths:\r\n        exec(open(conf_path).read(), globals())\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box86\")\r\n    os.system(\"chmod +x $PREFIX/glibc/bin/box64\")\r\ndef create_wine_prefix():\r\n    if not os.path.exists(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{container}/wine/bin/wine64\"):\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{container}/wine/bin/wine $PREFIX/glibc/bin/wine64\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/{container}/wine/bin/wine $PREFIX/glibc/opt/wine/{container}/wine/bin/wine64\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Creating wine prefix 💫 {W}\")\r\n    os.system(f'WINEDLLOVERRIDES=\"mscoree=disabled\" taskset -c 4-7 box64 wine64 wineboot -u &>/dev/null')\r\n    os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n    os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n    os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n    os.system(f'ln -s /data/data/com.termux/files/usr/glibc/opt/G_drive \"{wine_prefix}/dosdevices/g:\" &>/dev/null')\r\n    os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n    os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Installing OS stuff... {W}\")\r\n    os.system(f'box64 wine64 \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n    if os.path.exists(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{container}/add-ons.bat\"):\r\n        os.system(f'box64 wine64 \"$PREFIX/glibc/opt/wine/{container}/wine/add-ons.bat\" &>/dev/null')\r\n        print(\"add-ons installed\")\r\n        os.remove(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{container}/add-ons.bat\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Done! {W}\")\r\n    print(f\"{G}{BOLD} prefix done enjoy 🤪 {W}\")\r\n    time.sleep(1)\r\n    os.system(\"box64 wineserver -k &>/dev/null\")\r\n    print(f\"{G}{BOLD} rebooting..... {W}\")\r\n    time.sleep(1)\r\n    subprocess.run([\"bash\", \"darkos\"])\r\n    exit()\r\ndef start_wine():\r\n    os.system(\"$PREFIX/glibc/opt/scripts/termux-x11.sh displayResolutionMode:custom &>/dev/null &\")\r\n    os.system(f\"$PREFIX/glibc/opt/scripts/termux-x11.sh displayResolutionCustom:{res} &>/dev/null &\")\r\n    os.system(\"box64 wine64 explorer /desktop=shell,\" + res + \" $PREFIX/glibc/opt/apps/DARKOS_configuration.exe &>/dev/null &\")\r\n    os.system(\"am start -n com.termux.x11/com.termux.x11.MainActivity &>/dev/null\")\r\n    os.system(\"clear\")\r\n    os.system(\"python3 $PREFIX/bin/photo.py\")\r\n    print(\"\")\r\n    print(f\" {R}{BOLD}D{G}{BOLD}A{Y}{BOLD}R{B}{W}{BOLD}K{R}{BOLD} O{C}{BOLD}S{G}{BOLD} is running...... {W}\")\r\n    print(\"\")\r\n    print(f\"{G}{BOLD} Please choose an option: \")\r\n    print(\"\")\r\n    print(f\"{G}{BOLD} (1) for {C}SHUTDOWN{W}\")\r\n    print(\"\")\r\n    print(f\"{G}{BOLD} (2) for exit to the {C}terminal{W}\")\r\n    print(\"\")\r\n    print(f\"{G}{BOLD} Simply press any other key to {C}REBOOT{W}\")\r\n    print(\"\")\r\ndef restart_wine():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.reboot\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1) \r\n        os.system(\"box64 wineserver -k &>/dev/null\")\r\n        print(f\"{G}{BOLD} Restarting WINE {W}\")\r\n        os.system(\"pkill -9 '.exe$'\")\r\n        os.system(f\"touch {file_path}\")\r\n        restart_program() \r\ndef update_wine():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.update\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1)\r\n        os.system(\"box64 wineserver -k &>/dev/null\")\r\n        print(f\"{G}{BOLD} Restarting WINE {W}\")\r\n        os.system(f\"touch {file_path}\")\r\n        os.system(\"python3 $PREFIX/bin/update-darkos.py\")\r\n        exit()\r\n        \r\ndef stop_virgl():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.stop-virgl\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1)\r\n        os.system(f\"touch {file_path}\")\r\n        os.system(\"killall virgl_test_server\")\r\n        os.system(\"ln -sf /data/data/com.termux/files/usr/glibc/lib/libGL.so.1.7.0 /data/data/com.termux/files/usr/glibc/lib/libGL.so.1\")\r\n        unset_path = \"/data/data/com.termux/files/usr/glibc/opt/scripts/unset.conf\"\r\n        exec(open(unset_path).read(), globals())\r\ndef start_virgl():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.start-virgl\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1)\r\n        os.system(f\"touch {file_path}\")\r\n        unset_path = \"/data/data/com.termux/files/usr/glibc/opt/scripts/unset.conf\"\r\n        exec(open(unset_path).read(), globals())\r\n        time.sleep(2)\r\n        virgl_path = \"/data/data/com.termux/files/usr/glibc/opt/scripts/virgl-settings.conf\"\r\n        exec(open(virgl_path).read(), globals())\r\ndef reload_style():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.style\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1)\r\n        os.system(f\"touch {file_path}\")  \r\n        os.system(\"python3 $PREFIX/glibc/opt/scripts/theme-changer.py\")\r\ndef shutdown_wine():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.shutdown\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1) \r\n        os.system(f\"touch {file_path}\")\r\n        stop_darkos()\r\ndef debug_wine():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.debug\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1) \r\n        os.system(\"box64 wineserver -k &>/dev/null\")\r\n        print(f\"{G}{BOLD} Restarting WINE {W}\")\r\n        os.system(f\"touch {file_path}\")\r\n        os.system(\"python3 $PREFIX/bin/debug-darkos.py\")\r\n        exit()\r\ndef settings_wine():\r\n    while True:\r\n        file_path = \"/data/data/com.termux/files/usr/glibc/opt/darkos/file.setting\"\r\n        while os.path.exists(file_path):\r\n            time.sleep(1) \r\n        os.system(\"box64 wineserver -k &>/dev/null\")\r\n        print(f\"{G}{BOLD} Restarting WINE {W}\")\r\n        os.system(f\"touch {file_path}\")\r\n        os.system(\"chmod +x /data/data/com.termux/files/usr/bin/install.sh\")\r\n        os.system(\"am start -n com.termux/.app.TermuxActivity &>/dev/null\")\r\n        subprocess.run([\"bash\", \"install.sh\"])\r\n        time.sleep(1)\r\n        restart_program() \r\ndef input_action():\r\n    while True:\r\n        stop = input()\r\n        if stop != \"1\" and stop != \"2\":\r\n            print(\"\")\r\n            print(f\"{G}{BOLD} Rebooting......... {W}\")\r\n            os.system(\"box64 wineserver -k &>/dev/null\")\r\n            time.sleep(1)\r\n            restart_program() \r\n        elif stop == \"1\":\r\n            stop_darkos()\r\n        elif stop == \"2\":\r\n            os.system(\"box64 wineserver -k\")\r\n            os.system('pkill -f \"app_process / com.termux.x11\"')\r\n            os.system('pkill -f pulseaudio')\r\n            print(f\"{G}{BOLD} exiting to the terminal goodbye {W}\")\r\n            time.sleep(2)\r\n            os._exit(0)\r\ndef restart_program():\r\n    extract_and_delete_tar_files()                \r\n    load_conf()\r\n    if not os.path.exists(wine_prefix):\r\n        create_wine_prefix()\r\n        extract_and_delete_tar_files()                \r\n        load_conf()\r\n    start_wine()\r\ndef stop_darkos():\r\n    os.system(\"box64 wineserver -k\")\r\n    os.system('pkill -f \"app_process / com.termux.x11\"')\r\n    os.system('pkill -f pulseaudio')\r\n    print(f\"{G}{BOLD} shutdown........ {W}\")\r\n    os.system(\"am startservice -a com.termux.service_stop com.termux/.app.TermuxService\")\r\n    os.system(\"pkill -f com.termux.x11\")\r\n    subprocess.run(['am', 'broadcast', '-a', 'com.termux.x11.ACTION_STOP', '-p', 'com.termux.x11'])\r\n    os._exit(0)\r\n\r\nrestart_program()\r\n\r\nthread1 = threading.Thread(target=restart_wine)\r\nthread2 = threading.Thread(target=input_action)\r\nthread3 = threading.Thread(target=update_wine)\r\nthread4 = threading.Thread(target=settings_wine)\r\nthread5 = threading.Thread(target=debug_wine)\r\nthread6 = threading.Thread(target=shutdown_wine)\r\nthread7 = threading.Thread(target=start_virgl)\r\nthread8 = threading.Thread(target=stop_virgl)\r\nthread9 = threading.Thread(target=reload_style)\r\n\r\nthread1.start()\r\nthread2.start()\r\nthread3.start()\r\nthread4.start()\r\nthread5.start()\r\nthread6.start()\r\nthread7.start()\r\nthread8.start()\r\nthread9.start()\r\n\r\n\r\nthread1.join()\r\nthread2.join()\r\nthread3.join()\r\nthread4.join()\r\nthread5.join()\r\nthread6.join()\r\nthread7.join()\r\nthread8.join()\r\nthread9.join()\r\n"
  },
  {
    "path": "setting-darkos.py",
    "content": "import os, time, shutil, sys, subprocess, urllib.request, urllib.error\r\nimport tarfile\r\nimport socket\r\nimport fnmatch\r\nimport zipfile\r\nimport tarfile\r\nfrom tqdm import tqdm\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\" \r\n\r\ntar_xz_file_path ='/sdcard/darkos/airidosas252builds/wine.tar.xz'\r\ntarget_folders = ['bin', 'lib', 'lib64', 'share']\r\ndestination_dir = '/data/data/com.termux/files/usr/glibc/opt/wine/3/wine'\r\nroot_dir = \"/data/data/com.termux/files/usr/glibc/opt/temp\"\r\nos.system(\"am start -n com.termux/.HomeActivity\")\r\n\r\ndef extract_archive(file_path, extract_to):\r\n    if not os.path.exists(file_path):\r\n        print(f\"{R}File does not exist: {file_path}{W}\")\r\n        return\r\n\r\n    if file_path.endswith('.zip'):\r\n        with zipfile.ZipFile(file_path, 'r') as zip_ref:\r\n            file_size = sum((file.file_size for file in zip_ref.infolist()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in zip_ref.infolist():\r\n                    zip_ref.extract(file, extract_to)\r\n                    pbar.update(file.file_size)\r\n\r\n    elif file_path.endswith('.tar.gz') or file_path.endswith('.tgz') or file_path.endswith('.tar'):\r\n        with tarfile.open(file_path, 'r') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    elif file_path.endswith('.tar.xz') or file_path.endswith('.txz'):\r\n        with tarfile.open(file_path, 'r:xz') as tar_ref:\r\n            file_size = sum((file.size for file in tar_ref.getmembers()))\r\n            with tqdm(total=file_size, unit='B', unit_scale=True, desc=f'{G}Extracting{C}', bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}]') as pbar:\r\n                for file in tar_ref.getmembers():\r\n                    tar_ref.extract(file, extract_to)\r\n                    pbar.update(file.size)\r\n\r\n    else:\r\n        print(f\"{R}Unsupported file format{W}\")\r\n        return\r\n\r\ndef remove():\r\n    folder_path = '/data/data/com.termux/files/home'\r\n    for filename in os.listdir(folder_path):\r\n        if fnmatch.fnmatch(filename, '*.tar.xz*'):\r\n            file_path = os.path.join(folder_path, filename)\r\n            os.remove(file_path)\r\n            print(f'{C}{filename} {G}has been deleted.{W}')\r\ndef uninstall_wine9():\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/wine/bin\"):\r\n        os.system(\"rm -r /data/data/com.termux/files/usr/glibc/opt/wine/1/wine\")\r\n        if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine\"):\r\n            shutil.rmtree('/data/data/com.termux/files/usr/glibc/opt/wine/1/.wine')\r\n    if os.path.exists(\"/sdcard/darkos\"):\r\n        os.system(\"rm -r /sdcard/darkos\")\r\ndef install_wine9():\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/AZ.tar.xz\")\r\n    extract_archive('AZ.tar.xz','/data/data/com.termux/files/usr/glibc/')\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/wine-default.tar.xz\")\r\n    extract_archive('wine-default.tar.xz','/data/data/com.termux/files/usr/glibc/opt/wine/1/')\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/darkos.tar.xz\")\r\n    extract_archive('darkos.tar.xz','/sdcard/')\r\n    os.system(\"wget -q --show-progress https://github.com/ahmad1abbadi/darkos/releases/download/beta/update.tar.xz\")\r\n    extract_archive('update.tar.xz','/data/data/com.termux/files/home/')\r\n    os.system(\"rm $PREFIX/bin/darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/update-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/run-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/debug-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/setting-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/darkos\")\r\n    os.system(\"wget -O run-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/run-darkos.py\")\r\n    os.system(\"wget -O darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos.py\")\r\n    os.system(\"wget -O darkos https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos\")\r\n    os.system(\"wget -O debug-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/debug-darkos.py\")\r\n    os.system(\"wget -O setting-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/setting-darkos.py\")\r\n    os.system(\"wget -O update-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/update-darkos.py\")\r\n    os.system(\"chmod +x darkos\")\r\n    os.system(\"mv update-darkos.py darkos.py run-darkos.py debug-darkos.py setting-darkos.py darkos $PREFIX/bin/\")\r\n    remove()\r\n    print(\"\")\r\n    print(f\"{G} DARKOS files repaired successfully {W}\")\r\ndef internet_connected():\r\n    try:\r\n        socket.create_connection((\"8.8.8.8\", 53), timeout=1)\r\n        return True\r\n    except OSError:\r\n        pass\r\n    return False\r\ndef wine_manager():\r\n  os.system(\"clear\")\r\n  photo()\r\n  print(f\"{R}[{W}-{R}]{G}{BOLD} Wine Manager ⚙️ {W}\")\r\n  print(f\"{Y} 1) install wine manually in container 3 📥 {W}\")\r\n  print(f\"{Y} 2) uninstall wine 📤 {W}\")\r\n  print(f\"{Y} 3) Repair DARKOS files 🔧 {W}\")\r\n  print(f\"{Y} 4) back to main menu 🔙  {W}\")\r\n  print(\"\")\r\n  choice = input()\r\n  if choice != \"1\" and choice != \"2\" and choice != \"3\" and choice != \"4\" and choice != \"dev\":\r\n    print(\"wrong\")\r\n    wine_manager()\r\n  elif choice == \"1\":\r\n    wine_select()\r\n  elif choice == \"dev\":\r\n    os.system(\"clear\")\r\n    conf_path = \"/data/data/com.termux/files/usr/glibc/opt/wine/os.conf\"\r\n    print(f\"{G}{BOLD} share log on our Telegram group {W}\")\r\n    print(f\"{G}{BOLD} to exit dev mode {C} kill termux {G}or press {C}Ctrl + C {W}\")\r\n    exec(open(conf_path).read())\r\n    exec(open('/sdcard/darkos/darkos_dynarec.conf').read())\r\n    os.system(\"BOX86_LOG=1 BOX86_SHOWSEGV=1 BOX86_DYNAREC_LOG=1 BOX86_DYNAREC_MISSING=1 BOX86_DLSYM_ERROR=1 BOX64_LOG=1 BOX64_SHOWSEGV=1 BOX64_DYNAREC_LOG=1 BOX64_DYNAREC_MISSING=1 WINEDEBUG=warn+all BOX64_DLSYM_ERROR=1 WINEDEBUG=+err taskset -c 4-7 box64 wine explorer /desktop=shell,800x600 $PREFIX/glibc/opt/apps/pc.ex >/sdcard/darkos.log\")\r\n  elif choice == \"2\":\r\n      uninstall_wine()\r\n  elif choice == \"3\":\r\n      print(f\"{Y} Do you really want to repair Wine files ? This will delete all your files inside the drive C in container 1 {W}\")\r\n      print(f\"{C} yes = y {W}\")\r\n      print(f\"{C} no = n {W}\")\r\n      stop = input()\r\n      if stop != \"y\" and choice != \"n\":\r\n          print(f\"{R} wrong choice going back to main menu {W}\")\r\n          time.sleep(1)\r\n          wine_manager()\r\n      elif stop == \"y\":\r\n          if internet_connected():\r\n               uninstall_wine9()\r\n               time.sleep(1)\r\n               install_wine9()\r\n               print(f\"{G} done.... {W}\")\r\n               time.sleep(1)\r\n               wine_manager()\r\n          else:\r\n               print(f\"{R} No internet connection available. Aborting operation. {W}\")\r\n               time.sleep(1)\r\n               wine_manager()\r\n      elif stop == \"n\":\r\n          wine_manager()\r\n  elif choice == \"4\":\r\n      os.system(\"python3 $PREFIX/bin/darkos.py\")\r\n      os.system(\"exit\")\r\ndef photo():\r\n  os.system(\"python3 $PREFIX/bin/photo.py\")\r\ndef uninstall_wine():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{Y} Are you sure you want to delete the wine version? {W}\")\r\n    print(\"\")\r\n    \r\n    for i in range(2, 6):\r\n        if os.path.exists(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{i}/wine/bin\"):\r\n            print(f\"{Y} {i - 1}) Delete wine on container {C}{i} {W}\")\r\n            \r\n    print(f\"{Y} else) setting menu ⬅️ {W}\")\r\n    print(\"\")\r\n    \r\n    choice = input()\r\n    \r\n    if choice != \"1\" and choice != \"2\" and choice != \"3\" and choice != \"4\":\r\n        print(f\"{G} backing {W}\")\r\n        wine_manager()\r\n    else:\r\n        container_number = int(choice) + 1\r\n        if os.path.exists(f\"/data/data/com.termux/files/usr/glibc/opt/wine/{container_number}/wine/bin\"):\r\n            print(f\"{G}{BOLD} Deleting wine, please wait.... {W}\")\r\n            print(\"\")\r\n            os.system(f\"rm -r /data/data/com.termux/files/usr/glibc/opt/wine/{container_number}/wine\")\r\n            os.system(\"rm -r /data/data/com.termux/files/usr/glibc/opt/wine/os.conf\")\r\n            os.system(\"cp /data/data/com.termux/files/usr/glibc/opt/wine/1/os.conf /data/data/com.termux/files/usr/glibc/opt/wine\")\r\n        wine_manager()\r\ndef install_wine3():\r\n    if os.path.exists(\"/sdcard/darkos/airidosas252builds/wine.tar.xz\"):\r\n        os.remove(\"/sdcard/darkos/airidosas252builds/wine.tar.xz\")\r\n    conf_path = f\"/data/data/com.termux/files/usr/glibc/opt/wine/3/os.conf\"\r\n    wine_prefix = f\"/data/data/com.termux/files/usr/glibc/opt/wine/3/.wine\"\r\n    exec(open(conf_path).read())\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Creating wine prefix 💫 {W}\")\r\n    if not os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin/wine64\"):\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin/wine $PREFIX/glibc/bin/wine64\")\r\n        os.system(f\"ln -sf /data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin/wine $PREFIX/glibc/opt/wine/3/wine/bin/wine64\")\r\n    os.system(f'WINEDLLOVERRIDES=\"mscoree=disabled\" box64 wine64 wineboot  >/sdcard/darkos/boot64_log.txt 2>&1')\r\n    os.system(f'cp -r $PREFIX/glibc/opt/Startxmenu/* \"{wine_prefix}/drive_c/ProgramData/Microsoft/Windows/Start Menu\"')\r\n    os.system(f'rm \"{wine_prefix}/dosdevices/z:\"')\r\n    os.system(f'ln -s /sdcard/Download \"{wine_prefix}/dosdevices/o:\" &>/dev/null')\r\n    os.system(f'ln -s /sdcard/darkos \"{wine_prefix}/dosdevices/e:\" &>/dev/null')\r\n    os.system(f'ln -s /data/data/com.termux/files \"{wine_prefix}/dosdevices/z:\"')\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} Installing DXVK+Zink... {W}\")\r\n    os.system(f'box64 wine64 \"$PREFIX/glibc/opt/apps/Install OS stuff.bat\" &>/dev/null')\r\n    print(f\"{G}{BOLD} Done! {W}\")\r\n    print(f\"{G}{BOLD} prefix done enjoy 🤪 {W}\")\r\n    print(\"to select installed wine please choose container 3 \")\r\n    time.sleep(3)\r\n    os.system(\"box64 wineserver -k &>/dev/null\")\r\n    time.sleep(1)\r\n    wine_manager()\r\ndef wine_select():\r\n    os.system(\"clear\")\r\n    photo()\r\n    print(f\"{C}{BOLD} welcome to installation airidosas bulid of wine . {Y} \\nplease make sure you have wine setup file in this path {G}/sdcard/darkos/airidosas252builds/wine.tar.xz {W}\")\r\n    print(\"\")\r\n    if os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"):\r\n        print(f\"{R} error ...there is a wine installed in container 3 {W}\")\r\n    if not os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"):\r\n        print(\"\")\r\n        print(f\"{Y} 1) install airidosas252builds wine on container 3. {W}\")\r\n        print(\"\")\r\n        print(f\"{G} please make sure you have renamed file to {C}wine.tar.xz {W}\")\r\n        print(\"\")\r\n    print(f\"{Y} else) back to wine manger menu ⬅️ {W}\")\r\n    print(\"\")\r\n    choice = input()\r\n    if choice != \"1\":\r\n        print(f\"{G} back to wine manger.... {W}\")\r\n        wine_manager()\r\n    elif choice == \"1\":\r\n        print(f\"{G} installing airidosas252builds wine please wait..... {W}\")\r\n        print(\"\")\r\n        if not os.path.exists(\"/data/data/com.termux/files/usr/glibc/opt/wine/3/wine/bin\"):\r\n            if os.path.exists(\"/sdcard/darkos/airidosas252builds/wine.tar.xz\"):\r\n                extract_archive('/sdcard/darkos/airidosas252builds/wine.tar.xz','/data/data/com.termux/files/usr/glibc/opt/temp/')\r\n            search_and_move_folders(root_dir, target_folders, destination_dir)\r\n        install_wine3()\r\n        time.sleep(1)\r\n    wine_manager()\r\ndef search_and_move_folders(root_dir, target_folders, destination_dir):\r\n    for root, dirs, files in os.walk(root_dir):\r\n        for folder in dirs:\r\n            if folder in target_folders:\r\n                source_path = os.path.join(root, folder)\r\n                destination_path = os.path.join(destination_dir, folder)\r\n                if not os.path.exists(destination_path):\r\n                    shutil.move(source_path, destination_path)\r\nwine_manager()\r\n\r\n"
  },
  {
    "path": "shutdown.sh",
    "content": "#!/data/data/com.termux/files/usr/bin/bash\r\n\r\nexport PATH=/data/data/com.termux/files/usr/bin\r\nunset LD_LIBRARY_PATH\r\n\r\nsleep 1\r\nbox64 wineserver -k &>/dev/null\r\npkill -f \"app_process / com.termux.x11\"\r\npkill -f pulseaudio\r\nsleep 1\r\n\r\nexit \r\n"
  },
  {
    "path": "terminal_utility/colors.properties",
    "content": "foreground=   #81B5AC\nbackground=   #031A16\ncursor=  #81B5AC\n\ncolor0=       #031A16\ncolor1=       #3E9688\ncolor2=       #883E96\ncolor3=       #3E4C96\ncolor4=       #96883E\ncolor5=       #4C963E\ncolor6=       #963E4C\ncolor7=       #81B5AC\n\ncolor8=       #2B685E\ncolor9=       #3E9688\ncolor10=      #883E96\ncolor11=      #3E4C96\ncolor12=      #96883E\ncolor13=      #4C963E\ncolor14=      #963E4C\ncolor15=      #D2E7E4\n\ncolor16=      #3E7996\ncolor17=      #3E965B\ncolor18=      #0B342D\ncolor19=      #184E45\ncolor20=      #5F9C92\ncolor21=      #A7CEC8"
  },
  {
    "path": "terminal_utility/darkos-motd.sh",
    "content": "#!/data/data/com.termux/files/usr/bin\nW=\"\\e[0;39m\"\nG=\"\\e[1;32m\"\nC=\"\\e[1;36m\"\nY='\\033[1;33m'\nR=\"\\e[1;31m\"\nBOLD='\\033[1m'\n\nif [[ -d /system/app/ && -d /system/priv-app ]]; then\n    DISTRO=\"Android $(getprop ro.build.version.release)\"\n    MODEL=\"$(getprop ro.product.brand) $(getprop ro.product.model)\"\nfi\ncpu=$(</sys/class/thermal/thermal_zone0/temp)\nTEMP=$(echo $cpu | cut -c 1-2)\nPROCESSOR_NAME=$(cat /proc/cpuinfo | grep Hardware | cut -d ' ' -f 2)\nPROCESSOR_COUNT=$(grep -ioP 'processor\\t:' /proc/cpuinfo | wc -l)\n\n[[ \"$TEMP\" -lt \"60\" ]] && FG=${G}\n[[ \"$TEMP\" -gt \"60\" ]] && FG=${Y}                      \n[[ \"$TEMP\" -gt \"75\" ]] && FG=${R}\n\nclear\n\nLOGO=\"\n██████╗░░█████╗░██████╗░██╗░░██╗   ░█████╗░░██████╗\n██╔══██╗██╔══██╗██╔══██╗██║░██╔╝   ██╔══██╗██╔════╝\n██║░░██║███████║██████╔╝█████═╝░   ██║░░██║╚█████╗░\n██║░░██║██╔══██║██╔══██╗██╔═██╗░   ██║░░██║░╚═══██╗\n██████╔╝██║░░██║██║░░██║██║░╚██╗   ╚█████╔╝██████╔╝\n╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝   ░╚════╝░╚═════╝░\n\"\n\n# get free memory\nIFS=\" \" read USED AVAIL TOTAL <<<$(free -htm | grep \"Mem\" | awk {'print $3,$7,$2'})\nprintf \"      %+25s ${G}${LOGO}${W}\"\necho -e \"\n${W}${BOLD}System Info:\n$C OS         :$W$BOLD Dark OS\n$C Distro     : $W$DISTRO\n$C Host       : $W$MODEL\n$C Kernel     : $W$(uname -sr)\n$C CPU        : $W$PROCESSOR_NAME ($G$PROCESSOR_COUNT$W vCPU)\n$C Memory     : $G$USED$W used, $G$AVAIL$W avail, $G$TOTAL$W total$W\n$C Temperature: $G${TEMP}°c$W\"\n\nmax_usage=95\nbar_width=45\n\n# disk usage: ignore zfs, squashfs & tmpfs\nmapfile -t dfs < <(df -H -t sdcardfs -t fuse -t fuse.rclone | tail -n+2)\nprintf \"\\n${BOLD}Disk Usage:${W}\\n\"\n\nfor line in \"${dfs[@]}\"; do\n    # get disk usage\n    usage=$(echo \"$line\" | awk '{print $5}' | sed 's/%//')\n    used_width=$((($usage*$bar_width)/100))\n    # color is green if usage < max_usage, else red\n    if [ \"${usage}\" -ge \"${max_usage}\" ]; then\n        color=$R\n    else\n        color=$G\n    fi\n    # print green/red bar until used_width\n    bar=\"[${color}\"\n    for ((i=0; i<$used_width; i++)); do\n        bar+=\"#\"\n    done\n    # print dimmmed bar until end\n    bar+=\"${white}${dim}\"\n    for ((i=$used_width; i<$bar_width; i++)); do\n        bar+=\"-\"\n    done\n    bar+=\"${undim}]\"\n    # print usage line & bar\n    echo \"${line}\" | awk '{ printf(\"%-30s used %+1s of %+4s\\n\", $6, $3, $2); }' | sed -e 's/^/  /'\n    echo -e \"${bar}\" | sed -e 's/^/  /'\ndone\n"
  },
  {
    "path": "update-darkos.py",
    "content": "import os, time, shutil, sys, subprocess, urllib.request, urllib.error, fnmatch\r\n\r\nR = \"\\033[1;31m\"\r\nG = \"\\033[1;32m\"\r\nY = \"\\033[1;33m\"\r\nB = \"\\033[1;34m\"\r\nC = \"\\033[1;36m\"\r\nW = \"\\033[1;37m\"\r\nBOLD = \"\\033[1m\"\r\n\r\ncurrent_version = \"0.971\"\r\nurl = 'https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/currently%20version.txt'\r\ndef remove():\r\n    folder_path = '/data/data/com.termux/files/home'\r\n    for filename in os.listdir(folder_path):\r\n        if fnmatch.fnmatch(filename, '*.tar.xz*'):\r\n            file_path = os.path.join(folder_path, filename)\r\n            os.remove(file_path)\r\n            print(f'{filename} has been deleted.')\r\nos.system(\"am start -n com.termux/.HomeActivity\")\r\nos.system(\"clear\")\r\nos.system(\"python3 $PREFIX/bin/photo.py\")\r\ntime.sleep(2)   \r\nprint(\"\")\r\nprint(f\"{R}[{W}-{R}]{G}{BOLD} Shutdown OS.... {W}\")\r\nprint(\"\")\r\nprint(f\"{R}[{W}-{R}]{G}{BOLD} checking 🔎..... {W}\")\r\ntime.sleep(1)\r\nresponse = urllib.request.urlopen(url)\r\nlatest_version = response.read().decode('utf-8').strip()\r\ntry:\r\n  if latest_version > current_version:\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} update available..... {C}updating......📥 {W}\")\r\n    os.system(\"rm $PREFIX/bin/darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/update-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/run-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/debug-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/setting-darkos.py\")\r\n    os.system(\"rm $PREFIX/bin/darkos\")\r\n    os.system(\"wget -O run-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/run-darkos.py\")\r\n    os.system(\"wget -O darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos.py\")\r\n    os.system(\"wget -O darkos https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos\")\r\n    os.system(\"wget -O debug-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/debug-darkos.py\")\r\n    os.system(\"wget -O setting-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/setting-darkos.py\")\r\n    os.system(\"wget -O update-darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/update-darkos.py\")\r\n    os.system(\"wget -O new-update.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/new-update.py\")\r\n    os.system(\"chmod +x darkos\")\r\n    os.system(\"mv update-darkos.py darkos.py run-darkos.py debug-darkos.py setting-darkos.py darkos $PREFIX/bin/\")\r\n    os.system(\"python3 new-update.py\")\r\n    time.sleep(2)\r\n    remove()\r\n    os.system(\"rm new-update.py\")\r\n    print(f\"{R}[{W}-{R}]{G}{BOLD} update completed 🎉 {W}\")\r\n    print(f\"{G}{BOLD} rebooting.... {W}\")\r\n    time.sleep(3)\r\nexcept urllib.error.HTTPError as e:\r\n  if e.code == 404:\r\n    print(f\"{R} no internet connection 😵 {C}rebooting..... {W}\")\r\n    time.sleep(2)\r\n  else:\r\n    os.system(\"rm $PREFIX/bin/darkos.py\")\r\n    os.system(\"wget -O darkos.py https://raw.githubusercontent.com/ahmad1abbadi/darkos/main/darkos.py\")\r\n    os.system(\"mv darkos.py\")\r\n    print(f\"{C} no update available {W}\")\r\n    time.sleep(3)\r\nos.system(\"python3 $PREFIX/bin/run-darkos.py\")\r\n"
  }
]